[SOLVED] Linking Crypto++ with Qt 5.2 (OS X Mavericks)
-
Hi,
I'm trying to link a third party cryptographic library "Crypto++ 5.6.2" with my QT project however I keep getting the following error
@ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)@Here's my .pro file:
@TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qtSOURCES += main.cpp
INCLUDEPATH += /usr/include/
INCLUDEPATH += /usr/include/cryptopp/win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../usr/lib/release/ -lcryptopp
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../usr/lib/debug/ -lcryptopp
else:unix: LIBS += -L$$PWD/../../../../usr/lib/ -ldl -lpthreadINCLUDEPATH += $$PWD/../../../../usr/include
DEPENDPATH += $$PWD/../../../../usr/includewin32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../usr/lib/release/libcryptopp.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../usr/lib/debug/libcryptopp.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../../../../usr/lib/release/cryptopp.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../../../../usr/lib/debug/cryptopp.lib
else:unix: PRE_TARGETDEPS += $$PWD/../../../../usr/lib/libcryptopp.awin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../usr/lib/release/ -lsqlite3
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../usr/lib/debug/ -lsqlite3
else:unix: LIBS += -L$$PWD/../../../../usr/lib/ -lsqlite3INCLUDEPATH += $$PWD/../../../../usr/include
DEPENDPATH += $$PWD/../../../../usr/includeOTHER_FILES +=
../../../../usr/lib/libcryptopp.a
@I know I must add the "-lcryptopp" flag to the LIBS variable like so
@win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../usr/lib/release/ -lcryptopp
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../usr/lib/debug/ -lcryptopp
else:unix: LIBS += -L$$PWD/../../../../usr/lib/ -lcryptopp -ldl -lpthread@However when I do I get the following error message:
@/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -o testDaemon_CLI1 main.o -L/Users/omar/Projects/testDaemon_CLI1/../../../../usr/lib/ -ldl -lpthread -lsqlite3 -lcryptopp
ld: library not found for -lcryptopp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [testDaemon_CLI1] Error 1 @I compiled a version of my project on the command-line with no problems using the same libraries, but for some reason QT seems to be having a problem with it, can anyone help?
Thanks!
-
Hi and welcome to devnet,
What does happen if you give the absolute path to libcryptopp.dylib ?
-
And for the first error, are you sure your dependencies are of the correct architecture ?
-
Thanks for the quick reply!
There is no libcryptopp.dylib, when you compile the Crypto++ Library you only get libcryptopp.a and libcryptopp.so, which worked when compiling from the command-line with the "-lcryptopp" flag.
Yes I'm sure, all the libraries were compiled on the same machine and the project with the same exact code and the same libraries worked on the command-line, but for some reason doesn't work for the QT project.
-
A .so on OS X ? That's quite strange
Then, did you try giving the absolute path to libcryptopp ?
-
I added this line to the .pro file
@unix: LIBS += /usr/lib/libcryptopp.a -lcryptopp@The error I got was:
@/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -o testDaemon_CLI1 main.o -L/Users/omar/Projects/testDaemon_CLI1/../../../../usr/lib/ -ldl -lpthread -lsqlite3 /usr/lib/libcryptopp.a -lcryptopp
ld: library not found for -lcryptopp
clang: error: linker command failed with exit code 1 (use -v to see invocation)@And I'm sure the file is there:
@/usr/lib$ ls|grep crypto
libcrypto.0.9.7.dylib
libcrypto.0.9.8.dylib
libcrypto.dylib
libcryptopp.a
libcryptopp.so
libk5crypto.dylib
@EDIT: You were right! I only needed the absolute path without the flag, I added this to my .pro file instead of the above:
@unix: LIBS += /usr/lib/libcryptopp.a@
And everything works beautifully as it did on the command-line! Thank you so much for your help, I've been puzzling over this for hours! :)