Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] How to adding 3nd party library not to *.pro file, but to some general (compiler) setting?
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 3 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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 {
        include(mybuildsettings.pri)
        }
        @

        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.

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

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved