PDA

View Full Version : can't link with user32.lib VS.net 2003


Kilka
12-27-2004, 01:58 PM
Hey all,

I'm stuck here with a problem that should be simple. CL/LINK can't seem to link anything to user32.lib. There are no problems compiling with the /c option....

Here is the error:
error LNK2019: unresolved external symbol

my makefile looks like this:
syshooks:
cl $(CFLAGS) /c syshooks.cpp
cl syshooks.obj

where CFLAGS = /I. /Ox /DWIN32 /DLTN_SRC /W3 /GX

I'm running this makefile with "nmake -f makefile.msvc syshooks" from the command line. I've checked the shell to make sure that the lib env variable is being set properly, and it is:

echo %lib%
c:\Program Files\Microsoft Visual Studio .NET 2003\VC7\ATLMFC\LIB;c:\Program Fil
es\Microsoft Visual Studio .NET 2003\VC7\LIB;c:\Program Files\Microsoft Visual S
tudio .NET 2003\VC7\PlatformSDK\lib\prerelease;c:\Program Files\Microsoft Visual
Studio .NET 2003\VC7\PlatformSDK\lib;c:\Program Files\Microsoft Visual Studio .
NET 2003\SDK\v1.1\lib;



User32.lib is found in the bolded path. It looks like the compiler can't find it for some reason. I've double checked that it exists, although I'm not sure what to do now. I'm getting desperate here, does anyone have any ideas ? The same code worked fine with visual C 6.0 and Borland, but not with this new version of cl.

Thanks,
-Kilka

Kilka
12-27-2004, 05:11 PM
nothing like adding my own reply.

I'm wondering if it would be possible to list all of the symbols in the lib file, maybe the're not included for some reason. Is that possible ?

-Kilka

Kilka
01-18-2005, 09:10 PM
I've made some slight progress in this department, but I am still stuck. I think it has something to do with the options that I'm passing to the linker and the compiler.


I'm finding that the following won't work
POC:
cl $(CFLAGS) POC.cpp


But that the following will work if I explicitly specify the lib

POC:
cl $(CFLAGS) /c POC.cpp (the /c just compiles but doesn't link)
link /DEFAULTLIB:user32.lib POC.obj

The code that I'm using to test this looks like. The three message functions in there are all found in windows.h which is in user32.lib.

#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
MSG message;
while (GetMessage(&message,NULL,0,0)) {
TranslateMessage( &message );
DispatchMessage( &message );
}
return 0;
}

Kilka
01-18-2005, 09:14 PM
Also, I can see the symbols in the lib that are not being resolved. I can dump the symbols with this link.

LibDump (http://www.softlookup.com/download.asp?ID=7534&RID=3461060&DID=4J58YURT)


Thanks,
Kilka

TheColonial
03-02-2005, 12:18 AM
I realise that I'm bumping an old thread, and I apologise if this is wrong, but I just wanted to make sure that Kilka had an answer to his problem.

From what I can see, you're building a Windows program, but using main() instead of WinMain(). When the linker spits the error out, what's the name of the symbol that it's failed to resolve?

Hope that helps.
OJ