sdl編譯問題 sdl printf沒有輸出 sdl編譯錯誤

我在windows下使用命令行編譯


編譯

-------linux

 如果在程序中用到了SDLSDL_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, 否則出現各種問題



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章