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. QtCreator - Compiling Issue - External source files
Forum Update on Monday, May 27th 2025

QtCreator - Compiling Issue - External source files

Scheduled Pinned Locked Moved Solved General and Desktop
c++11qtcreatormsvc2015
6 Posts 2 Posters 4.1k 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.
  • B Offline
    B Offline
    Blacktempel
    wrote on 8 Jul 2016, 23:09 last edited by
    #1

    I have a Qt project, accessing another cross-platform (boost) project on my disc. Adding the header includes does not seem to cause any problem.

    #include "../../Visual Studio 2015/Projects/..." //Header file down the road
    

    Adding existing source files to the sources folder in my Qt Project works also without a problem, the files are found and I can open them. But these source files are not compiled, as a linker error clearly states (IMO).

    LNK1104: cannot open file 'debug\Error.obj'
    

    Copying the content of (here Error.cpp) the source file in a new file in the Qt-Project directory and adding it solves the problem, though that would mean having to copy each time I pull the other project's changes with git or make changes myself. That misses the purpose of including external source files.

    I have already asked this question on stackoverflow without much luck. One suggestion was to create a ".pri" file and include this file in the Qt-project's ".pro" file. The best I got out of this was a change of the linker error from 1104 to 1181, both unable to open the ".obj" file.

    Has someone experienced this behaviour before or has a hint to a possible solution ?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 9 Jul 2016, 02:45 last edited by JKSH 7 Sept 2016, 02:52
      #2

      Hi @Blacktempel, and welcome to the Qt Dev Net!

      The correct way to link to external libraries is described at http://doc.qt.io/qt-5/third-party-libraries.html. In a nutshell, you should set the INCLUDEPATH and LIBS variables in your *.pro file.

      @Blacktempel said:

      #include "../../Visual Studio 2015/Projects/..." //Header file down the road

      After you set INCLUDEPATH, you don't need such a long #include line anymore.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Blacktempel
        wrote on 9 Jul 2016, 09:22 last edited by Blacktempel 7 Sept 2016, 09:30
        #3

        Hello @JKSH,

        thank you for your answer. This is no library, these are just external source files which have to be compiled together with my Qt-project. The boost headers and libs are already correctly included. Setting the INCLUDEPATH variable only changes the length of the header include and source file include in the *.pro file.
        Trying to set the correct path to the boost-directories root directory and adding the source files with a "short path" results in a failure to find the files at all, which is... a little strange but I was already there. (Paths are correct)
        If I use the "long" path, the files are found, but not compiled.

        INCLUDEPATH += //all other include paths \
                       "../../Visual Studio 2015/Projects/ProjectDir/"
        
        SOURCES += //all other sources \
                   Shared/Net/Error.cpp
        //or using 
                   ProjectDir/Net/Error.cpp
        

        results in "Failure to find: %filenameWithShortPath%".

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JKSH
          Moderators
          wrote on 9 Jul 2016, 13:23 last edited by
          #4

          Hi @Blacktempel,

          I see, I misread your original post.

          One suggestion was to create a ".pri" file and include this file in the Qt-project's ".pro" file. The best I got out of this was a change of the linker error from 1104 to 1181, both unable to open the ".obj" file.

          What happens if you try this solution again, after moving/copying the external source files to a path that does not contain any spaces?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          B 1 Reply Last reply 10 Jul 2016, 10:43
          1
          • J JKSH
            9 Jul 2016, 13:23

            Hi @Blacktempel,

            I see, I misread your original post.

            One suggestion was to create a ".pri" file and include this file in the Qt-project's ".pro" file. The best I got out of this was a change of the linker error from 1104 to 1181, both unable to open the ".obj" file.

            What happens if you try this solution again, after moving/copying the external source files to a path that does not contain any spaces?

            B Offline
            B Offline
            Blacktempel
            wrote on 10 Jul 2016, 10:43 last edited by
            #5

            Hi @JKSH,

            changing the include in the *.pro file to a path without spaces seemed to work, thank you.
            As test I copied the project to C:

            //This apparently works and source files are compiled.
            include(C:/ProjDir/ProjName.pri)
            //This works too, but the source files are not being compiled.
            include("../../Visual Studio 2015/Projects/ProjDir/ProjName.pri")
            

            Is that an existing bug in "include" ?
            Is there currently no way to include external source files where the path has space[s] in it ?

            J 1 Reply Last reply 11 Jul 2016, 10:44
            0
            • B Blacktempel
              10 Jul 2016, 10:43

              Hi @JKSH,

              changing the include in the *.pro file to a path without spaces seemed to work, thank you.
              As test I copied the project to C:

              //This apparently works and source files are compiled.
              include(C:/ProjDir/ProjName.pri)
              //This works too, but the source files are not being compiled.
              include("../../Visual Studio 2015/Projects/ProjDir/ProjName.pri")
              

              Is that an existing bug in "include" ?
              Is there currently no way to include external source files where the path has space[s] in it ?

              J Offline
              J Offline
              JKSH
              Moderators
              wrote on 11 Jul 2016, 10:44 last edited by
              #6

              @Blacktempel said:

              Is that an existing bug in "include" ?
              Is there currently no way to include external source files where the path has space[s] in it ?

              I'm not sure; I have never used the include() function with space-containing paths.

              You can ask the Qt engineers by subscribing to the Interest mailing list and posting there.

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              1

              1/6

              8 Jul 2016, 23:09

              • Login

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