只包括SDL头导致链接器错误 [英] Simply including SDL header causes linker error
问题描述
我要将我的游戏从glut迁移到sdl。
I was going to migrate my game from glut to sdl.
它完全在glut中工作,但我想使用一些sdl功能。
It's working perfectly in glut but I wanted to use some sdl features.
所以我进入我的项目属性,在目标头下我点击将编译的程序,构建阶段,链接二进制库和库,添加SDL.framework
So I go into my project properties, under the targets header I click the program that will be compiled, build phases, link binary with libraries, add SDL.framework
与我为OpenGL.framework和GLUT.framework做的完全相同
The exact same as I have done for OpenGL.framework and GLUT.framework
但是当我添加: #include < SDL / SDL.h>
在我尝试生成时出现链接器错误:
However when I add: #include <SDL/SDL.h>
it comes up with a linker error when I try to build:
Undefined symbols for architecture x86_64:
"_main", referenced from:
__start in crt1.o
(maybe you meant: _SDL_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$
推荐答案
SDL使用一个宏重命名 main(..)
,并且应该提供自己的,通常在 SDLmain.m
中实现。它应与SDL.framework一起提供。
SDL uses a macro to rename your main(..)
and should supply its own, usually implemented in SDLmain.m
. It should be supplied together with the SDL.framework.
从此处下载框架时 http ://www.libsdl.org/download-1.2.php 阅读 devel-lite $中的
ReadMeDevLite.txt
c $ c>文件夹。
When you download the framework from here http://www.libsdl.org/download-1.2.php Read the ReadMeDevLite.txt
in the devel-lite
folder.
另一个描述
http://www.meandmark.com/sdlopenglpart2.html
这篇关于只包括SDL头导致链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!