Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors such as: Error when building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o #4

Closed
monocongo opened this issue May 17, 2019 · 6 comments
Assignees

Comments

@monocongo
Copy link

Thanks for providing this script, as I will need OpenCV for software I plan to run on my Jetson Nano board.

I have run the build script and it failed right near the end. [please see the output copied from the console]

This was run on a fresh Jetson Nano. The only thing I've done there before running the build script was to update/install a few packages (following this tutorial):

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install git cmake
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install libhdf5-serial-dev hdf5-tools
$ sudo apt-get install python3-dev
$ cd ~/git 
$ git clone https://github.com/mdegans/nano_build_opencv.git
$ cd nano_build_opencv
$ ./build_opencv.sh 

The final message in the output (where the fatal error occurs?) appears to be Python2 related. Is it necessary to build OpenCV for Python2 support? I don't plan to use Python2 (all my Python code is Python 3.6+), so maybe I can eliminate the parts that are building for Python2 support and maybe bypass this error as a result?

I apologize I'm unfamiliar with OpenCV builds, compilation error messages, etc. so I'm dependent on others to make sense of this for me. If I can help debug or troubleshoot this issue further from my end then please ask so I can help you help me.

@mdegans
Copy link
Owner

mdegans commented May 20, 2019

I'd be happy to help. It looks like it's failing at the building python2 module. One possible troubleshooting step is to try to build without python2 and see if that fixes it. here is a version with no Python2 support. Please let me know if it builds.

Also, please note that building OpenCV requires a lot of memory. If you encounter failures at random points, you might consider running headless (ssh in and then systemctl isolate multi-user.target). A swap file might also help, but I would recommend mounting it on an external drive if you do use one. Swapping from a MicroSD card severely hurts it's lifespan.

@monocongo
Copy link
Author

monocongo commented May 21, 2019

Thanks, @mdegans. I will give this a try.

I appreciate the heads up about running a swap file on my microSD card, as I just set that up today. I guess I will switch over to an external hard drive for swap.

I was able to get OpenCV version 4.0 to build/install using this script from NVIDIA.

@mdegans
Copy link
Owner

mdegans commented May 21, 2019

Thanks, @mdegans. I will give this a try.

I appreciate the heads up about running a swap file on my microSD card, as I just set that up today. I guess I will switch over to an external hard drive for swap.

That's a good solution, just make sure it's usb3 and fast. You can use the hdparm utility to benchmark drives on linux. For example sudo hdparm -t /dev/mmcblk0 will read benchmark your MicroSD on nano. If it's not installed, you can install it with sudo apt-get install hdparm. I have benchmarked external SSDs at around 225MB/s so that's the number you should be expecting from /dev/sda (probably the name of your first usb drive) if it's a USB-3 SSD.

I was able to get OpenCV version 4.0 to build/install using this script from NVIDIA.

That script works perfectly well, but please be aware that you will likely have similar issues if you try to build without enough free memory. It will probably work fine until it comes time to link everything together at the end, and then fail at some random thing, yielding no useful google results from the error message.

@mdegans mdegans changed the title Error when building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o Errors such as: Error when building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o Aug 2, 2019
@m7mdosama
Copy link

I'd be happy to help. It looks like it's failing at the building python2 module. One possible troubleshooting step is to try to build without python2 and see if that fixes it. here is a version with no Python2 support. Please let me know if it builds.

Also, please note that building OpenCV requires a lot of memory. If you encounter failures at random points, you might consider running headless (ssh in and then systemctl isolate multi-user.target). A swap file might also help, but I would recommend mounting it on an external drive if you do use one. Swapping from a MicroSD card severely hurts it's lifespan.

The link is not found , Please update

@DaveXanatos
Copy link

Please update link for no-python2/build, as I'm encountering this same issue.

Thanks!

@mdegans
Copy link
Owner

mdegans commented Mar 3, 2020

Please update link for no-python2/build, as I'm encountering this same issue.

Thanks!

Sorry for the necropost. I removed that becuase it wasn't the root of the problem. If you are having the same issue, please try building again with a swap file / partition.

Repository owner locked as resolved and limited conversation to collaborators Mar 3, 2020
@mdegans mdegans closed this as completed Mar 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants