Results 1 to 3 of 3

Thread: Linker error... What am i doing wrong?

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Linker error... What am i doing wrong?

    Hello,

    Back from my unsuccessful journey with MinGW-w64, i just installed a clean Windows XP virtual machine and Visual Studio 2008.
    I also have installed the latest Qt SDK with Qt Desktop 4.8.1 compiled for MSVC2008.
    In one of my project, i have platform-specific code to dynamically load a windows library (Via LoadLibrary(), GetProcAddress() and FreeLibrary()). So in my project file, i use:
    Qt Code:
    1. win32 {
    2. LIBS += -lws2_32 -luser32 -lkernel32
    3. }
    To copy to clipboard, switch view to plain text mode 
    However, the linker complains:
    Qt Code:
    1. SCLibrary.cpp
    2. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2565) : warning C4007: 'WinMain' : must be '__stdcall'
    3. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2578) : warning C4007: 'wWinMain' : must be '__stdcall'
    4. ..\..\PQRRS\SCLibrary\src\SCLibrary.cpp(22) : warning C4007: 'DllMain' : must be '__stdcall'
    5. ..\..\PQRRS\SCLibrary\src\SCLibrary.cpp(22) : warning C4100: 'lpvReserved' : unreferenced formal parameter
    6. CanonCR180Controller.cpp
    7. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2565) : warning C4007: 'WinMain' : must be '__stdcall'
    8. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2578) : warning C4007: 'wWinMain' : must be '__stdcall'
    9. moc_CanonCR180Controller.cpp
    10. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2565) : warning C4007: 'WinMain' : must be '__stdcall'
    11. C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2578) : warning C4007: 'wWinMain' : must be '__stdcall'
    12. Creating library ..\..\PQRRS\Debug\SCLibrary.lib and object ..\..\PQRRS\Debug\SCLibrary.exp
    13. CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__FreeLibrary referenced in function "public: virtual __thiscall SC::CanonCR180Controller::~CanonCR180Controller(void)" (??1CanonCR180Controller@SC@@UAE@XZ)
    14. CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__GetProcAddress referenced in function "public: virtual bool __thiscall SC::CanonCR180Controller::doInitialize(void)" (?doInitialize@CanonCR180Controller@SC@@UAE_NXZ)
    15. CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__GetLastError referenced in function "public: virtual bool __thiscall SC::CanonCR180Controller::doInitialize(void)" (?doInitialize@CanonCR180Controller@SC@@UAE_NXZ)
    16. CanonCR180Controller.obj : error LNK2019: unresolved external symbol __imp__LoadLibraryW referenced in function "public: virtual bool __thiscall SC::CanonCR180Controller::doInitialize(void)" (?doInitialize@CanonCR180Controller@SC@@UAE_NXZ)
    17. ..\..\PQRRS\Debug\SCLibrary.dll : fatal error LNK1120: 4 unresolved externals
    18. cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQt" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -Fodebug\ @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\SCLibrary.obj.1820.10.jom
    19. cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQt" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -Fodebug\ @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\CanonCR180Controller.obj.1820.1242.jom
    20. C:\QtSDK\Desktop\Qt\4.8.1\msvc2008\bin\moc.exe -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQt" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -D_MSC_VER=1500 -DWIN32 ..\..\PQRRS\SCLibrary\src\Controllers\CanonCR180Controller.h -o debug\moc_CanonCR180Controller.cpp
    21. cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -D_CRT_SECURE_NO_WARNINGS -DSCLib -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include" -I"..\..\PQRRS\RELibrary\include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\include\ActiveQt" -I"debug" -I"..\..\PQRRS\SCLibrary" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\mkspecs\win32-msvc2008" -Fodebug\ @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\moc_CanonCR180Controller.obj.1820.2303.jom
    22. link /LIBPATH:"c:\QtSDK\Desktop\Qt\4.8.1\msvc2008\lib" /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /DLL /MANIFEST /MANIFESTFILE:"debug\SCLibrary.intermediate.manifest" /OUT:..\..\PQRRS\Debug\SCLibrary.dll @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\SCLibrary.dll.1820.3245.jom
    23. C:\QtSDK\QtCreator\bin\jom.exe -f Makefile.Debug
    24. cd RELibrary\ && C:\QtSDK\QtCreator\bin\jom.exe -f Makefile
    25. cd SCLibrary\ && C:\QtSDK\QtCreator\bin\jom.exe -f Makefile
    26. jom: C:\Home\Documents\PQRRS\Debug\SCLibrary\Makefile.Debug [..\..\PQRRS\Debug\SCLibrary.dll] Error 1120
    27. jom: C:\Home\Documents\PQRRS\Debug\SCLibrary\Makefile [debug] Error 2
    28.  
    29. jom 1.0.8 - empower your cores
    30.  
    31. jom: C:\Home\Documents\PQRRS\Debug\Makefile [sub-SCLibrary-make_default-ordered] Error 2
    32. 22:06:11: The process "C:\QtSDK\QtCreator\bin\jom.exe" exited with code 2.
    33. Error while building project Recognition Suite (target: Desktop)
    34. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    Is there anyone with a clue of what i'm doing wrong please?

    Thanks,
    Pierre.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Linker error... What am i doing wrong?

    the unresolved symbols might be because of the prior warnings.

    looking here, they suggest some qmake compiler flags to try - HTH!
    http://qt-project.org/forums/viewthread/15938,
    You can add following line to your .pro file.
    QMAKE_CFLAGS += /Gz
    QMAKE_CXXFLAGS += /Gz
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. The following user says thank you to amleto for this useful post:

    hickscorp (22nd April 2012)

  4. #3
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Linker error... What am i doing wrong?

    Hello, and thank you for your answer,

    Something was very wrong with the order i was including windows.h and friends... i removed all includes, and eliminated every non-required one related to windows. Now everything works, and linking no longer display those messages.

    Thanks,
    Pierre.

Similar Threads

  1. Linker error with .obj
    By Wasabi in forum Newbie
    Replies: 0
    Last Post: 3rd August 2011, 16:49
  2. linker error when installing 4.7.1
    By ajax in forum Installation and Deployment
    Replies: 7
    Last Post: 23rd February 2011, 16:50
  3. Linker error
    By Tavit in forum Qt Programming
    Replies: 1
    Last Post: 14th July 2008, 14:30
  4. Linker error
    By alfblt16 in forum Qt Programming
    Replies: 2
    Last Post: 28th September 2006, 09:20
  5. Linker Error
    By ankurjain in forum Qt Programming
    Replies: 2
    Last Post: 5th April 2006, 05:45

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.