Trying to Install OpenCV with CMake on Raspberry Pi 3+ [closed]
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...
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.
FYI... created this issue in github if you want to follow it: https://github.com/opencv/opencv/issu...
disable ts module -DBUILD_opencv_ts:BOOL=OFF
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!