当我尝试在我的c ++程序中使用SDL时,我得到以下内容:
> g++ minimal.cpp SDLMain.m Undefined symbols: "_main", referenced from: start in crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit status这是我的minimal.cpp:
#include <SDL/SDL.h> int main(int argc, char **argv) { return 0; }我可以从http://www.libsdl.org/faq.php?action=listentries&category=7收集到的是,通过包含SDL.h,它通过一些宏魔法重命名我的主要功能。 但是SDLMain.m应该通过调用重命名的函数再次使事情变得正确。 但不知怎的,这种情况没有发生?
我正在运行Leopard。
请注意,这是与问题550455不同的问题。
When I try to use SDL in my c++ program, I get the following:
> g++ minimal.cpp SDLMain.m Undefined symbols: "_main", referenced from: start in crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit statusHere's my minimal.cpp:
#include <SDL/SDL.h> int main(int argc, char **argv) { return 0; }What I could gather from http://www.libsdl.org/faq.php?action=listentries&category=7 was that by including SDL.h, it renames my main function through some macro magic. But then SDLMain.m is supposed to make things right again by calling that renamed function. But somehow that is not happening?
I'm running Leopard.
Note that this is a different issue from question 550455.
最满意答案
您还可以使用SDL sdl-config提供的工具:
gcc sdltest.c -o sdltest `sdl-config --cflags --libs`Solution was to use the SDLMain.m file included in SDL-devel-1.2.14-extras.dmg from the SDL homepage. For some reason the one I was using before had mysteriously stopped working. Here's my working compile command:
g++ -framework SDL -framework Cocoa -I/usr/local/include/SDL/ minimal.cpp "/Library/Application Support/Developer/Shared/Xcode/Project Templates/SDL Application/SDLMain.m"更多推荐
发布评论