Handmade Network»Forums
2 posts
This newly registered member has not yet activated their account.
user32.lib isn't working
I should start off by saying I am using VS 2015,

I have a shell file in w:\work\misc
@echo off
mkdir ..\..\build
pushd ..\..\build
cl -Zi ..\work\misc\win32_main.cpp User32.lib
popd

but when I compile my code I get error link2019 unresolved external symbol imp_messagebox A.
Not sure what the problem is, when I compile from the ide itself without the command prompt my code works fine.
Dumitru Frunza
24 posts
Apprentice github.com/dfrunza/hoc
user32.lib isn't working
'user32.lib' needs to be passed to the linker using the '/link' option :
1
cl -Zi ..\work\misc\win32_main.cpp /link User32.lib
Mārtiņš Možeiko
2559 posts / 2 projects
user32.lib isn't working
dfrunza
'user32.lib' needs to be passed to the linker using the '/link' option :

That's not necessary. lib files passed to cl.exe will get automatically passed to link.exe even without "/link" argument.

@catsonmars: are you sure you are editing and calling same .bat file? Can you show full output from running .bat file (copy&paste it in [ code ] bbtags)
And are using same cl.exe as your IDE uses? Basically are you calling vcvarsall.bat from same folder as your IDE?
Alberto Vaudagna
12 posts
user32.lib isn't working
Add also kernel32.lib
Mārtiņš Možeiko
2559 posts / 2 projects
user32.lib isn't working
Edited by Mārtiņš Možeiko on
kernel32.lib is implicit. It is always linked to (because C/C++ startup code uses functions from it). No need to specify it unless you use /nodefaultlib
2 posts
This newly registered member has not yet activated their account.
user32.lib isn't working
Edited by catsonmars on
I have this as my shell.bat

@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
set path=w:\work\misc;%path%

If I go to Program Files (x86)\Microsoft Visual Studio 14.0\VC and type vcvarsall.bat the command prompt doesn't do anything. That is the only Visual studio folder that has the vcvarsall in it.

Mārtiņš Možeiko
2559 posts / 2 projects
user32.lib isn't working
Can you show output of "echo %LIB%" after you called your shell.bat?
How are you calling shell.bat and build.bat?