Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Osx weak link framework/dylib



  • Is it possible to weak link an osx framework as well as a dylib using QtCreator and if so, how?

    Thanks!



  • [Moved to the tools forum]

    That has nothing to do with Qt Creator, it just calls regular make + makefiles. Just add the weak linked libraries to the LIBS variable:

    @
    LIBS += -weak_framework <framework_name>
    @

    PS: for weak linking of a library use

    @
    LIBS += -weak_library <library name>
    @

    See "Apple's documentation":http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html for details.



  • Thanks. I was just about to post my findings and found your answer. :)

    After diving into this I would have asked a different question of how to lazy load a shared library. I want strict linking on the symbols but to load the library only when needed. Also I apologize for not looking at the ld man page before asking this question (didn't occur to me); maybe it will save someone down the road some time. :)

    With that said, for those interested this is how to lazy load a shared library on osx:

    @-L../mylib/dir/ -lazy-lmylib@

    Thanks again!


Log in to reply