Ask Your Question
0

Trying to Install OpenCV with CMake on Raspberry Pi 3+ [closed]

asked 2019-07-22 21:38:46 -0500

pcasey92 gravatar image

updated 2019-07-22 21:41:44 -0500

Hola. I have been trying to install OpenCV with CMake for the last two weeks on my Raspberry Pi 3+. I have tried around ten different tutorials just trying to get it to work, but I always have a problem at the same spot where I start the compilation of OpenCV Python. Anywhere between the 30% and 70% mark, usually, I always get the same error. I have looked everywhere for a solution with no results. I've reflashed my SD card so many times with different Raspbian images and doing my best with workarounds, I am not savvy with all this coding and stuff. I'm just trying to follow these tutorials so I can get an OpenCV People Counter working for my little shop. If anyone could help me, I'd greatly appreciate it.

/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o: in function `_start':

(.text+0x34): undefined reference to `main'

collect2: error: ld returned 1 exit status

make[2]: * [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/build.make:66: modules/core/precomp.hpp.gch/opencv_core_Release.gch] Error 1

make[1]: * [CMakeFiles/Makefile2:2896: modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2

make[1]: * Waiting for unfinished jobs.... /usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o: in function `_start':

(.text+0x34): undefined reference to `main'

collect2: error: ld returned 1 exit status

make[2]: * [modules/ts/CMakeFiles/pch_Generate_opencv_ts.dir/build.make:66: modules/ts/precomp.hpp.gch/opencv_ts_Release.gch] Error 1

make[1]: * [CMakeFiles/Makefile2:8173: modules/ts/CMakeFiles/pch_Generate_opencv_ts.dir/all] Error 2 /usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o: in function `_start':

(.text+0x34): undefined reference to `main'

collect2: error: ld returned 1 exit status

make[2]: * [modules/imgproc/CMakeFiles/pch_Generate_opencv_imgproc.dir/build.make:66: modules/imgproc/precomp.hpp.gch/opencv_imgproc_Release.gch] Error 1

make[1]: * [CMakeFiles/Makefile2:3228: modules/imgproc/CMakeFiles/pch_Generate_opencv_imgproc.dir/all] Error 2 /usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o: in function `_start':

(.text+0x34): undefined reference to `main'

collect2: error: ld returned 1 exit status

make[2]: * [modules/imgcodecs/CMakeFiles/pch_Generate_opencv_imgcodecs.dir/build.make:66: modules/imgcodecs/precomp.hpp.gch/opencv_imgcodecs_Release.gch] Error 1

make[1]: * [CMakeFiles/Makefile2:6108: modules/imgcodecs/CMakeFiles/pch_Generate_opencv_imgcodecs.dir/all] Error 2

make: * [Makefile:163: all] Error 2

Also, if anyone cares to know, these are a few of the tutorials I have tried to follow along with and I always get stuck at this issue. https://linuxize.com/post/how-to-inst... https://tutorials-raspberrypi.com/ins... https://www.learnopencv.com/install-o... https://www.pyimagesearch.com/2018/08...

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by LBerger
close date 2019-09-13 00:59:27.918132

Comments

Were you able to figure out a solution for this? I'm getting the exact same error trying to compile oCV 4.1.1 on a pi running Raspian Buster. I'm using the same tutorials as you for reference. I'm using a pi4 but I'm guessing you're running Buster on a pi 3.

ctcarroll gravatar imagectcarroll ( 2019-08-18 14:13:27 -0500 )edit

FYI... created this issue in github if you want to follow it: https://github.com/opencv/opencv/issu...

ctcarroll gravatar imagectcarroll ( 2019-08-18 15:15:04 -0500 )edit

disable ts module -DBUILD_opencv_ts:BOOL=OFF

LBerger gravatar imageLBerger ( 2019-08-18 15:18:10 -0500 )edit
1

Thanks @LBerger for the suggestion. What actually ended up solving it for me was a different cmake value suggested by someone on github. -D ENABLE_PRECOMPILED_HEADERS=NO. I also used your recommendation of -DBUILD_opencv_ts:BOOL=OFF but that alone didn't fix it for me anyway. More detail in the github issue. Thanks again!

ctcarroll gravatar imagectcarroll ( 2019-08-18 19:31:21 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-09-12 23:51:14 -0500

Volt-AmperAI gravatar image

Thanks @LBerger, you all for your help, all the libraries are installed, the modules are also running the programs from the folder with examples /home/pi/opencv/opencv-4.1.1/samples/python tried several examples, everything works as it should. I will continue to master the theme of opencv.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-07-22 21:38:46 -0500

Seen: 738 times

Last updated: Jul 22 '19