2012-08-05 3 views
0

Visual Studio 2010에서 Qt를 사용하려고합니다. 디버거에서 실행할 수있는 작동 프로그램을 만들었습니다. 그러나 Q_OBJECT 매크로를 클래스에 추가하려고하면 링커 오류가 발생합니다.Qt Q_OBJECT가 Visual Studio 2010에서 링커 오류를 만듭니다.

1>------ Build started: Project: qt_poop, Configuration: Debug Win32 ------ 
1>Build started 2012/08/05 12:58:56. 
1>InitializeBuildStatus: 
1> Creating "Debug\qt_poop.unsuccessfulbuild" because "AlwaysCreate" was specified. 
1>ClCompile: 
1> GLViewer.cpp 
1> Window.cpp 
1> main.cpp 
1> Generating Code... 
1>Link: 
1> LINK : c:\Users\abral\Documents\Visual Studio 2010\Projects\qt_poop\Win32\Debug\\qt_poop.exe not found or not built by the last incremental link; performing full link 
1>GLViewer.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall GLViewer::metaObject(void)const " ([email protected]@@[email protected]@XZ) 
1>GLViewer.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall GLViewer::qt_metacast(char const *)" ([email protected]@@[email protected]) 
1>GLViewer.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall GLViewer::qt_metacall(enum QMetaObject::Call,int,void * *)" ([email protected]@@[email protected]@@[email protected]) 
1>c:\Users\abral\Documents\Visual Studio 2010\Projects\qt_poop\Win32\Debug\\qt_poop.exe : fatal error LNK1120: 3 unresolved externals 
1> 
1>Build FAILED. 
1> 
1>Time Elapsed 00:00:07.50 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

나는 다른 사람에 의해 제기 된 몇 가지 비슷한 문제를 본 적이 컴파일러와 MOC 내 초보자 뇌가 아직은 이해할 수없는 다른 정말 복잡한 기술적 인 물건의 무리와 함께 할 수있는 뭔가가 보인다. 또한, 그것의 많은 컴파일러를 구성하는 명령 줄을 사용하는 사람들을 대상으로하지만 VS를 사용하고 있습니다 그리고 난 정말 그런 식으로 유지하고 싶습니다 (기본적으로 난 그냥 녹색을 누르면 수 싶습니다 화살표와 나의 프로그램을 보아라 - that 's 누구나). 그래서 ... 누군가가 가능한 한 간단한 방법으로 Visual Studio를 구성하여 어떻게 연결하거나 컴파일해야 할지를 결정할 수 있다면, 나는 영원히 감사 할 것입니다.

+2

QT 작성자는 녹색 화살표가 있으며 QT로 코드를 작성하는 데 적합합니다. 그냥 ' –

+0

가능한 간단한 Qt "Hello World 컴파일!" Visual Studio 2010 Express 내 응용 프로그램?] (http://stackoverflow.com/questions/3031512/compiling-a-simple-qt-hello-world-application-within-visual-studio-2010-expre) – Mat

답변

0

Q_OBJECT를 클래스에 추가 한 다음 qmake을 실행했는지 확인하십시오. 나는 Creator와 함께 일 했었지만, Q_OBJECT 매크로를 사용하여 QObject를 확장하는 클래스를 포함하는 코드를 컴파일하기 전에, 그렇게하지 않았을 때 정말 이상한 오류가있었습니다.

관련 문제