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.
'user32.lib' needs to be passed to the linker using the '/link' option :
1
cl -Zi ..\work\misc\win32_main.cpp /link User32.lib
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?
Add also kernel32.lib
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

Edited by Mārtiņš Možeiko 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.


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