Cannot link to my own libraries in Qt 5.2.0 OSX w/clang++
-
I've been updating some of my code run under Qt5 on OSX and have come across an issue whereby I seem unable to link to libraries that I have created. One of my build scripts works in three stages, firstly it builds a core library that contains some basic classes that aren't GUI dependant. It then builds a library containing custom widgets which relies on the first library. The final stage builds some designer plugins.
The first stage seems to build successfully and the resulting .dylibs are installed in /usr/lib. But when the second build reaches the linking stage, clang++ says it cannot find the library.
@ld: library not found for -labcsCore@The same code compiles cleanly in linux using the same version of Qt 5.2.0 although obviously using gcc instead of clang. I have the following in the second stage project file:
@LIBS += -L/usr/lib -labcsCore@
Any ideas?
-
Hi and welcome to devnet,
Are you really sure the libraries are installed (you would need admin rights to install them) ?
Did you check using ls ?
Do they follow the normal naming scheme ?Hope these questions helps
-
Hi,
They're definitely in the right place. The project was pulled down from a working copy out of SVN. The only thing I can think of is that clang isn't looking in the directory that I'm telling it to.
@ls -lh /usr/lib/libabcs*
-rwxr-xr-x 1 root wheel 246K 26 Dec 22:25 /usr/lib/libabcsCore.1.0.0.dylib
lrwxr-xr-x 1 root wheel 23B 26 Dec 22:25 /usr/lib/libabcsCore.1.0.dylib -> libabcsCore.1.0.0.dylib
lrwxr-xr-x 1 root wheel 23B 26 Dec 22:25 /usr/lib/libabcsCore.1.dylib -> libabcsCore.1.0.0.dylib
lrwxr-xr-x 1 root wheel 23B 26 Dec 22:25 /usr/lib/libabcsCore.dylib -> libabcsCore.1.0.0.dylib
-rwxr-xr-x 1 root wheel 1.1M 12 Jul 19:53 /usr/lib/libabcsWidgets.1.0.0.dylib
lrwxr-xr-x 1 root wheel 26B 12 Jul 19:53 /usr/lib/libabcsWidgets.1.0.dylib -> libabcsWidgets.1.0.0.dylib
lrwxr-xr-x 1 root wheel 26B 12 Jul 19:53 /usr/lib/libabcsWidgets.1.dylib -> libabcsWidgets.1.0.0.dylib
lrwxr-xr-x 1 root wheel 26B 12 Jul 19:53 /usr/lib/libabcsWidgets.dylib -> libabcsWidgets.1.0.0.dylib
@@file /usr/lib/libabcsCore.dylib
/usr/lib/libabcsCore.dylib: Mach-O 64-bit dynamically linked shared library x86_64@@otool -L /usr/lib/libabcsCore.dylib
/usr/lib/libabcsCore.dylib:
libabcsCore.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/Users/andy/Qt/5.2.0/clang_64/lib/QtSql.framework/Versions/5/QtSql (compatibility version 5.2.0, current version 5.2.0)
/Users/andy/Qt/5.2.0/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.2.0, current version 5.2.0)
/Users/andy/Qt/5.2.0/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.2.0, current version 5.2.0)
/Users/andy/Qt/5.2.0/clang_64/lib/QtXml.framework/Versions/5/QtXml (compatibility version 5.2.0, current version 5.2.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)@First phase build partial results:
@<snip>
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -single_module -dynamiclib -compatibility_version 1.0 -current_version 1.0.0 -install_name libabcsCore.1.dylib -o libabcsCore.1.0.0.dylib abcs_debug.o abcs_network.o abcs_protocol.o abcs_settings.o abcs_client.o abcs_driver.o moc_abcs_core.o -F/Users/andy/Qt/5.2.0/clang_64/lib -framework QtSql -framework QtCore -framework QtNetwork -framework QtXml
ln -s libabcsCore.1.0.0.dylib libabcsCore.dylib
ln -s libabcsCore.1.0.0.dylib libabcsCore.1.dylib
ln -s libabcsCore.1.0.0.dylib libabcsCore.1.0.dylib
cp -f /Users/andy/src/abcs/libs/trunk/core/abcs_core.h /usr/include/
cp -f "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.1.0.0.dylib"
ln -f -s "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.dylib"
ln -f -s "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.1.dylib"
ln -f -s "libabcsCore.1.0.0.dylib" "/usr/lib/libabcsCore.1.0.dylib"
</snip>@Second phase error:
@/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -single_module -dynamiclib -compatibility_version 1.0 -current_version 1.0.0 -install_name libabcsWidgets.1.dylib -o libabcsWidgets.1.0.0.dylib abcsPushBtn.o abcsStatusLabel.o abcsClocks.o abcsclientwidget.o abcsFader.o abcsFaderControl.o abcsDial.o abcsDestButton.o abcsDestGrid.o abcsSourceButton.o abcsSourceGrid.o abcsGestureScroller.o abcsSmartButton.o abcsKeypad.o qrc_abcsWidgets.o moc_abcs_widgets.o -F/Users/andy/Qt/5.2.0/clang_64/lib -L/usr/lib -labcsCore -framework QtWidgets -framework QtGui -framework QtCore -framework QtXml -framework QtSql -framework QtNetwork -framework OpenGL -framework AGL
ld: library not found for -labcsCore
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [libabcsWidgets.1.0.0.dylib] Error 1
make: *** [sub-widgets-install_subtargets] Error 2
@ -
The command line looks fine to me. Can you try with a minimal project that uses libabcsCore ?
-
What does
@ls -la /usr/lib/libabcsCore*@
return ?
-
Sorry for taking so long to reply:
@ls -la /usr/lib/libabcsCore*
-rwxr-xr-x 1 root wheel 251548 26 Dec 22:25 /usr/lib/libabcsCore.1.0.0.dylib
lrwxr-xr-x 1 root wheel 23 26 Dec 22:25 /usr/lib/libabcsCore.1.0.dylib -> libabcsCore.1.0.0.dylib
lrwxr-xr-x 1 root wheel 23 26 Dec 22:25 /usr/lib/libabcsCore.1.dylib -> libabcsCore.1.0.0.dylib
lrwxr-xr-x 1 root wheel 23 26 Dec 22:25 /usr/lib/libabcsCore.dylib -> libabcsCore.1.0.0.dylib
@ -
I just realized, is it me or is -L/usr/lib missing from your linker line ?
-
I think it might be you. ;-)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -single_module -dynamiclib -compatibility_version 1.0 -current_version 1.0.0 -install_name libabcsWidgets.1.dylib -o libabcsWidgets.1.0.0.dylib abcsPushBtn.o abcsStatusLabel.o abcsClocks.o abcsclientwidget.o abcsFader.o abcsFaderControl.o abcsDial.o abcsDestButton.o abcsDestGrid.o abcsSourceButton.o abcsSourceGrid.o abcsGestureScroller.o abcsSmartButton.o abcsKeypad.o qrc_abcsWidgets.o moc_abcs_widgets.o -F/Users/andy/Qt/5.2.0/clang_64/lib -L/usr/lib -labcsCore -framework QtWidgets -framework QtGui -framework QtCore -framework QtXml -framework QtSql -framework QtNetwork -framework OpenGL -framework AGL
-
Did you try to link to your library by hand on the command line ?
-
No sorry, I meant create a dummy main using a function of your library and call clang by hand to compile/link to see it still has the same problem