LINK error: LNK2001: unresolved external symbol

shri1609
05-04-2010, 11:20 PM
hi ,

i am using MSDN library functions in my c file. I want to create a GUI using some of the following functions like
CreateWindowEx
ShowWindow
AdjustWindowRect
LoadCursor
SetWindowPos
CreatePen
TextOut
LineTo
MoveToEx etc....

but whn i build the project i'm getting link error while creating .obj file for all of the functions which ever i'm using.
the errors are like:

error LNK2001: unresolved external symbol __imp__GetMessageA@16
win.obj : error LNK2001: unresolved external symbol __imp__SetTimer@16
win.obj : error LNK2001: unresolved external symbol __imp__UpdateWindow@4
win.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8
win.obj : error LNK2001: unresolved external symbol __imp__SetWindowPos@28
like this fr all of the functions which are used...




if anyone cm across these type of problems plz help...

Qua
05-04-2010, 11:53 PM
This is due to the fact that you have properly referenced the header file for the windows functions. Have you included windows.h in your application?
#include <Windows.h>
It can be difficult to interpret the error messages of the c/c++ compilers when you're not used to them. Error "LNK2001: 'unresolved external symbol blablablabla'" is thrown when you're not properly referencing/including files throughout your project. There are two common reasons for this error

Either you didn't include the header file wherein the function resides;
or you haven't configured the project to look in the correct folder for the files to include

Verify that you have succesfully covered both of the above issues.

shri1609
05-05-2010, 12:00 AM
thanks for tat advice ....
i've included Windows.h header.
but still its the same error.

Qua
05-05-2010, 12:52 AM
If you do not have the windows.h header file, then install the Platform SDK (http://msdn.microsoft.com/en-us/windows/bb980924.aspx) for windows. With it comes the most common header files and compilers. Including "windows.h".

shri1609
05-05-2010, 01:03 AM
i have windows.h header file and i already included that one in my program...
ans still i am getting those above errors...

blork98
05-31-2010, 10:29 PM
Hi,

Don't know if you already solved ur problem but here are a couple of ways to solve it assuming u r using Visual Studio.

1. Did you add the directory where windows.h is located?

a.Go to solution explorer, right click on the project, select properties
b.Click on C/C++ then click on additional Include Directories then select edit
c. add the directory where windows.h is located, should be on the directory
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include
d. make sure you have the windows SDK but it should come free w/ Visual Studio or VC++ express anyway

2.Did you add the directory where the windows lib files are located?

a.Go to solution explorer, right click on the project, select properties
b.Click on Linker then click on Additional Library Directories then select edit
c.add the directory where the lib files are located, should be on
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib

hope this helps

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum