can't link with user32.lib VS.net 2003

7e00f748ca227fb60992c005b8cab119
0
Kilka 101 Dec 27, 2004 at 21:58

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

4 Replies

Please log in or register to post a reply.

7e00f748ca227fb60992c005b8cab119
0
Kilka 101 Dec 28, 2004 at 01:11

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

7e00f748ca227fb60992c005b8cab119
0
Kilka 101 Jan 19, 2005 at 05:10

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;
}
7e00f748ca227fb60992c005b8cab119
0
Kilka 101 Jan 19, 2005 at 05:14

Also, I can see the symbols in the lib that are not being resolved. I can dump the symbols with this link.

LibDump

Thanks,
Kilka

5e1d89e267ccbd40fed3dff8a3de9085
0
TheColonial 101 Mar 02, 2005 at 08:18

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