Unresolved Externals with VC++ 2k5 Express
Hey guys, there was an old thread on this that I was unable to bump, so sorry to respost an old problem.
I am trying to compile lesson 31 from the NeHe tutorials so that I can mess with the code a bit and get more familiar with what is going on. I can get the code working no problem in VC++ 6.0, but I was hoping to play with the new VC++ 2005 Express and get more familiar with it.
This is basically the output that the compiler gives me:
wintest.obj : error LNK2019: unresolved external symbol __imp__UnregisterClassA@8 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)
wintest.obj : error LNK2019: unresolved external symbol __imp__DestroyWindow@4 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)
wintest.obj : error LNK2019: unresolved external symbol __imp__ReleaseDC@8 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)
wintest.obj : error LNK2019: unresolved external symbol __imp__MessageBoxA@16 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)
wintest.obj : error LNK2019: unresolved external symbol __imp__ShowCursor@4 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)
wintest.obj : error LNK2019: unresolved external symbol __imp__ChangeDisplaySettingsA@8 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)
wintest.obj : error LNK2019: unresolved external symbol __imp__SetFocus@4 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__SetForegroundWindow@4 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__ShowWindow@8 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__SetPixelFormat@12 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__ChoosePixelFormat@8 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__GetDC@4 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__AdjustWindowRectEx@16 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__RegisterClassA@4 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__LoadCursorA@8 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__LoadIconA@8 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)
wintest.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)
wintest.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)
wintest.obj : error LNK2019: unresolved external symbol __imp__SwapBuffers@4 referenced in function _WinMain@16
wintest.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function _WinMain@16
wintest.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function _WinMain@16
wintest.obj : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function _WinMain@16
Debug/wintest.exe : fatal error LNK1120: 23 unresolved externals
So basically a bunch of unresolved externals...
The solution I have read before was to make sure the following libraries are linked in: OpenGL32.lib GLu32.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.
I downloaded the Microsoft Platform SDK a few weeks ago. VC++ 2005 simply has me enter additional directories where it can find include files or libraries, so I have been linking the directories in the Platform SDK. All the libraries above are in those directories so should therefore be properly linked in.
I have heard that I potentially need to build a new win32 app in VC++ 2005 and simply cut and paste the code into the new project. Once I downloaded the lesson 31 code I simply let VC++ 2005 upgrade the project to the new version, so maybe that upgrade is causing the problems. It was a bit odd though, I only saw an option to create a win32 console application in the VC++ 2005 project creation window, and making a new console application and then pasting in all the lesson31 code did not work out so hot.
One other potential problem was that there was one library that the compiler complained about missing: libcmtd.lib. This library was not in my platform SDK libraries or my VC++ 2005 libraries, but it was in my old VC++ 6.0 directory, so I copied it into my platform SDK libraries. Perhaps this created some kind of problem.
Lastly, I also tried setting the compiler to use all my old includes and libraries from VC++ 6.0, but that creates a whole different set of unresolved externals.
I can always just use my old compiler, but I'm a bit frustrated that I can't get this working on the new compiler. Anyone have any experience with this or ideas on what else I might try?
Thanks a ton guys!
~Mark~
Hi,
Make sure the following are there in the linkers additional dependencies -
user32.lib gdi32.lib opengl32.lib glu32.lib
Also make sure that path to these librarired are set correctly as well. That is all I had to do to get rid of these errors.
Make sure the following are there in the linkers additional dependencies -
user32.lib gdi32.lib opengl32.lib glu32.lib
Also make sure that path to these librarired are set correctly as well. That is all I had to do to get rid of these errors.
The more applications I write, more I find out how less I know
That mostly did the trick. I completely missed the additional dependancies field. I thought by getting the library directory entered I was set. I am still getting the following unresolved externals though:
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _GetRegistrySysColors@8
The platform SDK's library directory has the glaux.lib library, so the directory is set fine. The code already had the "#pragma comment( lib, "glaux.lib" )" line when I downloaded it, so I'm not sure where to go from here.
I have the following libraries set in my additional dependancies:
opengl32.lib glu32.lib glaux.lib odbc32.lib odbccp32.lib user32.lib gdi32.lib
That list of .lib files I saw before also included winspool.lib and several others, but those don't seem to be in my library directories, so I was unable to see if adding any of those made a difference. Still, if you got it working with just the libraries you mentioned then I think I am doing something else wrong.
Thanks again for the help!
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _GetRegistrySysColors@8
glaux.lib(tk.obj) : error LNK2019: unresolved external symbol __imp__RegOpenKeyExA@20 referenced in function _GetRegistrySysColors@8
The platform SDK's library directory has the glaux.lib library, so the directory is set fine. The code already had the "#pragma comment( lib, "glaux.lib" )" line when I downloaded it, so I'm not sure where to go from here.
I have the following libraries set in my additional dependancies:
opengl32.lib glu32.lib glaux.lib odbc32.lib odbccp32.lib user32.lib gdi32.lib
That list of .lib files I saw before also included winspool.lib and several others, but those don't seem to be in my library directories, so I was unable to see if adding any of those made a difference. Still, if you got it working with just the libraries you mentioned then I think I am doing something else wrong.
Thanks again for the help!
~Mark~
A short google search yields Advapi32.lib as the missing library.
STLport | Lua | Squirrel | Doxygen | NASM | bochs | osdev | Ruby | FreeBSD | Zend Framework 2 | YUI 3 | VP UML| ZFS | Linux Mint (Cinnamon)
Hehe I had tried a few unsuccessful google searches, but you're right, if I paste in the entire first line of the output into google I get a foreign website, but I could make out the "link Advapi32.lib".
Thanks for the link as well, and all the help from everyone, its working great now :)
Thanks for the link as well, and all the help from everyone, its working great now :)
~Mark~
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement