Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    OSX Library not Loaded?

    General and Desktop
    2
    3
    1684
    Loading More Posts
    • 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.
    • rootshell
      rootshell last edited by

      I have a Library named "libZip.dylib" that I have created with Qt, when I attempt to use it in a project, the application builds without any warnings or errors, but when I run the application it crashes with:

      (Should note this builds and runs fine on both windows and linux)

      /Users/bryancairns/Documents/Source/PluginService/Dist/AppTester
      dyld: Library not loaded: libZip.dylib

      I have the application in:
      /Users/bryancairns/Documents/Source/PluginService/Dist/

      I have the library in:
      /Users/bryancairns/Documents/Source/PluginService/Dist/Libs

      A few google searches instructed me to try a few things, none of which are working...

      Added to the project run settings:
      DYLD_LIBRARY_PATH = /Users/bryancairns/Documents/Source/PluginService/Dist/Libs

      Added to the applications project file different attempt to force linking:
      QMAKE_RPATHDIR += /Users/bryancairns/Documents/Source/PluginService/Dist/Libs

      And then I tried...
      QMAKE_LFLAGS += '-Wl,-rpath,'$$ORIGIN/../Libs''

      And then I tried...
      QMAKE_LFLAGS += '-Wl,-rpath,/Users/bryancairns/Documents/Source/PluginService/Dist/Libs'

      Of course I am adding the LIBS but it seems to be a linking issue?
      LIBS += -L$${DISTDIR}/Libs -lZip

      Ran otool and the results are:

      @
      Bryans-MacBook-Pro:/ bryancairns$ otool -L /Users/bryancairns/Documents/Source/PluginService/Dist/AppTester
      /Users/bryancairns/Documents/Source/PluginService/Dist/AppTester:
      libZip.dylib (compatibility version 0.0.0, current version 0.0.0)
      /Users/bryancairns/Qt/5.3/clang_64/lib/QtXml.framework/Versions/5/QtXml (compatibility version 5.3.0, current version 5.3.1)
      /Users/bryancairns/Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.1)
      /Users/bryancairns/Qt/5.3/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.3.0, current version 5.3.1)
      /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)

      @

      Almost looks like it is searching / for the lib?
      Help I am a bit confused as to what i am doing wrong :)

      Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

      Languages: C++, C#, VB, Python, Java

      1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        There may be dependency for libZip.dylib and they may not exist in your box. Check them. Since it says library is not loaded, I don't suspect the path issue. It may be just dependency issue.
        How are you running the program ? Are you running from QtCreator or outside the Qt Creator env ? From QtCreator it should work fine if everything is fine with library.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply Reply Quote 0
        • rootshell
          rootshell last edited by

          That's a very good point. I did fail to mention the libZip.dylib is simply a wrapper for ZLIB, which is compiled and placed in the same directory. I just assumed that setting QMAKE_RPATHDIR would set the search path for both of them.

          /Users/bryancairns/Documents/Source/PluginService/Dist/Libs/libZip.dylib
          /Users/bryancairns/Documents/Source/PluginService/Dist/Libs/libz.dylib

          So would I have to add the QMAKE_RPATHDIR in the libZip as well pointing to ZLIB?

          or would it just be easier to include the Zip code directly in the application and avoid libraries all together?

          I am running the application from inside Qt Creator.

          Certifications: CISSP, MCITP, MCSE, MCSA, BA, AA, AG, CST, CNST, Linux+, Security+, Server+, Network+, A+, iNet+

          Languages: C++, C#, VB, Python, Java

          1 Reply Last reply Reply Quote 0
          • First post
            Last post