我在windows下使用命令行编译
编译
-------在linux下
如果在程序中用到了SDL,SDL_image库进行编程时,那么在编译该文件时,需要加上:
`sdl-config --cflags --libs`
同时还要加载SDL_image库:-lSDL_image
g++ file.cpp `sdl-config --cflags --libs` -lSDL_image
-------------在windows下
编译时候必须把/ML改成/MD,用命令行编译必须加上/MD
还要加上/subsystem:"windows"
如:
cl sdltest.c SDL.lib SDLmain.lib /O2 /MD /link /subsystem:"windows"
如果遇到:fatal error LNK1104: cannot open file 'libc.lib'
加入/nodefaultlib:libc
如:cl agg_platform_support.cpp aa_demo.cpp agg_slider_ctrl.cpp SDL.lib SDLmain.lib agg.lib /O2 /MD -I".\include" /link /subsystem:"windows" /nodefaultlib:libc
另外如果想使用printf或者fprintf(stderr...这些东西,/subsystem:"windows"应该改为/subsystem:"CONSOLE" 这问题浪费了我很多时间,详见:
How can I get console output instead of stdout.txt and stderr.txt?
http://sdl.beuc.net/sdl.wiki/FAQ_Console
所有模块如SDL.lib SDLmain.lib 你的程序 都必须使用同一个编译参数 /MD或者/MT, 否则出现各种问题