handmade.network » Forums » user32.lib isn't working
catsonmars
2 posts
This newly registered member has not yet activated their account.
#13006 user32.lib isn't working
2 weeks, 6 days ago

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.
dfrunza
Dumitru Frunza
19 posts

Apprentice
github.com/dfrunza/hoc

#13007 user32.lib isn't working
2 weeks, 5 days ago

'user32.lib' needs to be passed to the linker using the '/link' option :
1
cl -Zi ..\work\misc\win32_main.cpp /link User32.lib

Programming is hard, let's go shopping!
mmozeiko
Mārtiņš Možeiko
1477 posts
1 project
#13009 user32.lib isn't working
2 weeks, 5 days ago

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?
albus95
Alberto Vaudagna
7 posts
#13018 user32.lib isn't working
2 weeks, 5 days ago

Add also kernel32.lib
mmozeiko
Mārtiņš Možeiko
1477 posts
1 project
#13020 user32.lib isn't working
2 weeks, 5 days ago Edited by Mārtiņš Možeiko on Sept. 4, 2017, 9:21 a.m.

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
catsonmars
2 posts
This newly registered member has not yet activated their account.
#13022 user32.lib isn't working
2 weeks, 5 days ago Edited by on Sept. 4, 2017, 10:27 a.m.

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.

mmozeiko
Mārtiņš Možeiko
1477 posts
1 project
#13023 user32.lib isn't working
2 weeks, 5 days ago

Can you show output of "echo %LIB%" after you called your shell.bat?
How are you calling shell.bat and build.bat?