Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [SOLVED] Linking Crypto++ with Qt 5.2 (OS X Mavericks)

[SOLVED] Linking Crypto++ with Qt 5.2 (OS X Mavericks)

Scheduled Pinned Locked Moved Installation and Deployment
6 Posts 2 Posters 4.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    heero_yuy
    wrote on last edited by
    #1

    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 -= qt

    SOURCES += 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 -lpthread

    INCLUDEPATH += $$PWD/../../../../usr/include
    DEPENDPATH += $$PWD/../../../../usr/include

    win32-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.a

    win32: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/ -lsqlite3

    INCLUDEPATH += $$PWD/../../../../usr/include
    DEPENDPATH += $$PWD/../../../../usr/include

    OTHER_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!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What does happen if you give the absolute path to libcryptopp.dylib ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        And for the first error, are you sure your dependencies are of the correct architecture ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • H Offline
          H Offline
          heero_yuy
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            A .so on OS X ? That's quite strange

            Then, did you try giving the absolute path to libcryptopp ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • H Offline
              H Offline
              heero_yuy
              wrote on last edited by
              #6

              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! :)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved