Opened 10 years ago

Closed 4 years ago

#44355 closed defect (fixed)

opencv @2.4.9 - build failure: Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o (And probable fix)

Reported by: Lord-Kamina (Gregorio Litenstein) Owned by: stromnov (Andrey Stromnov)
Priority: Normal Milestone:
Component: ports Version: 2.3.1
Keywords: Cc:
Port: opencv

Description

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)

Attachments (1)

patch-OpenCVPCHSupport.cmake.diff (1.3 KB) - added by Lord-Kamina (Gregorio Litenstein) 10 years ago.
Patch file

Download all attachments as: .zip

Change History (6)

Changed 10 years ago by Lord-Kamina (Gregorio Litenstein)

Patch file

comment:1 Changed 10 years ago by mf2k (Frank Schima)

Keywords: undefined symbols crt1.10.6 removed
Owner: changed from macports-tickets@… to stromnov@…

In the future, please Cc the port maintainers (port info --maintainers opencv).

comment:2 in reply to:  1 Changed 10 years ago by Lord-Kamina (Gregorio Litenstein)

Replying to mf2k@…:

In the future, please Cc the port maintainers (port info --maintainers opencv).

Whoops, sorry; first time opening a ticket.

comment:3 Changed 4 years ago by mascguy (Christopher Nielsen)

Given that we don't support opencv 2.x, can this be closed?

comment:4 Changed 4 years ago by mascguy (Christopher Nielsen)

This ticket is no longer relevant, as we don't have an OpenCV 2 port. Can someone close?

comment:5 Changed 4 years ago by kencu (Ken)

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.