I have OpenCV 3.3.1 installed on OS 10.13.1 using Homebrew, and I'm getting a linker problem I can't diagnose. Does anyone have a clue what might be going on?
Command line:
g++ backsub.cpp `pkg-config --libs --cflags opencv` -o backsub
Returns the following error message:
ld: library not found for -llibopencv_stitching.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Using the -v option gives, for the linker section (hard wrapped to make it easier to read):
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.
xctoolchain/usr/bin/ld" -demangle -lto_library
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.
xctoolchain/usr/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64
-macosx_version_min 10.13.0 -o backsub
-L/usr/local/Cellar/opencv/3.3.1_1/lib
/var/folders/zn/p7grv7lj49lfdrvrtn7mp1kh0000gn/T/backsub-2eda30.o
-llibopencv_stitching.3.3.1.dylib -llibopencv_superres.3.3.1.dylib
-llibopencv_videostab.3.3.1.dylib -llibopencv_photo.3.3.1.dylib
-llibopencv_aruco.3.3.1.dylib -llibopencv_bgsegm.3.3.1.dylib
-llibopencv_bioinspired.3.3.1.dylib -llibopencv_ccalib.3.3.1.dylib
-llibopencv_dpm.3.3.1.dylib -llibopencv_face.3.3.1.dylib
-llibopencv_fuzzy.3.3.1.dylib -llibopencv_img_hash.3.3.1.dylib
-llibopencv_line_descriptor.3.3.1.dylib -llibopencv_optflow.3.3.1.dylib
-llibopencv_reg.3.3.1.dylib -llibopencv_rgbd.3.3.1.dylib
-llibopencv_saliency.3.3.1.dylib -llibopencv_stereo.3.3.1.dylib
-llibopencv_structured_light.3.3.1.dylib
-llibopencv_phase_unwrapping.3.3.1.dylib
-llibopencv_surface_matching.3.3.1.dylib
-llibopencv_tracking.3.3.1.dylib -llibopencv_datasets.3.3.1.dylib
-llibopencv_text.3.3.1.dylib -llibopencv_dnn.3.3.1.dylib
-llibopencv_plot.3.3.1.dylib -llibopencv_xfeatures2d.3.3.1.dylib
-llibopencv_shape.3.3.1.dylib -llibopencv_video.3.3.1.dylib
-llibopencv_ml.3.3.1.dylib -llibopencv_ximgproc.3.3.1.dylib
-llibopencv_calib3d.3.3.1.dylib -llibopencv_features2d.3.3.1.dylib
-llibopencv_highgui.3.3.1.dylib -llibopencv_videoio.3.3.1.dylib
-llibopencv_flann.3.3.1.dylib -llibopencv_xobjdetect.3.3.1.dylib
-llibopencv_imgcodecs.3.3.1.dylib -llibopencv_objdetect.3.3.1.dylib
-llibopencv_xphoto.3.3.1.dylib -llibopencv_imgproc.3.3.1.dylib
-llibopencv_core.3.3.1.dylib -lc++ -lSystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.
xctoolchain/usr/lib/clang/9.0.0/lib/darwin/libclang_rt.osx.a
ld: library not found for -llibopencv_stitching.3.3.1.dylib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
pkg-config seems to be doing the right things. All of the dylibs are in /usr/local/Cellar/opencv/3.3.1_1/lib and have the exact filenames specified in the command line. For some reason the linker isn't seeing them. Thanks for any help!
Related
I want to compile for my program and I am stuck here , I am usig freebsd 12.1 and gcc++6.4 + gnu gmake -j20 comand
Curent path
# mysql
INCDIR += -I../../../extern/mysql
LIBDIR += -L/usr/local/lib/mysq
LIBS += -lmysqlclient -lz -pthread -lm -lssl -lcrypto
### END
Error in putty
root#vps:/usr/src/Sursa/Server/source/game/src # gmake -j20
linking ../game
ld: error: unable to find library -lmysqlclient
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake: *** [Makefile:228: ../game] Error 1
root#vps:/usr/src/Sursa/Server/source/game/src #
root#vps:/usr/src/Sursa/Server/source/game/src #
I edited the typo and now i am geeting this
root#vps:/usr/src/Sursa/Server/source/game/src # gmake -j20
linking ../game
ld: error: /usr/local/lib/mysql/libmysqlclient.a(client.c.o) is incompatible with elf_i386_fbsd
ld: error: /usr/local/lib/mysql/libmysqlclient.a(libmysql.c.o) is incompatible with elf_i386_fbsd
ld: error: /usr/local/lib/mysql/libmysqlclient.a(crypt_genhash_impl.cc.o) is incompatible with elf_i386_fbsd
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake: *** [Makefile:228: ../game] Error 1
root#vps:/usr/src/Sursa/Server/source/game/src #
You have a typo in LIBDIR += -L/usr/local/lib/mysq - missing l.
Make sure you have mysql57-client package installed. If not, run pkg install mysql57-client.
Also, /usr/src dir is usually used to store FreeBSD source code. It is not a best idea to use it to store your own code.
Main question is: How do I get the clang error out of make?
I have been trying to follow these instructions to install GLEW. On second look I've seen that GLEW might not really be necessary on Mac OS X, but I'd still like to find out how to get the error from the problem I was having. (I am not very experienced with make and could not make any similar online solutions work).
Theoretically I should download GLEW, unzip, and run 'make' in the file. This is the output of make:
$ make
cc -dynamiclib -install_name /usr/local/lib/libGLEW.2.1.0.dylib -current_version 2.1.0 -compatibility_version 2.1 -o lib/libGLEW2.1.0.dylib tmp/darwin/default/shared/glew.o -framework OpenGL
ld: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks//OpenGLframework/OpenGL.tbd:4:18: error: unknown enumerated scalar
platform: zippered
^~~~~~~~
file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Framework//OpenGL.framework/OpenGL.tbd'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libGLEW.2.1.0.dylib] Error 1
Make -n shows that this is just the first command and it pretty much immediately fails. I have tried make V=1, make VERBOSE=1, and make SHELL='sh -x', but they don't give me additional detail about the clang error. I've also tried running the cc command with -v:
$ cc -v -dynamiclib -install_name /usr/local/lib/libGLEW.2.1.0.dylib -current_version 2.1.0 -compatibility_version 2.1 -o lib/libGLEW2.1.0.dylib tmp/darwin/default/shared/glew.o -framework OpenGL
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -dylib -dylib_compatibility_version 2.1 -dylib_current_version 2.1.0 -arch x86_64 -dyib_install_name /usr/local/lib/libGLEW.2.1.0.dylib -macosx_version_min 10.14.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -o lib/libGLEW.2.1.0.dylib tmp/darwin/default/shared/glew.o -framework OpenGL -L/usr/local/lib -lSystem / Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchains/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a
ld: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks//OpenGLframework/OpenGL.tbd:4:18: error: unknown enumerated scalar
platform: zippered
^~~~~~~~
file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Framework//OpenGL.framework/OpenGL.tbd'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libGLEW.2.1.0.dylib] Error 1
I don't think I am actually managing to get the real error out of clang. So how do I do that?
It is
Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -dylib -dylib_compatibility_version 2.1 -dylib_current_version 2.1.0 -arch x86_64 -dyib_install_name /usr/local/lib/libGLEW.2.1.0.dylib -macosx_version_min 10.14.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -o lib/libGLEW.2.1.0.dylib tmp/darwin/default/shared/glew.o -framework OpenGL -L/usr/local/lib -lSystem / Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchains/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a
command that fails, which is ld, not clang. You can run this command separately to get the same error message.
And
ld: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks//OpenGLframework/OpenGL.tbd:4:18: error: unknown enumerated scalar
platform: zippered
^~~~~~~~
file '/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Framework//OpenGL.framework/OpenGL.tbd'
is linker's error message. Unfortunately, I'm not familiar with compilation process on Mac, so can't advice how to fix it.
Trying to link a simple program using LLVM 4.0.0 release (Clang, LLD) on Mac OS Sierra.
Note, this is fully achievable in Linux.
My current path is prefixed with the LLVM's bin directory (i.e. /opt/LLVM/4.0.0/bin:$PATH.
The program (main.cpp) is the simplest possible C++ application:
int main()
{
return 0;
}
The shell command issued is: clang -fuse-ld=lld.
This fails with these errors:
/opt/llvm/4/bin/ld.lld: error: unknown argument: -no_deduplicate
/opt/llvm/4/bin/ld.lld: error: unknown argument: -dynamic
/opt/llvm/4/bin/ld.lld: error: unknown argument: -arch
/opt/llvm/4/bin/ld.lld: error: unknown emulation: acosx_version_min
/opt/llvm/4/bin/ld.lld: error: unable to find library -lto_library
/opt/llvm/4/bin/ld.lld: error: /opt/llvm/4/lib/libLTO.dylib: invalid data encoding
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
Using the -v switch, I see this linker command (formatted):
"/opt/llvm/4/bin/ld.lld" \
-demangle \
-lto_library /opt/llvm/4/lib/libLTO.dylib \
-no_deduplicate \
-dynamic \
-arch x86_64 \
-macosx_version_min 10.12.0 \
-o a.out \
main.o \
-lSystem /opt/llvm/4/bin/../lib/clang/4.0.0/lib/darwin/libclang_rt.osx.a
Does anyone know the proper switches for this platform?
After contacting the LLVM-dev mailing list, it appears that LLD for macOS (meaning, Mach-O object format linking) development is stale.
To use Clang on macOS, it's best to stick with the OS-provided ld64.
If the only reason to use LLVM-lld is speed, then try zld
https://github.com/michaeleisel/zld/
It's consistently cuts time to half (often to less than half) as compared to that taken by Apple-ld.
Add the following linker flag:
-fuse-ld=`which zld` -Wl,-zld_original_ld_path,ld
I'm trying to use OpenNI with my kinect but I have a problem during the build. I get this error :
ld: library not found for -lOpenNI
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When I try "ld -lOpenNI" in terminal it finds it, and the path to the libOpenNI.dylib has been added to the library search paths (it's just /usr/lib). It has also been linked in "link binary With Libraries". I have tried to clean the build folder.
The whole compiler argument is :
Ld /Users/henrax/Library/Developer/Xcode/DerivedData/handtracker-dafbaeqppvdfnfhgffkyffwhskyl/Build/Products/Debug/handtracker normal x86_64
cd /Users/henrax/Documents/handtracker
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/henrax/Library/Developer/Xcode/DerivedData/handtracker-dafbaeqppvdfnfhgffkyffwhskyl/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib -F/Users/henrax/Library/Developer/Xcode/DerivedData/handtracker-dafbaeqppvdfnfhgffkyffwhskyl/Build/Products/Debug -filelist /Users/henrax/Library/Developer/Xcode/DerivedData/handtracker-dafbaeqppvdfnfhgffkyffwhskyl/Build/Intermediates/handtracker.build/Debug/handtracker.build/Objects-normal/x86_64/handtracker.LinkFileList -mmacosx-version-min=10.9 -stdlib=libc++ -framework GLUT -framework OpenGL /Applications/Kinect/OpenNI-Bin-Dev-MacOSX-v1.5.7.10/Samples/NiHandTracker/x64-Release/NiHandTracker.o /Applications/Kinect/OpenNI-Bin-Dev-MacOSX-v1.5.7.10/Samples/NiHandTracker/x64-Release/NiHandViewer.o /Applications/Kinect/OpenNI-Bin-Dev-MacOSX-v1.5.7.10/Samples/NiHandTracker/x64-Release/NiSimpleViewer.o -lOpenNI -lOpenNI.jni /Applications/Kinect/OpenNI-Bin-Dev-MacOSX-v1.5.7.10/Samples/NiHandTracker/x64-Release/main.o -Xlinker -dependency_info -Xlinker /Users/henrax/Library/Developer/Xcode/DerivedData/handtracker-dafbaeqppvdfnfhgffkyffwhskyl/Build/Intermediates/handtracker.build/Debug/handtracker.build/Objects-normal/x86_64/handtracker_dependency_info.dat -o /Users/henrax/Library/Developer/Xcode/DerivedData/handtracker-dafbaeqppvdfnfhgffkyffwhskyl/Build/Products/Debug/handtracker
It seems like a pretty easy problem but I have searched and not found any solution. Any help would be very welcomed !
I am trying to compile lsd_slam on OSX 10.9.5 and I get the build error as
ld: library not found for -lGL
clang: error: linker command failed with exit code 1 (use -v to see invocation)
From what I understand from this SO answer, it needs to compile with the flag-framework OpenGL. What changes are needed and in which Makefile so as this choses the framework instead of -lGL.
It should link correctly if you replace -lGL by -framework OpenGL