我该怎么做?我不想使用 Visual Studio IDE,但我想使用提供的编译器 (cl.exe) 和 VS2013 的开发人员命令提示符。
问问题
2360 次
3 回答
5
我以前是通过命令行来做的
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
于 2015-10-02T18:48:18.467 回答
2
cl.exe /Wall /Tc main.c
will generate a proper main.exe
.
and before that:
- ensure that c:\Windows\System32 is in the PATH
- execute
vcvarsall.bat
from your install directory of VC
If you want to use a library (e.g., 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.
于 2015-05-11T22:37:19.087 回答
2
我也遇到了这个问题。我必须做两件事来修复它:
- 添加
/SUBSYSTEM:CONSOLE
前面的答案中提到的。请注意,这会产生不同的错误error LNK2019: unresolved external symbol __imp_CommandLineToArgvW referenced in function main_getcmdline
。这可以通过执行下一步来解决。 - 链接
Shell32.lib
SDL 论坛中提到的:https ://discourse.libsdl.org/t/windows-build-fails-with-missing-symbol-imp-commandlinetoargvw/27256/2
所以我的最终命令行命令看起来像:
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
于 2020-08-06T15:25:21.580 回答