Adding external library into Qt Creator project

后端 未结 8 1947
广开言路
广开言路 2020-11-22 09:39

How can I add external library into a project built by Qt Creator RC1 (version 0.9.2)? For example, the win32 function EnumProcesses() requires Psapi.lib<

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 10:41

    I would like to add for the sake of completeness that you can also add just the LIBRARY PATH where it will look for a dependent library (which may not be directly referenced in your code but a library you use may need it).

    For comparison, this would correspond to what LIBPATH environment does but its kind of obscure in Qt Creator and not well documented.

    The way i came around this is following:

    LIBS += -L"$$_PRO_FILE_PWD_/Path_to_Psapi_lib/"
    

    Essentially if you don't provide the actual library name, it adds the path to where it will search dependent libraries. The difference in syntax is small but this is very useful to supply just the PATH where to look for dependent libraries. It sometime is just a pain to supply each path individual library where you know they are all in certain folder and Qt Creator will pick them up.

提交回复
热议问题