错误日志如下:
生成日志 ------- 已启动生成: 项目: test,配置: Debug|Win32 -------
命令行 正在创建临时文件“c:\tmp\RSP000006.rsp”,其内容为
[
/O1 /I "C:\Qt\3.3.4\include" /I "." /I "C:\Qt\3.3.4\mkspecs\win32-msvc.net" /D "_WINDOWS" /D "UNICODE" /D "WIN32" /D "QT_DLL" /D "QT_THREAD_SUPPORT" /Gm /MD /Fo"Debug\\" /Fd".\\" /W3 /c /Zi /TP -Zm200 -w34100 -w34189
.\main.cpp
]
正在创建命令行“cl.exe @c:\tmp\RSP000006.rsp /nologo”
正在创建临时文件“c:\tmp\RSP000007.rsp”,其内容为
[
/OUT:"Debug\\test.exe" /NOLOGO /LIBPATH:"C:\Qt\3.3.4\lib" /DEBUG /SUBSYSTEM:WINDOWS qt-mt334.lib qtmain.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib imm32.lib winmm.lib wsock32.lib winspool.lib delayimp.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
.\Debug\main.obj
.\Debug\mydialog.obj
]
正在创建命令行“link.exe @c:\tmp\RSP000007.rsp”
输出窗口 正在编译...
main.cpp
正在链接...
mydialog.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall MyDialog::qt_property(int,int,class QVariant *)" (?qt_property@MyDialog@@UAE_NHHPAVQVariant@@@Z)
mydialog.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall MyDialog::qt_emit(int,struct QUObject *)" (?qt_emit@MyDialog@@UAE_NHPAUQUObject@@@Z)
mydialog.obj : error LNK2001: 无法解析的外部符号 "public: virtual bool __thiscall MyDialog::qt_invoke(int,struct QUObject *)" (?qt_invoke@MyDialog@@UAE_NHPAUQUObject@@@Z)
mydialog.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __thiscall MyDialog::qt_cast(char const *)" (?qt_cast@MyDialog@@UAEPAXPBD@Z)
mydialog.obj : error LNK2001: 无法解析的外部符号 "public: virtual char const * __thiscall MyDialog::className(void)const " (?className@MyDialog@@UBEPBDXZ)
mydialog.obj : error LNK2019: 无法解析的外部符号 "public: static class QMetaObject * __cdecl MyDialog::staticMetaObject(void)" (?staticMetaObject@MyDialog@@SAPAVQMetaObject@@XZ) ,该符号在函数 "public: virtual class QMetaObject * __thiscall MyDialog::metaObject(void)const " (?metaObject@MyDialog@@UBEPAVQMetaObject@@XZ) 中被引用
mydialog.obj : error LNK2019: 无法解析的外部符号 "public: static class QString __cdecl MyDialog::tr(char const *,char const *)" (?tr@MyDialog@@SA?AVQString@@PBD0@Z) ,该符号在函数 "protected: virtual void __thiscall MyDialog::languageChange(void)" (?languageChange@MyDialog@@MAEXXZ) 中被引用
Debug\\test.exe : fatal error LNK1120: 7 个无法解析的外部命令
结果 生成日志保存在“file://e:\vc\test\Debug\\BuildLog.htm”中
test - 8 错误,0 警告
环境变量如下:
系统变量
INCLUDE=%NET2003%\SDK\v1.1\include\;%NET2003%\Vc7\include\;%NET2003%\Vc7\PlatformSDK\include\;%NET2003%\Vc7\atlmfc\include\
Lib=%NET2003%\SDK\v1.1\Lib\
NET2003=C:\Program Files\Microsoft Visual Studio .NET 2003
Path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%NET2003%\Common7\IDE;%NET2003%\Bin;%NET2003%\Common7\Tools;%NET2003%\Common7\Tools\bin\prerelease;%NET2003%\Common7\Tools\bin;%NET2003%\SDK\v1.1\bin;%NET2003%\SDK\v1.1\v1.1.4322;%NET2003%\Vc7\bin
用户变量
PATH=d:\Qtwin\3.3.4\bin;D:\Qtwin\3.3.4\bin;C:\Qtwin\3.3.4\bin
用户变量 = def
INCLUDE=%NET2003%\SDK\v1.1\include\;%NET2003%\Vc7\include\;%NET2003%\Vc7\PlatformSDK\include\;%NET2003%\Vc7\atlmfc\include\;%NET2003%\vc7\include\
用户变量
Lib=%NET2003%\Vc7\PlatformSDK\Lib\;%NET2003%\Vc7\lib\;%NET2003%\Vc7\atlmfc\lib\;%NET2003%\SDK\v1.1\Lib\
几个文件的代码如下:
main.cpp
- #include <qapplication.h>
- #include "mydialog.h"
- int main( int argc, char ** argv )
- {
- QApplication a( argc, argv );
- MyDialog w;
- w.show();
- return a.exec();
- }
mydialog.cpp
- /****************************************************************************
- ** Form implementation generated from reading ui file 'mydialog.ui'
- **
- ** Created: 星期五 二月 22 20:52:02 2008
- ** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.4 edited Nov 24 2003 $)
- **
- ** WARNING! All changes made in this file will be lost!
- ****************************************************************************/
- #include "mydialog.h"
- #include <qvariant.h>
- #include <qpushbutton.h>
- #include <qradiobutton.h>
- #include <qlabel.h>
- #include <qcheckbox.h>
- #include <qlineedit.h>
- #include <qlayout.h>
- #include <qtooltip.h>
- #include <qwhatsthis.h>
- #include <qimage.h>
- #include <qpixmap.h>
- /*
- * Constructs a MyDialog as a child of 'parent', with the
- * name 'name' and widget flags set to 'f'.
- *
- * The dialog will by default be modeless, unless you set 'modal' to
- * TRUE to construct a modal dialog.
- */
- MyDialog::MyDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
- : QDialog( parent, name, modal, fl )
- {
- if ( !name )
- setName( "MyDialog" );
- setSizeGripEnabled( TRUE );
- QWidget* privateLayoutWidget = new QWidget( this, "layout4" );
- privateLayoutWidget->setGeometry( QRect( 80, 110, 365, 56 ) );
- layout4 = new QVBoxLayout( privateLayoutWidget, 11, 6, "layout4");
- layout2 = new QHBoxLayout( 0, 0, 6, "layout2");
- radioButton1 = new QRadioButton( privateLayoutWidget, "radioButton1" );
- layout2->addWidget( radioButton1 );
- textLabel1 = new QLabel( privateLayoutWidget, "textLabel1" );
- layout2->addWidget( textLabel1 );
- checkBox1 = new QCheckBox( privateLayoutWidget, "checkBox1" );
- layout2->addWidget( checkBox1 );
- lineEdit1 = new QLineEdit( privateLayoutWidget, "lineEdit1" );
- lineEdit1->setFrameShape( QLineEdit::LineEditPanel );
- lineEdit1->setFrameShadow( QLineEdit::Sunken );
- layout2->addWidget( lineEdit1 );
- layout4->addLayout( layout2 );
- Layout1 = new QHBoxLayout( 0, 0, 6, "Layout1");
- buttonHelp = new QPushButton( privateLayoutWidget, "buttonHelp" );
- buttonHelp->setAutoDefault( TRUE );
- Layout1->addWidget( buttonHelp );
- Horizontal_Spacing2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
- Layout1->addItem( Horizontal_Spacing2 );
- buttonOk = new QPushButton( privateLayoutWidget, "buttonOk" );
- buttonOk->setAutoDefault( TRUE );
- buttonOk->setDefault( TRUE );
- Layout1->addWidget( buttonOk );
- buttonCancel = new QPushButton( privateLayoutWidget, "buttonCancel" );
- buttonCancel->setAutoDefault( TRUE );
- Layout1->addWidget( buttonCancel );
- layout4->addLayout( Layout1 );
- languageChange();
- resize( QSize(511, 282).expandedTo(minimumSizeHint()) );
- clearWState( WState_Polished );
- // signals and slots connections
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
- }
- /*
- * Destroys the object and frees any allocated resources
- */
- MyDialog::~MyDialog()
- {
- // no need to delete child widgets, Qt does it all for us
- }
- /*
- * Sets the strings of the subwidgets using the current
- * language.
- */
- void MyDialog::languageChange()
- {
- setCaption( tr( "MyDialog" ) );
- radioButton1->setText( tr( "radioButton1" ) );
- textLabel1->setText( tr( "textLabel1" ) );
- checkBox1->setText( tr( "checkBox1" ) );
- buttonHelp->setText( tr( "&Help" ) );
- buttonHelp->setAccel( QKeySequence( tr( "F1" ) ) );
- buttonOk->setText( tr( "&OK" ) );
- buttonOk->setAccel( QKeySequence( QString::null ) );
- buttonCancel->setText( tr( "&Cancel" ) );
- buttonCancel->setAccel( QKeySequence( QString::null ) );
- }
mydialog.h
- /****************************************************************************
- ** Form interface generated from reading ui file 'mydialog.ui'
- **
- ** Created: 星期五 二月 22 19:26:36 2008
- ** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.4 edited Nov 24 2003 $)
- **
- ** WARNING! All changes made in this file will be lost!
- ****************************************************************************/
- #ifndef MYDIALOG_H
- #define MYDIALOG_H
- #include <qvariant.h>
- #include <qdialog.h>
- class QVBoxLayout;
- class QHBoxLayout;
- class QGridLayout;
- class QSpacerItem;
- class QRadioButton;
- class QLabel;
- class QCheckBox;
- class QLineEdit;
- class QPushButton;
- class MyDialog : public QDialog
- {
- Q_OBJECT
- public:
- MyDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
- ~MyDialog();
- QRadioButton* radioButton1;
- QLabel* textLabel1;
- QCheckBox* checkBox1;
- QLineEdit* lineEdit1;
- QPushButton* buttonHelp;
- QPushButton* buttonOk;
- QPushButton* buttonCancel;
- protected:
- QVBoxLayout* layout4;
- QHBoxLayout* layout2;
- QHBoxLayout* Layout1;
- QSpacerItem* Horizontal_Spacing2;
- protected slots:
- virtual void languageChange();
- };
- #endif // MYDIALOG_H