How do I that? I don't want to use the Visual Studio IDE, yet I want to use the provided compiler (cl.exe) and the Developer Command Prompt for VS2013.
我以前是通过命令行来做的
cl /EHsc /MD main.cpp /Fetest.exe /I F:\C++_Libraries\SDL2\SDL2-2.0.3\include /link /LIBPATH:F:\C++_Libraries\SDL2\SDL2-2.0.3\lib\x86 SDL2.lib SDL2main.lib /SUBSYSTEM:CONSOLE
cl.exe /Wall /Tc main.c
will generate a proper main.exe
.
and before that:
vcvarsall.bat
from your install directory of VC If you want to use a library (eg, SDL) you need to list the libraries with /link
option (library paths can be added with /LIBPATH
) and the library include directories with /I
option.
I faced this problem as well. I had to do two things to fix it:
/SUBSYSTEM:CONSOLE
as mentioned in previous answers. Note that this gives a different error along the lines of error LNK2019: unresolved external symbol __imp_CommandLineToArgvW referenced in function main_getcmdline
. This can be solved with doing the next step.Shell32.lib
as mentioned in the SDL forums: https://discourse.libsdl.org/t/windows-build-fails-with-missing-symbol-imp-commandlinetoargvw/27256/2So my final command line command looks like:
cl.exe /Zi /I "C:\...\SDL2-2.0.12\include" sdl_program.c /link "C:\...\lib\x64\SDL2main.lib" "C:\...\lib\x64\SDL2.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64\shell32.lib" /SUBSYSTEM:CONSOLE
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.