无法打开源文件,没有这样的文件或目录

时间:2019-04-12 20:34:06

标签: qt compiler-errors qmake

我有一个要在子目录结构中构建的项目。结构如下:

Project
  - Project.pro
  |
  Base
  |  -base.pro
  |  |
  |  Object
  |  |  -object.pro
  |  |  |
  |  |  Dependency1
  |  |  |  - depend1.cpp
  |  |  |  - depend1.hpp
  |  |  |
  |  |  Dependency2
  |  |     - depend2.cpp
  |  |     - depend2.hpp
  |  |
  |  GUI
  |  |  - gui.pro
  |  |  ...Folders and their source files
  |  |
  |  Other Folders
  |    - other .pro files
  |
  External
    |
    ExternalProj1
    |
    ExternalProj2

到目前为止,我只是在尝试编译Object的项目。但是,当我尝试对其进行编译时,它只会给我错误:

Cannot open source file: '..\..\..\Project\Base\Object\Dependency1\depend1.cpp' No such file or directory
Cannot open source file: '..\..\..\Project\Base\Object\Dependency2\depend2.cpp' No such file or directory

我已经尝试过搜索,但是与这种相关问题有关的大多数问题似乎都缺少头文件,这不是错误试图在此处传达的内容。我尝试对object.probase.proProject.pro进行各种修改,但是所有修改都失败了,我有点想从这里开始。 Project是子目录项目,BaseExternal也是子目录项目。我不是很确定我需要从这里修改什么才能使此错误消失。

这是我的base.pro

TEMPLATE = subdirs

    SUBDIRS += \
      Object \
      GUI \
      Others... 

object.pro看起来像这样:

TEMPLATE = lib
TARGET = Object

CONFIG += c++17

HEADERS += \
   $$PWD/Dependency1/depend1.hpp \
   $$PWD/Dependency2/depend2.hpp 

SOURCES += \
   $$PWD/Dependency1/depend1.cpp \
   $$PWD/Dependency2/depend2.cpp 

INCLUDEPATH += \
    $$PWD/Dependency1 \
    $$PWD/Dependency2 

Project.pro看起来与base.pro非常相似,只是它的子目录为BaseExternal。我究竟做错了什么?我希望现在能够弄清楚这一点,以便在尝试构建Base文件夹和External文件夹中的单个项目时可以对其进行修复。

编辑:因为需要编译输出:

c1xx: fatal error C1083: Cannot open source file: '..\..\..\Project\Base\Object\Dependency1\depend1.cpp': No such file or directory
depend1.cpp
c1xx: fatal error C1083: Cannot open source file: '..\..\..\Project\Base\Object\Dependency2\depend2.cpp': No such file or directory
jom: C:\Users\<USER>\Documents\Projects\build-Project-Desktop_Qt_5_12_1_MSVC2017_64bit-Debug\Base\Object\Makefile.Debug [debug\Dependency1.obj] Error 2
jom: C:\Users\<USER>\Documents\Projects\build-Project-Desktop_Qt_5_12_1_MSVC2017_64bit-Debug\Base\Object\Makefile.Debug [debug\Dependency2.obj] Error 2
c1xx: fatal error C1083: Cannot open source file: '..\..\..\Project\Base\Object\Dependency2\depend2.cpp': No such file or directory
jom: C:\Users\<USER>\Documents\Projects\build-Project-Desktop_Qt_5_12_1_MSVC2017_64bit-Debug\Base\Object\Makefile [debug] Error 2
09:59:10: The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project Project (kit: Desktop Qt 5.12.1 MSVC2017 64bit)
The kit Desktop Qt 5.12.1 MSVC2017 64bit has configuration issues which might be the root cause for this problem.
When executing step "Make"

0 个答案:

没有答案