仅包含 SDL 标头会导致链接器错误 [英] Simply including SDL header causes linker error

查看:20
本文介绍了仅包含 SDL 标头会导致链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算将我的游戏从 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)

谷歌搜索只会导致很少的结果,但没有真正的解释.

Googling simply leads to a fair few results, but no real explanations.

推荐答案

SDL 使用宏来重命名您的 main(..) 并且应该提供它自己的,通常在 SDLmain 中实现.米.它应该与 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.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆