gpt4 book ai didi

c++ - undefined symbol 体系结构 x86_64 的 undefined symbol : "_kCFAllocatorDefault"

转载 作者:太空狗 更新时间:2023-10-29 19:59:55 26 4
gpt4 key购买 nike

我正在尝试在 mac os 10.7 下的 eclipse 中编译一些东西,但构建失败了:

  Undefined symbols for architecture x86_64:
"_kCFAllocatorDefault", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFURLCreateWithFileSystemPath", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFStringCreateWithCString", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFBundleCreate", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFBundleGetFunctionPointerForName", referenced from:
___GLeeGetProcAddress in GLee.o
"_CFRelease", referenced from:
___GLeeGetProcAddress in GLee.o
"_glGetString", referenced from:
___GLeeGetExtensions in GLee.o
_GLeeGetExtStrGL in GLee.o
_GLeeInit in GLee.o
(maybe you meant: _GLee_Lazy_glGetStringi, _GLeeFuncPtr_glGetStringi )
"___CFConstantStringClassReference", referenced from:
CFString in GLee.o

所以我知道问题出在 ld 符号上。现在我尝试去项目属性并在 eclipse 中将 -framework CoreFramework 添加到 g++ 和 gcc 的参数,但这并没有解决它。

这些符号位于何处,更重要的是 - 如何将它们添加到我的项目中

最佳答案

我通过向链接器添加 .dylib 来修复此问题。如何设置?

  1. 转到项目属性
  2. 转到 C/C++ 构建 --> 设置
  3. 选择 Mac OS X C++ 链接器 --> 库这是棘手的部分......我通过“try-error”方法发现了它是如何工作的:

假设您有一个要添加的名为“libMyLib.dylib”的 dylib 文件,位于/opt/local/lib/MyLibrary

在显示库的窗口的一部分添加行“我的图书馆”在显示库搜索路径的窗口的一部分添加行“/opt/local/lib/MyLibrary/”

=> eclipse 会自动执行此操作:1.在字符串前加上“lib”2. 在你的字符串后添加“.dylib”

Mac 出现了另一个问题...假设您使用了 CoreFoundation 框架中的符号。 Mac OS 框架本质上是带有头文件的动态库……如果您不确定,可以随时通过“file myFile”进行检查

问题是 eclipse 永远不会正确地从 MAC OS SDK 和/System/Library/Frameworks/中获取那些 dylib,因为它们没有添加 .dylib。诀窍是简单地转到 dylib 所在的位置(即使它的名称中没有 .dylib)例如 cd/System/Library/Frameworks/CoreFoundation.framework

然后复制文件并添加dylib(不要重命名!!!)

  file CoreFoundation
CoreFoundation (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
CoreFoundation (for architecture i386): Mach-O dynamically linked shared library i386
#copy the lib and name it to "eclipse friendly format"
cp CoreFoundation libCoreFoundation.dylib

关于c++ - undefined symbol 体系结构 x86_64 的 undefined symbol : "_kCFAllocatorDefault",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9955105/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com