Well, it's been a while since I worked on Mac, and that was in the Carbon days.
So, I've created a nice little utility library (.dylib) and it looks fine. otool -D produces this:
libGenQtSupportLib.so.dylib:
libGenQtSupportLib.so.1.dylib
libGenQtSupportLib.so.dylib:
libGenQtSupportLib.so.1.dylib
To copy to clipboard, switch view to plain text mode
so that looks nice, and the otool -L produces this:
libGenQtSupportLib.so.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
libGenQtSupportLib.so.1.dylib (compatibility version 1.0.0, current version 1.0.0)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.6.0, current version 5.6.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.6.0, current version 5.6.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
To copy to clipboard, switch view to plain text mode
and I think that looks ok. I'm not sure what the @rpath is, though...
So, now I'm trying to link to it, and the linker claims it can't find the library:
Here's the relevant part of my application .pro:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QMAKE_CXXFLAGS += "-std=c++11 -D__TESTING__"
QMAKE_CXXFLAGS_DEBUG += -O0
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
TARGET = configPropertiesBundler
TEMPLATE = app
CONFIG += debug
GENQTSUPPORTLIBDIR = $$(DEV)/Qt/GenQtSupportLib
INCLUDEPATH += $${GENQTSUPPORTLIBDIR}
LIBS += -l$${GENQTSUPPORTLIBDIR}/libGenQtSupportLib.so.dylib
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QMAKE_CXXFLAGS += "-std=c++11 -D__TESTING__"
QMAKE_CXXFLAGS_DEBUG += -O0
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
TARGET = configPropertiesBundler
TEMPLATE = app
CONFIG += debug
GENQTSUPPORTLIBDIR = $$(DEV)/Qt/GenQtSupportLib
INCLUDEPATH += $${GENQTSUPPORTLIBDIR}
LIBS += -l$${GENQTSUPPORTLIBDIR}/libGenQtSupportLib.so.dylib
To copy to clipboard, switch view to plain text mode
What looks like the 'ld' command in the 'compile output' window is here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names
-stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-mmacosx-version-min=10.7 -Wl,-rpath,/Users/Shared/devtools/qt5r/lib -o configPropertiesBundler.app/Contents/MacOS/configPropertiesBundler
main.o mainwindow.o OpenPropertiesBundleDialog.o moc_mainwindow.o moc_OpenPropertiesBundleDialog.o
-F/Users/Shared/devtools/qt5r/lib
---> -l/Users/Shared/dev/Qt/GenQtSupportLib/libGenQtSupportLib.so <-----
-framework QtWidgets -framework QtGui -framework QtCore -framework OpenGL -framework AGL
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names
-stdlib=libc++ -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-mmacosx-version-min=10.7 -Wl,-rpath,/Users/Shared/devtools/qt5r/lib -o configPropertiesBundler.app/Contents/MacOS/configPropertiesBundler
main.o mainwindow.o OpenPropertiesBundleDialog.o moc_mainwindow.o moc_OpenPropertiesBundleDialog.o
-F/Users/Shared/devtools/qt5r/lib
---> -l/Users/Shared/dev/Qt/GenQtSupportLib/libGenQtSupportLib.so <-----
-framework QtWidgets -framework QtGui -framework QtCore -framework OpenGL -framework AGL
To copy to clipboard, switch view to plain text mode
(note that my support lib name is truncated to '.so' without the '.dylib')
And the error output is:
ld: library not found for -l/Users/Shared/dev/Qt/GenQtSupportLib/libGenQtSupportLib.so
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: library not found for -l/Users/Shared/dev/Qt/GenQtSupportLib/libGenQtSupportLib.so
clang: error: linker command failed with exit code 1 (use -v to see invocation)
To copy to clipboard, switch view to plain text mode
... which is probably correct, given that it's looking for a '.so', even though I specified a '.so.dylib'
So, what am I missing? I'm sure the path is correct - the lib is really there. I've tried both the -L<path> -l<shortname> and the -l<fullname> variants and still get the same issue.
I guess I could create a '.so' link to the .dylib so it would find it, but that doesn't seem very proper.
(Note the question is re: link-time/symbol resolution time, not run-time.)
Any thoughts appreciated.
rickb
Bookmarks