Error

Trying to compile SDL on MAC using XCode and C Language

While trying to compile my program, the following error occurs:

Undefined symbols for architecture x86_64: "_SDL_main", referenced from: -[SDLMain applicationDidFinishLaunching:] in SDLMain.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)


If your main program is called Main.cpp , try compiling it like this:

g++ Main.cpp -o main $(sdl2-config --cflags --libs)

and sdl2-config will generate all the correct compiler and linker flags you need for you.

If you are interested, you can see what it thinks the correct settings are with:

sdl2-config --cflags --libs

I get:

-I/usr/local/include/SDL2 -D_THREAD_SAFE -L/usr/local/lib -lSDL2
链接地址: http://www.djcxy.com/p/86346.html

上一篇: 链接器找不到C ++静态成员

下一篇: 错误