Important: Please read the Qt Code of Conduct -

[SOLVED] How to adding 3nd party library not to *.pro file, but to some general (compiler) setting?

  • First, I would like to apologize for my English (not my native language).

    I would like to ask: is there any compiler setting or something, where I could add 3nd party library info (paths to includes and lib files) so I wouldn't need to do it in every single project (*.pro) file? I know how to do it in *.pro file, I know about INCLUDEPATH and LIBS and I can use them so my projects are compiled just fine. But I don't like them here, because it's environment specific info, not project one. (I'm talking about path settings, not about linking libraries.)

    Reason why I need it:

    • When I need to send the code to someone (or even release to public), at EVERY release, I need to remove INCLUDEPATH and LIBS from my *.pro file
    • I know I could put libraries into include and lib folders of qt, but I keep them in other directory (with simple management tool, which helps me a lot) and some libraries are installed to their specific folders.
    • And some others...

    And it would be nice (but not necessary) if I could also configure some other compilers settings.

    Similar options in other systems:

    • Visual C++ 2008 IDE: Tools -> Options -> Projects and Solutions -> VC++ Directories
    • Code::Blocks IDE: Settings -> Compiler and debugger... -> Global compiler settings -> Search directories

    My configuration:

    • Windows XP, SP3, 32 bit
    • Qt Creator 2.3.0 (based on Qt 4.7.4 32 bit)
    • Qt 4.7.3 - MSVC2008, MinGW 4.4

    I tried to search solution, so if it's there (on this forum, Goole), I'm sorry for my inability to find it.

  • u can do it directly without doing anything just rightclick on ur project and then say add new library, and then it will ask for external or internal , select the appropriate one (in ur case it is external) and then add the path of ur library and u are done.

    after this one thing u have to do, just run qmake and build on that library folder...
    abd then build ur project...

    i think this will do for u...

  • gcc examines the CPATH environment variable for include paths (like -I xxx) and LIBRARY_PATH for the library search paths (like -L).

    IMHO, a better solution than environment variables would be to use qmake project include files (usually named xxx.pri). You can put all platform and/or build specific stuff into that file and include it in your main .pro file. The inclusion can be at a specific scope if needed.


    this is in your main .pro file

    LIBS += -lmyLib

    UseMyBuildSettings {

    mybuildsettings.pri can contain anything that would normally go into a .pro file too.

    To enable your special build settings, just pass CONFIG+=UseMyBuildSettings the qmake call. In Qt Creator, just go to the project settings and add it to the addtional command line arguments.

    It has the nice advantage that it is platform/toolchain independent. In case you ever need to build your project with Visual Studio :)

  • First, I would like to apologize for putting this thread to wrong section.

    Thank you very much for advices.

    To shoyeb: I afraid, this does not solve the problem - if I do that, it will add paths to directories into *.pro file anyway, which is what I'm trying avoid.

    To Volker: environmental variables - I didn't thought about it, that would solve it universally for me :3. But only for mingw, but I also compile in VC (it's much, much faster). And second solution helps a lot too, it's much easier to remove one file when sending code instead of some lines in the other. So I used that, it's really good idea. (By the way, instead of config value, I simply used exists() command - for my purpose, existence of the file is enough to include it.)

    So, thank you very much again.

  • @ volker thanx for guiding us to the right way...
    thank u again.....

  • You're welcome. Glad it worked out for you. One can do quit tricky things with qmake. Looking at the project files of the Qt sources can be inspirational too.

Log in to reply