未定义的符号 建筑x86_64的未定义符号:"_kCFAllocatorDefault"
undefined symbols Undefined symbols for architecture x86_64: "_kCFAllocatorDefault"
我正试图在eclipse中的macos10.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中的g++和gcc的参数中添加-framework CoreFramework,但这并没有解决问题
这些符号位于何处,更重要的是-我如何将它们添加到我的项目中?
我通过向链接器添加.dylib来修复此问题。如何设置?
- 转到项目礼仪
- 转到C/C++构建-->设置
- 选择Mac OS X C++链接器-->库以下是棘手的部分……我通过"尝试错误"方法找到了它的工作原理:
假设您有一个dylib文件要添加,名为"libMyLib.dylib",位于/opt/local/lib/MyLibrary 中
到窗口中显示库的部分添加行"MyLib"在窗口中显示库搜索路径的部分添加行"/opt/local/lib/MyLibrary/"
=>eclipse将自动执行以下操作:1.在字符串前面添加"lib"2.在字符串后添加".dylib"
Mac出现了另一个问题。。。假设您使用CoreFoundation框架中的符号。Mac操作系统框架本质上是带有头文件的dylib。。。如果你不确定你可以随时通过"文件myFile"检查
问题是eclipse永远不会正确地从MAC OS SDK和/System/Library/Frameworks/中获取这些dylib,因为它们没有添加.dlib。诀窍是简单地去dylib所在的地方(即使它的名字中没有.dlib)。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
您可以使用-framework选项例如g++框架CoreFoundation。。。。。。。。。。
相关文章:
- vscode g++链路故障:体系结构x86_64的未定义符号
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- C++ 中 dlsym 的未定义符号
- 仅在 MacOS 上析构函数的未定义符号
- OSX clang++:用于 cpp 文件中显式实例化模板的体系结构x86_64的未定义符号
- PCL 出错:体系结构x86_64 @pcl的未定义符号
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 体系结构x86_64的未定义符号:链接器错误
- C++ std::vector<int> 体系结构的未定义符号 x86_64:
- 生成文件:体系结构x86_64的未定义符号
- libc++abi未定义符号:_ZTVN10__cxxabif120__si-class_type_infoE
- Xcode"体系结构x86_64的未定义符号"
- 体系结构x86_64的未定义符号:找不到原因
- SWIG链接器:未定义符号:_ZN2cv8fastFreeEPv(cv::fastFree(void*))
- 如何修复架构x86_64的未定义符号,Boost Asio 1.58
- 在Qt5上去静态库:架构的未定义符号x86_64:
- 体系结构x86_64的未定义符号:c++/ h 文件和 cpp 文件
- 监视 SDK 下的未定义符号"__Unwind_SjLj_Unregister"
- 使用 Boost/Python 的未定义符号 - 复杂
- 建筑x86_64的未定义符号:"vtkDebugLeaksManager::vtkDebugLeaksManager()",引用自: