Static qt question



  • hi everybody
    i have one question. doest exist macro that tell me my qt library is static or dynamic ?
    tnx so much



  • Such a macro cannot exist. Macros will be evaluated during the preprocessor step. It is not interesting for the preprocessor what happens later on. Also the compiler is not interested in that. The first one is the linker but then it is too late for macros.

    What for do you need the information. If it is statically linked your application itself will take care of using the already loaded functions. If dynamically linked the application is still in charge but is asks the OS where to search for the dll's/so's. If they are not there it won't work of course.


  • Moderators

    This sort of thing is usually handled by a define passed to a compiler in the build system. I don't think Qt has something out of the box, but you can add it yourself.



  • Well if you only need it for Windows, you could check for the presence of Qt's DLLs:
    @
    #include "windows.h"
    bool bStaticBuild = (!::GetModuleHandle(L"Qt5Core")) && (!::GetModuleHandle(L"Qt5Cored"));
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.