#44355: opencv @2.4.9 - build failure: Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o (And probable fix) -------------------------------------------+------------------------------- Reporter: g.litenstein@… | Owner: macports- Type: defect | tickets@… Priority: Normal | Status: new Component: ports | Milestone: Keywords: undefined, symbols, crt1.10.6 | Version: 2.3.1 | Port: opencv -------------------------------------------+------------------------------- I've been trying to get OpenCV to compile for over a week now and have been hitting this error no matter what I did. Google hadn't been very helpful until I found a post explaining that when you're not compiling an executable, this error will appear unless the "-c" flag is used. {{{ Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make[2]: *** [modules/core/precomp.hpp.gch/opencv_core_Release.gch] Error 1 make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/build' make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make[2]: *** [modules/flann/precomp.hpp.gch/opencv_flann_Release.gch] Error 1 make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/build' make[1]: *** [modules/flann/CMakeFiles/pch_Generate_opencv_flann.dir/all] Error 2 make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/build' make: *** [all] Error 2 make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/build' Command failed: cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-2.4.9/../build" && /usr/bin/make -j2 -w all Exit code: 2 Error: org.macports.build for port opencv returned: command execution failed DEBUG: Error code: CHILDSTATUS 8137 2 DEBUG: Backtrace: command execution failed while executing "system -nice 0 $fullcmdstring" ("eval" body line 1) invoked from within "eval system $notty $nice \$fullcmdstring" invoked from within "command_exec build" (procedure "portbuild::build_main" line 8) invoked from within "portbuild::build_main org.macports.build" ("eval" body line 1) invoked from within "eval $procedure $targetname" Warning: targets not executed for opencv: org.macports.activate org.macports.build org.macports.destroot org.macports.install Please see the log file for port opencv for details: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/main.log To report a bug, follow the instructions in the guide: http://guide.macports.org/#project.tickets Error: Processing of port opencv failed }}} After a bit of hunting in the port, I got to the file "opencv-2.4.9/cmake/OpenCVPCHSupport.cmake" and in there added said flag to three different lines, which resulted in the port finally building properly. (Patch attached) -- Ticket URL: <https://trac.macports.org/ticket/44355> MacPorts <http://www.macports.org/> Ports system for OS X