Question

I am trying to compile some stuff under mac os 10.7 in eclipse and the build dies on:

  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 ld symbols. Now I tried going to project proprieties and adding -framework CoreFramework to parameters of g++ and gcc in eclipse but that didnt fix it.

Where are these symbols located and more importantly - how do I add them to my project?

Was it helpful?

Solution

I fixed this by adding a .dylib to linker. How to set it up?

  1. Go to project proprieties
  2. Go to C/C++ build --> settings
  3. Choose Mac OS X C++ Linker --> Libraries Here is where the tricky part is... I found out by "try-error" method, how this works:

Lets say you have a dylib file you want to add called "libMyLib.dylib" located in /opt/local/lib/MyLibrary

To part of the window where it says libraries add line "MyLib" To part of the window where it says Library search path add line "/opt/local/lib/MyLibrary/"

=> eclipse will automatically do this: 1. add "lib" in front of the string 2. add ".dylib" after your string

There comes another problem with Mac... Lets say you use symbols from CoreFoundation framework. Mac OS frameworks are essentialy dylibs with header files ... If you are not sure you can always check by "file myFile"

The problem is that eclipse will never correctly pick up on those dylibs from MAC OS SDK and /System/Library/Frameworks/ cause they dont have the .dylib added to them. The trick is to simply go to where the dylib is located (eventhough it doesnt have a .dylib in its name) e.g. cd /System/Library/Frameworks/CoreFoundation.framework

and then copy the file and add dylib (do NOT RENAME IT!!!)

  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

OTHER TIPS

You can use the -framework option e.g. g++ -framework CoreFoundation ..........

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top