Results 1 to 17 of 17

Thread: QT static with vs2005: error LNK2001: unresolved external symbol

  1. #1
    ucomesdag Guest

    Question QT static with vs2005: error LNK2001: unresolved external symbol

    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 ==========
    Last edited by jacek; 29th November 2006 at 21:52. Reason: changed [code] to [quote]

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Are you sure you linked with Qt libs? As it looks like you didn't...

  3. #3
    ucomesdag Guest

    Exclamation Re: QT static with vs2005: error LNK2001: unresolved external symbol

    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?
    Last edited by ucomesdag; 30th November 2006 at 00:24. Reason: updated contents

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Quote Originally Posted by ucomesdag View Post
    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.
    J-P Nurmi

  5. #5
    ucomesdag Guest

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    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...

  6. #6
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Quote Originally Posted by ucomesdag View Post
    /LIBPATH:"C:\Qt\4.2.0-static\lib"
    This part looks somewhat suspicious. You said you built 4.2.1 right?
    Software Engineer



  7. #7
    ucomesdag Guest

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Quote Originally Posted by gfunk View Post
    This part looks somewhat suspicious. You said you built 4.2.1 right?
    Oups your right 4.2.0 it is...

  8. #8
    ucomesdag Guest

    Exclamation Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Nobody usin Vs2005 with a static build of qt?

  9. #9
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    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.
    Software Engineer



  10. #10
    ucomesdag Guest

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Quote Originally Posted by gfunk View Post
    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 )...
    Last edited by ucomesdag; 2nd December 2006 at 22:24.

  11. #11
    Join Date
    Jan 2007
    Posts
    1
    Thanked 1 Time in 1 Post

    Thumbs up Re: QT static with vs2005: error LNK2001: unresolved external symbol

    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.

  12. The following user says thank you to raytmao for this useful post:

    arunredi (16th May 2008)

  13. #12
    Join Date
    Apr 2008
    Location
    California
    Posts
    25
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Quote Originally Posted by raytmao View Post
    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.
    - AR

  14. #13
    Join Date
    May 2008
    Posts
    3
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    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.

  15. #14
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Seems like you don't have debug version of Qt. So generate the project file in release mode:
    Qt Code:
    1. qmake -tp vc -config release
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  16. The following user says thank you to jpn for this useful post:

    Jasmine (22nd May 2008)

  17. #15
    Join Date
    May 2008
    Posts
    3
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    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.

  18. #16
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    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?
    J-P Nurmi

  19. The following user says thank you to jpn for this useful post:

    Jasmine (23rd May 2008)

  20. #17
    Join Date
    May 2008
    Posts
    3
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT static with vs2005: error LNK2001: unresolved external symbol

    Thanks a lot.

    Quote Originally Posted by jpn View Post
    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.

Similar Threads

  1. link error for visual studio.net 2003
    By berlin in forum Newbie
    Replies: 9
    Last Post: 29th September 2006, 16:06
  2. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  3. MS Visual Studio 6 Problems
    By dayrinni in forum Installation and Deployment
    Replies: 2
    Last Post: 23rd August 2006, 06:59
  4. Problems using DLL
    By larsli in forum Qt Programming
    Replies: 11
    Last Post: 15th July 2006, 10:18
  5. Unresolved External Symbol
    By munna in forum General Discussion
    Replies: 1
    Last Post: 10th May 2006, 19:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.