[solved] *.obj files not found when using msvc

  • Hi,
    I am working on a project and I am trying to compile it with the Msvc 2010. It compiles perfectly when using the MinGw compiler, but due to compatibility reasons I have to use Msvc.
    When I am building the program all files compile, and the *.obj files are existing.
    But afterwards I get some errors like:

    @PrimaryEmotion.obj:-1: Fehler: LNK2001: Nicht aufgelöstes externes Symbol ""public: __thiscall AffectiveState::AffectiveState(class AffectiveState const &)" (??0AffectiveState@@QAE@ABV0@@Z)".@

    (unresolved symbols) and a hint, that (in this case noted above) the file PrimaryEmotion.obj was not found.
    I read in some forums that this might be an error which comes from the linker.
    I do not know if this is relevant, but the code compiles to a dll file.

    Any suggestions what I am doing wrong?


  • Lifetime Qt Champion


    Are you trying to build a MinGW Qt project with Visual Studio ? If so, it won't work, you have to get a matching Qt installed

  • No, the project is pure c++ without any dependencies. It was written with Qt-Creator but you should be able to compile all source files with any compiler.

  • Lifetime Qt Champion

    So are you using still using Qt Creator ? Did you setup the compiler and linker correctly ?

    And are you sure you are linking to your library correctly ?

  • Yes I am using Qt Creator with "Qt 5.2.0 MSVC2010 32bit OpenGL" and the "msvc 10 x86" compiler. I am pretty shure this is correct, because the compilation does not fail, but the linking.

    A am not linking agains any library outside of the project. The linking errors come from *.obj files which are not found, but are compiled from within the project.

    As I said the project compiles fine with MinGW so this might be a msvc issue. Any msvc specific stuff that I do not see in the documentation.

    For clearance here the complete compiler output.

    @01:16:22: Führe Schritte für Projekt WASABIEngine aus...
    01:16:22: Starte "C:\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\bin\qmake.exe" C:\Users\Mortl\Desktop\WASABIQtGui\WASABIEngine\WASABIEngine.pro -r -spec win32-msvc2010
    01:16:23: Der Prozess "C:\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\bin\qmake.exe" wurde normal beendet.
    01:16:23: Starte "C:\Qt\Qt5.2.0\Tools\QtCreator\bin\jom.exe"
    C:\Qt\Qt5.2.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release
    cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DWASABIENGINE_LIBRARY -DQT_NO_DEBUG -DQT_CORE_LIB -DNDEBUG -I"..........\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\include" -I"..........\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\include\QtCore" -I"release" -I"." -I"..........\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\Mortl\AppData\Local\Temp\WASABIRunner.obj.2992.15.jom
    Code wird generiert...
    cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DWASABIENGINE_LIBRARY -DQT_NO_DEBUG -DQT_CORE_LIB -DNDEBUG -I"..........\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\include" -I"..........\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\include\QtCore" -I"release" -I"." -I"..........\Qt\Qt5.2.0\5.2.0\msvc2010_opengl\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\Mortl\AppData\Local\Temp\EmotionConverter.obj.2992.15.jom
    Code wird generiert...
    link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:release\WASABIEngine.dll.embed.manifest /OUT:release\WASABIEngine.dll @C:\Users\Mortl\AppData\Local\Temp\WASABIEngine.dll.2992.7593.jom
    Bibliothek "release\WASABIEngine.lib" und Objekt "release\WASABIEngine.exp" werden erstellt.
    SecondaryEmotion.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall AffectiveState::AffectiveState(class AffectiveState const &)" (??0AffectiveState@@QAE@ABV0@@Z)" in Funktion ""public: __thiscall SecondaryEmotion::SecondaryEmotion(class SecondaryEmotion const &)" (??0SecondaryEmotion@@QAE@ABV0@@Z)".
    PrimaryEmotion.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: __thiscall AffectiveState::AffectiveState(class AffectiveState const &)" (??0AffectiveState@@QAE@ABV0@@Z)".
    EmotionContainer.obj : error LNK2001: Nicht aufgelöstes externes Symbol ""public: __thiscall AffectiveState::AffectiveState(class AffectiveState const &)" (??0AffectiveState@@QAE@ABV0@@Z)".
    release\WASABIEngine.dll : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
    jom: C:\Users\Mortl\Desktop\WASABIQtGui\build-WASABIEngine\Makefile.Release [release\WASABIEngine.dll] Error 1120
    jom: C:\Users\Mortl\Desktop\WASABIQtGui\build-WASABIEngine\Makefile [release] Error 2
    01:16:30: Der Prozess "C:\Qt\Qt5.2.0\Tools\QtCreator\bin\jom.exe" wurde mit dem Rückgabewert 2 beendet.
    Fehler beim Erstellen/Deployment des Projekts WASABIEngine(Kit: Desktop Qt 5.2.0 MSVC2010 32bit OpenGL)
    Bei der Ausführung von Schritt 'Make'
    01:16:30: Verstrichene Zeit: 00:08.@

  • Hi, Are you sure all your function call are spelled correctly?

    AffectiveState::AffectiveState -> EffectiveState::EffectiveState ?? spelling mistakes or just outdated objects are often the cause of this kind of thing.

    Try a clean all and a rebuild :-)

  • As I said, the project compiles fine with an other compiler (MinGW) so the problem can not be a spelling mistake.
    I always clean the project before building, somtimes by manually deleting the whole build directory.

  • I have found the solution:

    In the header file there is a copy constructor declared but in the source file not defined. MinGW does not care about that, but MSVC throws therse errors while linking.

  • Lifetime Qt Champion

    Indeed, gcc and msvc (also clang) have different sensitivities about such things (also e.g. order of initialization)

    Great you found and and thanks for sharing !
    Can you also update the thread title prepending [solved] ? So other forum users may know a solution has been found :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.