Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在QT中添加新源文件夹后的链接问题_C++_Qt_Clang - Fatal编程技术网

C++ 在QT中添加新源文件夹后的链接问题

C++ 在QT中添加新源文件夹后的链接问题,c++,qt,clang,C++,Qt,Clang,初学者提示:我无法找出以下链接错误的原因 我用CH2.CPP创建了一个简单的项目,它在QT中正确构建: #include <iostream> using namespace std; int main() { cout << "Hello World!" << endl; return 0; } 之后,我在构建项目时收到了这个错误。以下是编译输出: 08:10:01: Running steps for project CH2… 08:10:01: C

初学者提示:我无法找出以下链接错误的原因

我用CH2.CPP创建了一个简单的项目,它在QT中正确构建:

#include <iostream>

using namespace std;

int main()
{
cout << "Hello World!" << endl;
return 0;
}
之后,我在构建项目时收到了这个错误。以下是编译输出:

08:10:01: Running steps for project CH2…
08:10:01: Configuration unchanged, skipping qmake step.
08:10:01: Starting: "/usr/bin/make" 
/Users/vivekshumi/Qt5.2.0/5.2.0/clang_64/bin/qmake -spec macx-clang CONFIG+=x86_64 -o     Makefile ../CH2/CH2.pro
WARNING: Failure to find: ../CH2/src/*.h       
/Applications/Xcode.app/Contents/Developer/toolschains/XcodeDefault.xctoolschain/usr/bin/clang++-headerpad\u max\u install\u names-Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk-mmacosx version min=10.6-o CH2.app/Contents/MacOS/CH2.o console.o direction.o error.o filelib.o gevents.o ginteractors.o gmath.o gobjects.o gtimer.o gtypes.o gwindow.o hashmap.o lexicon.o main.o platform.o point.o random.o simpio sound.o sound.ostartup.o strlib.o tokenscanner.o-F/Users/vivekshumi/Qt5.2.0/5.2.0/clang_64/lib-framework-QtGui-framework-QtCore-framework-OpenGL-framework-AGL

从新源目录添加到此项目的Main.cpp内容:

int Main(int, char *[]) {
extern int Main();
return Main();
}
qmake输出:

23:14:09: Running steps for project CH2...
23:14:09: Starting: "/Users/vivekshumi/Qt5.2.0/5.2.0/clang_64/bin/qmake"     /Users/vivekshumi/Developer/CH2/CH2.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64  CONFIG+=declarative_debug CONFIG+=qml_debug
WARNING: Failure to find: ../CH2/src/*.h
23:14:09: The process "/Users/vivekshumi/Qt5.2.0/5.2.0/clang_64/bin/qmake" exited normally.
23:14:09: Elapsed time: 00:00.

链接错误是由于未将$$PWD/lib/CPPLib中的某些附加源文件作为CH2.CPP中的库包含在内而发生的。您在哪里定义
int Main()
?什么是
intmain(int,char*[])
?@JoachimPileborg我在CH2.cpp中定义了intmain()。我将Main.cpp源代码引入这个项目,其中包含int Main(int,char*[])。一般情况下,当
qmake
报告错误时,您不应该
make
。此外,qmake对文件全局绑定使用了不同的语法,您是否尝试了类似
头+=$$files(src/*.h)
?@fasked:qmake没有任何错误。我已经用qmake输出更新了bug。此外,我还尝试将头+=$$文件(src/*.h)添加到.pro文件中,但同样无效。@Vivek
警告:找不到:../CH2/src/*.h
是错误:)
int Main(int, char *[]) {
extern int Main();
return Main();
}
23:14:09: Running steps for project CH2...
23:14:09: Starting: "/Users/vivekshumi/Qt5.2.0/5.2.0/clang_64/bin/qmake"     /Users/vivekshumi/Developer/CH2/CH2.pro -r -spec macx-clang CONFIG+=debug CONFIG+=x86_64  CONFIG+=declarative_debug CONFIG+=qml_debug
WARNING: Failure to find: ../CH2/src/*.h
23:14:09: The process "/Users/vivekshumi/Qt5.2.0/5.2.0/clang_64/bin/qmake" exited normally.
23:14:09: Elapsed time: 00:00.