Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Paths/properties required when compiling with shared library
QtWS25 Last Chance

Paths/properties required when compiling with shared library

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 908 Views
  • 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.
  • X Offline
    X Offline
    x6herbius
    wrote on last edited by
    #1

    I have a subdirs project with two current sub-projects - my main application and a library.

    http://i.imgur.com/j0XlBTW.png

    On disk, I have both sub-projects together under the source directory, which get compiled into their respective folders in the build directory.

    http://i.imgur.com/MSQNtZq.png

    Application source is red, build is green; library source is purple, build is blue. The application .pro file resides in the app directory in the red square, and the library .pro file in the IConsole directory in the purple square.

    My library will be a shared library, so I gather that I'll have to link the application to its lib/header files on compile and place the library DLL into the application directory when I run it. However, I'm getting a bit confused with what I need to specify in the application pro file in order to compile correctly. I have compiled the library sub-project without issue, but at the moment Qt Creator suggests the library header files when I try and #include them in the application sub-project, even though I haven't added the INCLUDEPATHS entry yet, and the headers cannot be found when the application sub-project is compiled. I'm also not sure what to specify for the LIBS entry as I'm not sure whether the path needs to be relative to the source or build directory of the application.

    My application .pro file also contains the following:

    @if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
    mac:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)_debug
    win32:LIBS = $$member(LIBS, 0) $$member(LIBS, 1)d
    }@

    I'm wondering whether the "=" should be changed to "+=" so that it doesn't override the LIBS variable, but I'm not sure.

    Could anyone give me any pointers to how I should configure the .pro file? I need to know what directory the INCLUDEPATHS variable treats as the root direcrory (same for LIBS) and what format the LIBS parameters need to be in - I know -L is for folders and -l for the files, but do the folders need preceding "/" characters and do the libraries need the ".lib" extension?

    Thanks.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      INCLUDEPATH's root dir is the directory where your .pro file is located (if you are including it in a .pri file, it still will be based on the location of the .pro).

      For LIBS, you do indeed need to use "+=". It should also be relative to the .pro file (actual loading of the library during runtime is something the OS manages, Qt has no influence there. LIBS are only relevant to the linker, which will be looking for library object files).

      (Z(:^

      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