6

I am trying to install OpenCV on Raspbian by following these steps:

http://mitchtech.net/raspberry-pi-opencv/

Everything works up until I do a "make". It gets up to 61% and then I get the following error:

[61% built target opencv_perf_gpu]

[61% building CXX object modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o]

c++: internal compiler error: Killed (program cclplus)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.

make[2]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/test/test_core.cpp.o] Error 4

make[1]: *** [modules/gpu/CMakeFiles/opencv_test_gpu.dir/all] Error 2

make: *** [all] Error 2

I'm running 2012-08-16-wheezy-raspbian image, expanded to 8GB.

The website I am following is installing an older version of OpenCV [2.3.1] on a Debian image.

Do you think this is the problem? Is it worth perusing to fix this problem or should I simply revert to a older version of OpenCV and use Debian instead?

3 Answers 3

5

Your error message says that you have got internal compiler error. This means there is a bug in compiler that prevents this code from being build. It happens sometimes, especially on less supported architectures like armv6. There are couple of things you can do to try to work around this:

  • use newer version of compiler. Default version in Debian 6 is GCC-4.6 but GCC-4.7 is also available. It's easy to install, just type sudo apt-get install gcc-4.7. Installing is only one step, however. Now you have to make opencv build system (which is cmake) use it. You can try this using environment variables by prefixing cmake with: CC=gcc-4.7 CXX=g++-4.7. So it would be cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ... Or you can do this in cmake-gui. Either way, start from the beginning, remove the folders you where compiling in and create fresh new one.

  • Install older version of opencv as it seems that this was working for somebody who wrote this tutorial. This is worth a shot if changing gcc version does not help. Unless you really need features from newer version.

  • Play with g++ compiler options. Especially with optimization levels (-O option). Sometimes turning optimizations off (-O0) solves problems with internal compiler errors. I can't give you any hints on how to do this, unfortunately. You could have to mess around with cmake build system or Makefile that it creates.

4
  • right now i'm going with your 2nd bullet point of reverting to open cv 2.3.1 and rebuilding everything. If this doesn't work then i'll go with gcc-4.7. after installing gcc-4.7, how exactly do I set up those environment variables you are talking about? CC=gcc-4.7 and CXX=g++-4.7? Sep 16, 2012 at 16:04
  • You either use export CC=gcc-4.7 and export CXX=g++-4.7 commands or just type CC=gcc-4.7 CXX=g++-4.7 cmake THE REST OF THE COMMAND Sep 16, 2012 at 16:22
  • Well, I got it to work with OpenCV 2.3.1 on Raspbian Wheezy. I was able to successfully run the 3 demos "kmeans", "drawing", and "convexhull". Thanks for your help! Sep 17, 2012 at 1:15
  • You also need to install g++-4.7, that should be added to the apt-get command. Next to this, using the cmake-gui the compiler version can easily be set.
    – Geerten
    Nov 23, 2014 at 15:38
0

I'm reasonably sure you've run out of memory. You should cross compile OpenCV using your PC.

5
  • I googled the error message and saw that conclusion. But what doesn't make sense to me is how come the other fellow was able to install open cv 2.3.1 on his debian image (he even shows youtube video)? Sep 16, 2012 at 16:06
  • I'm also reading through this page: bootc.net/archives/2012/05/26/… and wondering if I end up doing this, how would this work with Open CV? Do I use my toolchain to create all the binaries for Open CV and simply copy them into my raspberry pi somewhere? How does this work? Sep 16, 2012 at 16:19
  • @user1068636: Which memory split are you using? Do you have SWAP enabled? I believe if it was problem with not enough memory, you could find traces of OOM killer in your dmesg log. Sep 16, 2012 at 16:20
  • @Krzysztof - How can you tell what kind of split you're using or if I have swap enabled? Sep 17, 2012 at 1:17
  • @user1068636: One way is to check how much available memory you have with free -m. Look for total value in Mem: row. If you don't know anything about memory split, you probably have 192MB which is default (free command will show slightly less). You could also have 128, 224 or 240. The more RAM you have, the less RAM is allocated for GPU. You can also check if your swap is enabled using the same command, just look for 'Swap:' row. If it's non-zero, you have swap enabled. Sep 17, 2012 at 5:34
-1

I had the same problem. Solution was get a new Raspberry. The old one had only 256MB memory. When I tested on the 512M version on a fresh raspbian image everything compiled ok, (6-7 hours)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.