Ask a questionAsk a question
 

Answerlinker errors in VS 2005 (C++)

  • Sunday, November 13, 2005 6:56 AMtstubb Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I fixed the "cant find windows.h" problem and now I am getting linker erros like those below, after using the Windows App wizard to create code and compile it with no changes, can anyone help?

    Linking...

    test4.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageW@4 referenced in function _wWinMain@16

    test4.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function _wWinMain@16

    test4.obj : error LNK2019: unresolved external symbol __imp__TranslateAcceleratorW@12 referenced in function _wWinMain@16

    test4.obj : error LNK2019: unresolved external symbol __imp__GetMessageW@16 referenced in function _wWinMain@16

    test4.obj : error LNK2019: unresolved external symbol __imp__LoadAcceleratorsW@8 referenced in function _wWinMain@16

    test4.obj : error LNK2019: unresolved external symbol __imp__LoadStringW@16 referenced in function _wWinMain@16

    test4.obj : error LNK2019: unresolved external symbol __imp__RegisterClassExW@4 referenced in function "unsigned short __cdecl MyRegisterClass(struct HINSTANCE__ *)" (?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__LoadCursorW@8 referenced in function "unsigned short __cdecl MyRegisterClass(struct HINSTANCE__ *)" (?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__LoadIconW@8 referenced in function "unsigned short __cdecl MyRegisterClass(struct HINSTANCE__ *)" (?MyRegisterClass@@YAGPAUHINSTANCE__@@@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__UpdateWindow@4 referenced in function "int __cdecl InitInstance(struct HINSTANCE__ *,int)" (?InitInstance@@YAHPAUHINSTANCE__@@H@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__ShowWindow@8 referenced in function "int __cdecl InitInstance(struct HINSTANCE__ *,int)" (?InitInstance@@YAHPAUHINSTANCE__@@H@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExW@48 referenced in function "int __cdecl InitInstance(struct HINSTANCE__ *,int)" (?InitInstance@@YAHPAUHINSTANCE__@@H@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__EndPaint@8 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__BeginPaint@8 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcW@16 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__DestroyWindow@4 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__DialogBoxParamW@20 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)

    test4.obj : error LNK2019: unresolved external symbol __imp__EndDialog@8 referenced in function "int __stdcall About(struct HWND__ *,unsigned int,unsigned int,long)" (?About@@YGHPAUHWND__@@IIJ@Z)

Answers

  • Thursday, November 17, 2005 2:01 PMMohamed Eldawy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,
     I had the same problem at first, but luckily I could solve it. The problem is that the default installation of VS 8 express doesn't support the Platform SDK, so, after installing the platform SDK, you need to make a few modifications...

    1. Update the corewin_express.vsprops file (NOT the corewin.vsprops file).
    You need to change this...

    AdditionalDependencies="kernel32.lib"

    to this

    AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"

    2. Enable Win32 application creation
    Change the file AppSettings.htm found at
    “%ProgramFiles%\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\html\1033\"

    comment lines 441-> 444
    // WIN_APP.disabled = true;
    // WIN_APP_LABEL.disabled = true;
    // DLL_APP.disabled = true;
    // DLL_APP_LABEL.disabled = true;

    Now, everything should be fine (when you need to create a new win32 project, choose a win32 console application, and in the advancded settings choose win32 application)

    This information was found in MSDN. You can find the full article here...
    http://lab.msdn.microsoft.com/express/visualc/usingpsdk/default.aspx

All Replies

  • Sunday, November 13, 2005 7:16 AMAyman Shoukry - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You are probably missing a library that you need to link to (user32.dll). The PSDK folks should be able to help.

    Thanks,
      Ayman Shoukry
      VC++ Team
  • Sunday, November 13, 2005 5:47 PMtstubb Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Should that lib be in a specific directory, I did a search and it is located in WINDOWS/System32? Is there a newer version of the file possibly? VS 6 compiles the same code just fine.

  • Tuesday, November 15, 2005 3:12 PMtstubb Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Are any PSDK guys out there...Sad
    This problem is holding up my project and is getting very frustrating?

    Thanks
  • Wednesday, November 16, 2005 5:57 PMMartin RichterMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Did you installed a Platform SDK?
    What Visual Studio do you use? Th express version does not include the Platform SDK!
  • Thursday, November 17, 2005 4:07 AMtstubb Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I followed the instructions on MSDN for installing the PSDK. I have VS 8 express. The instructions said I could install the PSDK and change some setting and WIN 32 apps could be built, currently I can not build them and I get linker errors.

    Is it not true that WIN 32 apps work with the PSDK as stated on teh web page?

    Thanks
  • Thursday, November 17, 2005 2:01 PMMohamed Eldawy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,
     I had the same problem at first, but luckily I could solve it. The problem is that the default installation of VS 8 express doesn't support the Platform SDK, so, after installing the platform SDK, you need to make a few modifications...

    1. Update the corewin_express.vsprops file (NOT the corewin.vsprops file).
    You need to change this...

    AdditionalDependencies="kernel32.lib"

    to this

    AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"

    2. Enable Win32 application creation
    Change the file AppSettings.htm found at
    “%ProgramFiles%\Microsoft Visual Studio 8\VC\VCWizards\AppWiz\Generic\Application\html\1033\"

    comment lines 441-> 444
    // WIN_APP.disabled = true;
    // WIN_APP_LABEL.disabled = true;
    // DLL_APP.disabled = true;
    // DLL_APP_LABEL.disabled = true;

    Now, everything should be fine (when you need to create a new win32 project, choose a win32 console application, and in the advancded settings choose win32 application)

    This information was found in MSDN. You can find the full article here...
    http://lab.msdn.microsoft.com/express/visualc/usingpsdk/default.aspx

  • Friday, November 18, 2005 2:20 AMtstubb Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks a lot, my problem was the

    wrong corewin file, the MSDN post I read said the corewin.vsprops file was the one to change.
  • Thursday, November 24, 2005 6:29 AMNeuronz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I am getting the same linker errors even though I have made the required changes.
    The difference is that after using the wizard to build a Debug test app I modified the project properties to use MFC in a shared DLL as follows:

    Project > Test properties > Configuration properties > General > Use of MFC > Use MFC in a shared DLL

    (Note that before changing the above setting the project built without a problem.)

     

  • Monday, May 01, 2006 7:35 AMjmunro Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I just added the .lib files to the project properties linker command line additional: and recompiled my win32 app. It compiles now that I have the additional libs added where before it would not compile under vc8
  • Friday, May 12, 2006 4:22 AMmarca Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Bingo! That's it, it worked fine for me,  Thanks.

    Marc

  • Saturday, June 10, 2006 4:19 AMdougnoel Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     Neuronz wrote:

    Project > Test properties > Configuration properties > General > Use of MFC > Use MFC in a shared DLL


    I was having the following LNK2019 error in a project I was upgrading from Visual Studio 6:

    NWNXSCORCO.obj : error LNK2019: unresolved external symbol __imp__StringFromGUID2@12 referenced in function "protected: void __thiscall CNWNXSCORCO::GenUUID(char *)" (?GenUUID@CNWNXSCORCO@@IAEXPAD@Z)
    NWNXSCORCO.obj : error LNK2019: unresolved external symbol __imp__CoCreateGuid@4 referenced in function "protected: void __thiscall CNWNXSCORCO::GenUUID(char *)" (?GenUUID@CNWNXSCORCO@@IAEXPAD@Z)

    I have spent hours trying to figure out the problem today.  I saw your post and tried it.  It didn't work for me, but then I noticed the option below that said 'Use of ATL' and it was set to 'Not using ATL'.  I changed this to 'Dynamic Link to ATL', and voila!

    Project -> [Proj Name] Properties -> Configuration properties -> General -> Use of ATL -> Dynamic Link to ATL

    This solved my LNK2019 linking problems!

    Thanks,
    Doug
  • Thursday, June 15, 2006 11:27 PMJack_Bauer_24 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    This post saved me i spent hours looking for a solution until i read this and realised i'd altered the wrong file thanks - brilliant :)
  • Sunday, September 17, 2006 8:38 AMGuillaume J_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It solved my problems too.
    I'll make something to automate this task.
  • Monday, April 30, 2007 8:48 PMscheppsr77 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, the MS tech page had me edit the wrong file.  I guess most of us did.  But thanks, this fixed my problem.
  • Thursday, May 03, 2007 7:17 PMnicolas.ej Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I had the same linker problem and solved it.

     

    Now, I got this when building the solution

    (yes I followed all the steps of http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/. Using Vista OS and installed PSDK for Vista). The same solution works in VS 6.

     

    1>------ Build started: Project: MasterGoal, Configuration: Debug Win32 ------

    1>Compiling...

    1>icl.cpp

    1>Compiling UNICODE version

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(101) : warning C4996: 'ultoa' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(824) : see declaration of 'ultoa'

    1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _ultoa. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(124) : warning C4996: 'itoa' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(820) : see declaration of 'itoa'

    1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(147) : warning C4996: 'ultoa' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(824) : see declaration of 'ultoa'

    1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _ultoa. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(182) : warning C4996: '_ultow' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(884) : see declaration of '_ultow'

    1> Message: 'This function or variable may be unsafe. Consider using _ultow_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(198) : warning C4996: '_itow' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(878) : see declaration of '_itow'

    1> Message: 'This function or variable may be unsafe. Consider using _itow_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(214) : warning C4996: '_ultow' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(884) : see declaration of '_ultow'

    1> Message: 'This function or variable may be unsafe. Consider using _ultow_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

    1>Compiling...

    1>icl_win.cpp

    1>Compiling UNICODE version

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(101) : warning C4996: 'ultoa' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(824) : see declaration of 'ultoa'

    1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _ultoa. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(124) : warning C4996: 'itoa' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(820) : see declaration of 'itoa'

    1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(147) : warning C4996: 'ultoa' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(824) : see declaration of 'ultoa'

    1> Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _ultoa. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(182) : warning C4996: '_ultow' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(884) : see declaration of '_ultow'

    1> Message: 'This function or variable may be unsafe. Consider using _ultow_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(198) : warning C4996: '_itow' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(878) : see declaration of '_itow'

    1> Message: 'This function or variable may be unsafe. Consider using _itow_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

    1>d:\documentos\proyectos\mastergoal\framework\mastergoal-solution\src\icl_lib\icl_string.h(214) : warning C4996: '_ultow' was declared deprecated

    1> C:\Program Files\Microsoft Visual Studio 8\VC\include\wchar.h(884) : see declaration of '_ultow'

    1> Message: 'This function or variable may be unsafe. Consider using _ultow_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online help for details.'

    1>..\icl_lib\win\icl_win.cpp(189) : error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'ATOM [2]' to 'LPCWSTR'

    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    1>Build log was saved at "file://d:\Documentos\Proyectos\Mastergoal\Framework\mastergoal-solution\tmp\mastergoal.d\BuildLog.htm"

    1>MasterGoal - 1 error(s), 12 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

     

     

    Any ideas? Thanks and regards.
  • Thursday, May 03, 2007 7:41 PMnicolas.ej Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I solved the warning issue, now I get only this error:

     

    1>------ Build started: Project: MasterGoal, Configuration: Debug Win32 ------

    1>Compiling...

    1>icl_win.cpp

    1>Compiling UNICODE version

    1>..\icl_lib\win\icl_win.cpp(189) : error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'ATOM [2]' to 'LPCWSTR'

    1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    1>Build log was saved at "file://d:\Documentos\Proyectos\Mastergoal\Framework\mastergoal-solution\tmp\mastergoal.d\BuildLog.htm"

    1>MasterGoal - 1 error(s), 0 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========