Hi,
im trying to setup a cli environment for my win32 application, but im getting this wired error.
my folder structure looks like this:
1 2 3 4 5 6 7 8
|
project>
src>
mainer.cpp
build>
main.exe
tools>
build.bat
run.bat
|
my mainer.cpp looks like this:
1 2 3 4 5 6 7 8 9
|
#include <windows.h>
#include <cstdio>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
{
printf("test from winmain\n");
MessageBoxA(NULL,"test","test",MB_OK);
return 0;
}
|
and my build.bat looks like this:
1 2 3 4 5
|
@echo off
pushd ..\build\
cl ..\src\*.cpp /Fe"main.exe" /Zi user32.lib
popd
|
when i build and then run it from my console (by just typing "main.exe"), i see the message box, but it doesn't print anything to the console?
so i thought it was because i needed to change the subsystem to console, so i went back in to my build.bat and edited it.
it now looks like this:
1 2 3 4 5
|
@echo off
pushd ..\build\
cl ..\src\*.cpp /Fe"main.exe" /Zi user32.lib /link /SUBSYSTEM:CONSOLE
popd
|
problem is, when i try and build it now i get this wired error:
LIBCMT.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)
i would really appreciate it if someone could tell me what im doing wrong