SDL导致未定义的符号:“

编程入门 行业动态 更新时间:2024-10-25 22:35:16
SDL导致未定义的符号:“_ main”,引自:crt1.10.5.o中的start(SDL causes Undefined symbols: “_main”, referenced from: start in crt1.10.5.o)

当我尝试在我的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 status

Here'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"

更多推荐

本文发布于:2023-07-29 20:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319532.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:符号   未定义   SDL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!