PDA

View Full Version : QT static with vs2005: error LNK2001: unresolved external symbol



ucomesdag
29th November 2006, 21:28
I give up googled the whole internet and beyond but no avail.

I rebuilded QT 4.2.1 static and that went cleanly. And when I try to recompile my project I keep geeting these errors. Please anyone I'm stuck deep.... Read something about moc'in the source but it seems to be done, so where's the error?


------ Build started: Project: GT-8 FX FloorBoard, Configuration: Debug Win32 ------
Compiling Qt resource file: .\application.qrc...
Moc'ing stompBox.h...
Moc'ing preferencesPages.h...
Moc'ing preferencesDialog.h...
Moc'ing mainWindow.h...

<snip>

XMLWriter.cpp
sysxWriter.cpp
sysxParser.cpp
stompBox.cpp
preferencesPages.cpp
preferencesDialog.cpp
Generating Code...
Compiling...

<snip>

Compiling resources...
Linking...
bankTreeList.obj : error LNK2001: unresolved external symbol "public: static struct QListData::Data QListData::shared_null" (?shared_null@QListData@@2UData@1@A)
sysxParser.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
sysxWriter.obj : error LNK2019: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A) referenced in function "public: class QString & __thiscall QString::insert(int,class QString const &)" (?insert@QString@@QAEAAV1@HABV1@@Z)
XMLWriter.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
namedArray.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
Preferences.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
preferencesPages.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
stompBox.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
floorPanelBarButton.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)
main.obj : error LNK2001: unresolved external symbol "private: static struct QString::Data QString::shared_null" (?shared_null@QString@@0UData@1@A)

<snip>

moc_stompBox.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_floorPanelBar.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_floorPanelBarButton.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_mainWindow.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_preferencesPages.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_customLed.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_dragBar.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_floorBoard.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_floorBoardDisplay.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
preferencesPages.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_bankTreeList.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_customButton.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
moc_customDial.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
stompBox.obj : error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)
sysxWriter.obj : error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)
qtmaind.lib(qtmain_win.obj) : error LNK2001: unresolved external symbol "private: static struct QByteArray::Data QByteArray::shared_null" (?shared_null@QByteArray@@0UData@1@A)
moc_preferencesDialog.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QDialog::staticMetaObject" (?staticMetaObject@QDialog@@2UQMetaObject@@B)
qtmaind.lib(qtmain_win.obj) : error LNK2001: unresolved external symbol "public: static enum QSysInfo::WinVersion const QSysInfo::WindowsVersion" (?WindowsVersion@QSysInfo@@2W4WinVersion@1@B)
G:\Visual Studio 2005\Projects\GT-8 FX FloorBoard\Debug\GT-8 FX FloorBoard.exe : fatal error LNK1120: 10 unresolved externals
Build log was saved at "file://g:\Visual Studio 2005\Projects\GT-8 FX FloorBoard\Debug\BuildLog.htm"
GT-8 FX FloorBoard - 54 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

wysota
29th November 2006, 22:07
Are you sure you linked with Qt libs? As it looks like you didn't...

ucomesdag
29th November 2006, 22:13
I didn't change nothing in my project and when I switch back to the non static build of QT and do a build clean it compiles fine.... When I check the properties they are all there linked...

I got two build of QT 4.2.1: 4.2.1 and 4.2.1-static

Part of the build log:

/OUT:"G:\Visual Studio 2005\Projects\GT-8 FX FloorBoard\Debug\GT-8 FX FloorBoard.exe" /LIBPATH:"C:\Qt\4.2.0-static\lib" /MANIFEST /MANIFESTFILE:"Debug\GT-8 FX FloorBoard.exe.intermediate.manifest" /DEBUG /PDB:"g:\Visual Studio 2005\Projects\GT-8 FX FloorBoard\Debug\GT-8 FX FloorBoard.pdb" /SUBSYSTEM:WINDOWS qtmaind.lib QtCored4.lib QtGuid4.lib QtXmld4.lib winmm.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


Edit: Tried compiling it at the command line and it compiles fine with the static QT???
But when I import the .pro file and create a new project I still get the error's...
So it must be some setting in Visual Studio. Anyone experience with compiling static in Visual Studio?

jpn
30th November 2006, 07:14
Edit: Tried compiling it at the command line and it compiles fine with the static QT???
But when I import the .pro file and create a new project I still get the error's...
So it must be some setting in Visual Studio. Anyone experience with compiling static in Visual Studio?
I usually 1) update the environment variables (PATH, QTDIR), 2) change to the appropriate build in VS (Tools->Options->Qt), 3) restart VS and then 3) re-open the solution from the .pro file. This all just to avoid complications when switching from Qt build to another.

ucomesdag
30th November 2006, 15:27
I usually 1) update the environment variables (PATH, QTDIR), 2) change to the appropriate build in VS (Tools->Options->Qt), 3) restart VS and then 3) re-open the solution from the .pro file. This all just to avoid complications when switching from Qt build to another.Did that but nothing still the same the QT libs are inclided but when linking he doesn't find them I guess didn't find anything on the net...I'm looking for more than 2 days now... :crying:

gfunk
30th November 2006, 19:08
/LIBPATH:"C:\Qt\4.2.0-static\lib"

This part looks somewhat suspicious. You said you built 4.2.1 right?

ucomesdag
30th November 2006, 20:00
This part looks somewhat suspicious. You said you built 4.2.1 right?

Oups your right 4.2.0 it is... :o

ucomesdag
2nd December 2006, 18:20
Nobody usin Vs2005 with a static build of qt?

gfunk
2nd December 2006, 18:57
So, are there really 4.2.1 libs in c:\qt\4.2.0-static\lib (instead of c:\qt\4.2.1-static\lib)? If not, then fix your paths, or put the libs in there.

ucomesdag
2nd December 2006, 22:16
So, are there really 4.2.1 libs in c:\qt\4.2.0-static\lib (instead of c:\qt\4.2.1-static\lib)? If not, then fix your paths, or put the libs in there.No you got me wrong I wrote 4.2.1 from the beginning of this thread but meant 4.2.0 and yes the libs are there... And stuff compiles fine from the command line... I just cant get it to work from vs2005 (I must be really dumb :eek: )...

raytmao
24th January 2007, 16:49
Yes this is looks like VS issue. What I did to fix it:

-created a new .pro file
-open new .vcproj file from .pro using QT Visual Studio integration

After these steps it works for me.

arunredi
16th May 2008, 02:29
Yes this is looks like VS issue. What I did to fix it:

-created a new .pro file
-open new .vcproj file from .pro using QT Visual Studio integration

After these steps it works for me.
Guys,

I just had a similar situation and spent almost a full day googling a searching thru the forms toVS 2005 situation. FInally I found the soultion in this thread. Thank you all.

Jasmine
22nd May 2008, 09:48
HI..I am a newbie.
I am having problem
"
Performing moc on MainWindow.h
Compiling...
main.cpp
MainWindow.cpp
moc_MainWindow.cpp
Generating Code...
Compiling manifest to resources...
Linking...
LINK : fatal error LNK1104: cannot open file 'qtmaind.lib'
"
I am using Qt4.4.0 open source with VS 2005 in Window.
I installed Library path and linker data.
Can anybody help me this problem?

Thanks in advance.

jpn
22nd May 2008, 10:39
Seems like you don't have debug version of Qt. So generate the project file in release mode:

qmake -tp vc -config release

Jasmine
22nd May 2008, 12:43
Hi.. Thanks for your answer.
I tried it out in release version

qmake -tp vc -config release

then.. I found error

WARNING: Unable to generate output for C:/Qt/4.4.0/Makefile.Release [TEMPLATE vcapp]
WARNING: Unable to generate output for C:/Qt/4.4.0/Makefile.Debug [TEMPLATE vcapp]


What should I install for right version?
Should I delete and reinstall everything?
Please kindly reply me.

jpn
22nd May 2008, 14:24
I meant to run that command in the project directory, not in Qt installation directory. That's the command to generate a Visual Studio project out of a qmake project file. That's how you created the Visual Studio project in the first place, right?

Jasmine
23rd May 2008, 10:12
Thanks a lot.


I meant to run that command in the project directory, not in Qt installation directory. That's the command to generate a Visual Studio project out of a qmake project file. That's how you created the Visual Studio project in the first place, right?

I reinstalled MinGw with following components,
* MinGW base tools
* G++ compiler
* MinGW make

then I changed the path and type in VC command prompt
1. qmake -project
2. qmake
3. make
It work out now.