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. Adding Libraries Globally to QtCreator
Forum Updated to NodeBB v4.3 + New Features

Adding Libraries Globally to QtCreator

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
3 Posts 3 Posters 1.2k 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.
  • G Offline
    G Offline
    GinoMan2440
    wrote on last edited by
    #1

    Hey, I noticed that in Qt Creator - specifically on windows, but the same is true on every platform I've used it on - The standard libraries, and the windows sdk, and the open standard platform libs (openGL for example) are all referenced in the Qt Creator's editor's auto-complete feature. Specifically if you type...

    #include <v...
    

    it will suggest vector, and other headers from those three groupings that begin with "v*". Additionally after typing for example:

    vector<int> v;
    v.
    

    It will suggest all the methods for "vector" after the period and you can select one from the list.

    However for any other libraries, you have to add the library just to that specific project, instead of for example just being able to reference it by typing...

    #include <curl.h> // for example
    

    and if you're using cl.exe on windows and a static library, then you can also do...

    #pragma comment(lib, "curl.lib")
    

    and as long as "curl.lib" is in the lib path for the compiler, it will find and automatically import into the binary the static library.

    Question: How can I make the headers for the library globally available to Qt so that it suggests the headers and suggests the types and symbols of that header in their proper contexts like it does for the STL, OpenGL, and the Windows SDK as well as pass those headers to the compiler so that the compiler knows where they are?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tyras
      wrote on last edited by Tyras
      #2

      It is based on your Environment Variables INCLUDEPATH and LIB.

      All you need to do is to add the libraries include path (i.e. where its .h files are) and the libraries path (where the .lib (for MSVC) or .a (for minGW) files are) to these two variables and restart the QT Creator.

      When a coder says that it's impossible to do something, he's actually feeling too lazy to do it.

      1 Reply Last reply
      0
      • kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #3

        @GinoMan2440 said:

        However for any other libraries, you have to add the library just to that specific project, instead of for example just being able to reference it by typing...

        Your libraries (or more correctly headers) are not in system-wide recognized location.

        Question: How can I make the headers for the library globally available to Qt so that it suggests the headers and suggests the types and symbols of that header in their proper contexts like it does for the STL, OpenGL, and the Windows SDK as well as pass those headers to the compiler so that the compiler knows where they are?

        You can create a feature for qmake, where you add the paths to the headers and the binaries. You can use my repo where I've susbstituted the compilers as a template. The .prf file you copy in $QTDIR/mkspecs/features and you can use it with the CONFIG variable in your project, like this:

        CONFIG += my_cool_curl_feature
        

        Kind regards.

        Read and abide by the Qt Code of Conduct

        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