November 2, 2011

mirswith mirswith
Lab Rat
125 posts

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!

2 replies

November 2, 2011

Volker Volker
Robot Herder
5428 posts

[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:

  1. LIBS += -weak_framework <framework_name>

PS: for weak linking of a library use

  1. LIBS += -weak_library <library name>

See Apple’s documentation [developer.apple.com] for details.

November 2, 2011

mirswith mirswith
Lab Rat
125 posts

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:

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

Thanks again!

 
  ‹‹ Determine QMAKESPEC      Qt Creator debugger in Ubuntu ››

You must log in to post a reply. Not a member yet? Register here!