New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: error in linker when building go-opencv on OSX #6283

Open
gopherbot opened this Issue Aug 29, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@gopherbot

gopherbot commented Aug 29, 2013

by ngaloppo:

What steps will reproduce the problem?

Build go-opencv as such: 
go build -a -x code.google.com/p/go-opencv/trunk/opencv

What is the expected output?
Successful build of the opencv package

What do you see instead?
Assertion failure in the linker: 
ld: Assertion failed: (_machoSection != 0), function machoSection, file
/SourceCache/ld64/ld64-136/src/ld/ld.hpp, line 641.

This is when running: 
gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/_all.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/_cgo_export.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cv.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cvaux.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cxcore.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cxtype.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/highgui.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/opencv.o
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_calib3d.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_contrib.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_core.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_features2d.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_flann.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_gpu.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_highgui.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_imgproc.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_legacy.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_ml.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_nonfree.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_objdetect.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_ocl.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_photo.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_stitching.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_superres.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_ts.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_video.dylib
/usr/local/Cellar/opencv/2.4.5/lib/libopencv_videostab.dylib -Wl,-r -nostdlib
/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64/libgcc.a

These warnings from ld are interesting: 

ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_calib3d.dylib) on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_contrib.dylib) on link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_core.dylib)
on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_features2d.dylib) on link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_flann.dylib)
on link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_gpu.dylib)
on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_highgui.dylib) on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_imgproc.dylib) on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_legacy.dylib) on link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_ml.dylib) on
link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_nonfree.dylib) on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_objdetect.dylib) on link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_ocl.dylib)
on link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_photo.dylib)
on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_stitching.dylib) on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_superres.dylib) on link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_ts.dylib) on
link line
ld: warning: unexpected dylib (/usr/local/Cellar/opencv/2.4.5/lib/libopencv_video.dylib)
on link line
ld: warning: unexpected dylib
(/usr/local/Cellar/opencv/2.4.5/lib/libopencv_videostab.dylib) on link line

I found that removing the $LDFLAGS as below successfully results in building:

gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/_all.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/_cgo_export.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cv.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cvaux.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cxcore.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/cxtype.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/highgui.cgo2.o
$WORK/code.google.com/p/go-opencv/trunk/opencv/_obj/opencv.o  -Wl,-r -nostdlib
/usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/x86_64/libgcc.a


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
OSX

Which version are you using?  (run 'go version')
1.1.2

Please provide any additional information below: 

Full output of "go build -a -x code.google.com/p/go-opencv/trunk/opencv"
attached.

Attachments:

  1. _all.o-2013-07-29-105717.ld-snapshot.zip (43304 bytes)
  2. build.log (38175 bytes)
@robpike

This comment has been minimized.

Contributor

robpike commented Aug 31, 2013

Comment 1:

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc

This comment has been minimized.

Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 4, 2013

Comment 3:

Labels changed: added release-none, removed go1.3maybe.

@rsc

This comment has been minimized.

Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added repo-main.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc changed the title from cmd/ld: error in linker when building go-opencv on OSX to cmd/link: error in linker when building go-opencv on OSX Jun 8, 2015

@gsymons

This comment has been minimized.

gsymons commented Oct 16, 2018

code.google.com/p/go-opencv/trunk/opencv has moved to https://github.com/chai2010/opencv, but it still fail. As the last update of the repo is Jun 13, 2015, maybe https://github.com/hybridgroup/gocv will be a good alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment