我正在尝试在eclipse中的mac os 10.7下编译一些东西,然后构建就死了:
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的参数中但是没有解决它。
这些符号位于何处,更重要的是 - 如何将它们添加到我的项目?
答案 0 :(得分:5)
我通过向链接器添加.dylib来修复此问题。如何设置?
假设您有一个名为“libMyLib.dylib”的dylib文件位于/ opt / local / lib / MyLibrary
到窗口的一部分,它表示库添加行 “MyLib中” 到窗口的一部分,它说库搜索路径添加行 “/选择/本地/ lib中/在MyLibrary /”
=> eclipse会自动执行此操作: 1.在字符串前添加“lib” 2.在字符串
后添加“.dylib”Mac出现了另一个问题......让我们假设您使用CoreFoundation框架中的符号。 Mac OS框架是带头文件的必要dylib ...如果您不确定可以随时检查“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
答案 1 :(得分:4)
您可以使用-framework选项 例如g ++ -framework CoreFoundation ..........