をリンクしません。私はこのような単純なのQtアプリケーションを作成してみました:はなぜ、このシンプルなQtアプリケーションは
main.cppに:
#include <QApplication>
class MyApp : public QApplication {
Q_OBJECT
public:
MyApp(int argc, char* argv[]);
};
MyApp::MyApp(int argc, char* argv[]) :
QApplication(argc,argv) {
}
int main(int argc, char* argv[]) {
MyApp app(argc,argv);
return app.exec();
}
しかし、私はQtのでそれをコンパイルしてリンクしようとしたがクリエーター2.3.1(Qtの4.7.4)私は3 "未解決の外部シンボル" エラーを取得:
-
main.obj:-1: error: LNK2001: unresolved external symbol
""public: virtual struct QMetaObject const * __thiscall MyApp::metaObject(void)const "
([email protected]@@[email protected]@XZ)". -
main.obj:-1: error: LNK2001: unresolved external symbol
""public: virtual void * __thiscall MyApp::qt_metacast(char const*)"
([email protected]@@[email protected])". -
main.obj:-1: error: LNK2001: unresolved external symbol
""public: virtual int __thiscall MyApp::qt_metacall(enum QMetaObject::Call,int,void * *)"
([email protected]@@[email protected]@@[email protected])".
I think they are somehow related to the MetaObjectCompiler of Qt, but I can't figure out a solution. I know it's not considered good programming style in c++ to put declarations and definitions in one file, but that's not the point here. In my opinion it should be possible since there is nothing syntactically wrong here.
'コンパイル'が 'リンク'に変更されました。これはコンパイラの問題ではありません。 – stijn