编译 C/C++在 OS X 中使用 SDL 的应用程序,链接问题

发布于 2024-11-24 02:51:03 字数 1316 浏览 2 评论 0原文

我正在尝试在 OS X 10.6.8 上编译一个使用 SDL 的 C/C++ 程序,但在链接阶段遇到一些错误,代码可以编译,但由于缺少一些符号而无法使用。错误是:

Undefined symbols for architecture x86_64:
"_CFBundleGetMainBundle", referenced from: 
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
  _main in libSDLmain.a(SDLMain.o)
"_CFBundleCopyBundleURL", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLCreateCopyDeletingLastPathComponent", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLGetFileSystemRepresentation", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFRelease", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)

...

"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
  objc-class-ref in libSDLmain.a(SDLMain.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [dist/linwarrior] Error 1

我使用 file 命令检查,这些库要么仅限 x86_64,要么与 i386 和 x86_64 版本通用。

有没有办法让我确定到底是什么导致了这个错误?一种检查所包含的库的方法或任何帮助调试问题的方法?

我不知道它是否有帮助,但这就是我的 Makefile 创建的内容,我删除了文件名以使其简短,并且 KNT 标志只是我用于预处理器条件的东西:

/opt/local/bin/g++-mp-4.5 -DKNT=1 -Wp,-M,-MP,-MT,-MF, -std=c++0x -Wall -I source -O1 -funroll-loops -c -o

谢谢。

I'm trying to compile a C/C++ program that uses SDL on a OS X 10.6.8 but I'm having some errors on the linking stage, the code compiles but fails to like due to some missing symbols. The error is:

Undefined symbols for architecture x86_64:
"_CFBundleGetMainBundle", referenced from: 
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
  _main in libSDLmain.a(SDLMain.o)
"_CFBundleCopyBundleURL", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLCreateCopyDeletingLastPathComponent", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLGetFileSystemRepresentation", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFRelease", referenced from:
  -[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)

...

"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
  objc-class-ref in libSDLmain.a(SDLMain.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [dist/linwarrior] Error 1

I checked with the file command and the libraries are either x86_64 only or universal with both i386 and x86_64 versions.

Is there a way for me to determine what exactly is causing this error? A way to check the libs that are being included or any way to help debug the problem?

I don't know if it helps but this is what my Makefile creates, I removed file names to make it short, and the KNT flag is just something I'm using for preprocessor conditions:

/opt/local/bin/g++-mp-4.5 -DKNT=1 -Wp,-M,-MP,-MT,-MF, -std=c++0x -Wall -I source -O1 -funroll-loops -c -o

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文