Undefined symbols undefined symbols for x86_64 architecture: "_kCFAllocatorDefault"
I am trying to compile some things under mac os 10.7 in eclipse and the assembly dies:
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
So I know the problem is with the ld characters. Now I tried to come up with tricks and add -framework CoreFramework to g ++ and gcc options in eclipse, but it doesn't fix it.
Where are these symbols located, and more importantly, how do I add them to my project ?
source to share
I fixed this by adding .dylib to the linker. How do I set it up?
- Go to projects
- Go to C / C ++ build -> settings
- Select Mac OS X C ++ Linker -> Libraries This is where the tricky part is ... I learned from the "try-error" method how it works:
Let's say you have a dylib file that you want to add called libMyLib.dylib located at / opt / local / lib / MyLibrary
For the part of the window that says the libraries add the string "MyLib" For the part of the window that says: add the search string to the library "/ Opt / local / Library / MyLibrary /"
=> eclipse will automatically do the following: 1. add "lib" before the line 2. add ".dylib" after the line
There is another problem with Mac ... Let's say you are using symbols from Framework CoreFoundation. Framework for Mac OS is an important dylib with header files ... If you are unsure you can always check "file myFile"
The problem is that eclipse will never pick up these dylibs correctly from the MAC OS SDK and / System / Library / Frameworks / because they won't have the .dylib added. The trick is to just navigate to where dylib is located (although it doesn't have .dylib in its name), for example. cd / System / Library / Frameworks / CoreFoundation.framework
and then copy the file and add dylib (DON'T GET THIS !!!)
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
source to share