OSX Lion missing symbols

anonymous wrote on Wednesday, November 23, 2011:

I am trying to build a program that compiles fine in ubuntu on osx lion. The
linker complains as such:

Linking CXX executable photonio
Undefined symbols for architecture x86_64:
  "_glEnable", referenced from:
      pho::Engine::initResources()     in photonio.cpp.o
  "_glDepthMask", referenced from:
      pho::Engine::initResources()     in photonio.cpp.o
  "_glDepthFunc", referenced from:
      pho::Engine::initResources()     in photonio.cpp.o
  "_glDepthRange", referenced from:
      pho::Engine::initResources()     in photonio.cpp.o
  "_glClear", referenced from:
      pho::Engine::render()    in photonio.cpp.o
      _glfwOpenWindow in libglfw.a(window.o)
  "_glLineWidth", referenced from:
      pho::Engine::render()    in photonio.cpp.o
  "_glGetError", referenced from:
      pho::Engine::render()    in photonio.cpp.o
  "_glGetString", referenced from:
      __glfwParseGLVersion in libglfw.a(glext.o)
      _glfwExtensionSupported in libglfw.a(glext.o)
  "_glGetIntegerv", referenced from:
      __glfwRefreshContextParams in libglfw.a(glext.o)
      _glfwExtensionSupported in libglfw.a(glext.o)
  "_kCFAllocatorDefault", referenced from:
      __glfwPlatformGetProcAddress in libglfw.a(cocoa_glext.o)
  "_CFStringCreateWithCString", referenced from:
      __glfwPlatformGetProcAddress in libglfw.a(cocoa_glext.o)
  "_CFBundleGetFunctionPointerForName", referenced from:
      __glfwPlatformGetProcAddress in libglfw.a(cocoa_glext.o)
  "_CFRelease", referenced from:
      __glfwPlatformGetProcAddress in libglfw.a(cocoa_glext.o)
  "_objc_msgSend", referenced from:
      -[GLFWApplication sendEvent:] in libglfw.a(cocoa_init.o)
      __glfwPlatformInit in libglfw.a(cocoa_init.o)
      __glfwPlatformOpenWindow in libglfw.a(cocoa_window.o)
      -[GLFWContentView mouseDragged:] in libglfw.a(cocoa_window.o)
      -[GLFWContentView rightMouseDragged:] in libglfw.a(cocoa_window.o)
      -[GLFWContentView otherMouseDragged:] in libglfw.a(cocoa_window.o)
      __glfwPlatformPollEvents in libglfw.a(cocoa_window.o)
      ...
  "_objc_msgSendSuper2", referenced from:
      -[GLFWApplication sendEvent:] in libglfw.a(cocoa_init.o)
      -[GLFWContentView keyDown:] in libglfw.a(cocoa_window.o)
  "_CFBundleGetBundleWithIdentifier", referenced from:
      __glfwPlatformInit in libglfw.a(cocoa_init.o)
  "_TransformProcessType", referenced from:
      __glfwPlatformInit in libglfw.a(cocoa_init.o)
  "_SetFrontProcess", referenced from:
      __glfwPlatformInit in libglfw.a(cocoa_init.o)
  "_NSApp", referenced from:
      __glfwPlatformInit in libglfw.a(cocoa_init.o)
      __glfwPlatformOpenWindow in libglfw.a(cocoa_window.o)
      __glfwPlatformPollEvents in libglfw.a(cocoa_window.o)
      __glfwPlatformWaitEvents in libglfw.a(cocoa_window.o)
      __glfwPlatformCloseWindow in libglfw.a(cocoa_window.o)
  "_CGMainDisplayID", referenced from:
      __glfwPlatformInit in libglfw.a(cocoa_init.o)
      __glfwPlatformOpenWindow in libglfw.a(cocoa_window.o)
      __glfwPlatformSetMouseCursorPos in libglfw.a(cocoa_window.o)
      __glfwPlatformCloseWindow in libglfw.a(cocoa_window.o)
  "_CGDisplayCurrentMode", referenced from:
      __glfwPlatformInit in libglfw.a(cocoa_init.o)
  "_objc_msgSend_fixup", referenced from:
      l_objc_msgSend_fixup_autorelease in libglfw.a(cocoa_init.o)
      l_objc_msgSend_fixup_objectForKey_ in libglfw.a(cocoa_init.o)
      l_objc_msgSend_fixup_class in libglfw.a(cocoa_init.o)
      l_objc_msgSend_fixup_isKindOfClass_ in libglfw.a(cocoa_init.o)
      l_objc_msgSend_fixup_isEqualToString_ in libglfw.a(cocoa_init.o)
      l_objc_msgSend_fixup_alloc in libglfw.a(cocoa_init.o)
      l_objc_msgSend_fixup_respondsToSelector_ in libglfw.a(cocoa_init.o)
      ...
  "_OBJC_METACLASS_$_NSObject", referenced from:
      _OBJC_METACLASS_$_GLFWApplication in libglfw.a(cocoa_init.o)
      _OBJC_METACLASS_$_GLFWThread in libglfw.a(cocoa_init.o)
      _OBJC_METACLASS_$_GLFWContentView in libglfw.a(cocoa_window.o)
      _OBJC_METACLASS_$_GLFWWindowDelegate in libglfw.a(cocoa_window.o)
  "_OBJC_METACLASS_$_NSApplication", referenced from:
      _OBJC_METACLASS_$_GLFWApplication in libglfw.a(cocoa_init.o)
  "__objc_empty_cache", referenced from:
      _OBJC_METACLASS_$_GLFWApplication in libglfw.a(cocoa_init.o)
      _OBJC_CLASS_$_GLFWApplication in libglfw.a(cocoa_init.o)
      _OBJC_METACLASS_$_GLFWThread in libglfw.a(cocoa_init.o)
      _OBJC_CLASS_$_GLFWThread in libglfw.a(cocoa_init.o)
      _OBJC_METACLASS_$_GLFWContentView in libglfw.a(cocoa_window.o)
      _OBJC_CLASS_$_GLFWContentView in libglfw.a(cocoa_window.o)
      _OBJC_METACLASS_$_GLFWWindowDelegate in libglfw.a(cocoa_window.o)
      ...
  "__objc_empty_vtable", referenced from:
      _OBJC_METACLASS_$_GLFWApplication in libglfw.a(cocoa_init.o)
      _OBJC_CLASS_$_GLFWApplication in libglfw.a(cocoa_init.o)
      _OBJC_METACLASS_$_GLFWThread in libglfw.a(cocoa_init.o)
      _OBJC_CLASS_$_GLFWThread in libglfw.a(cocoa_init.o)
      _OBJC_METACLASS_$_GLFWContentView in libglfw.a(cocoa_window.o)
      _OBJC_CLASS_$_GLFWContentView in libglfw.a(cocoa_window.o)
      _OBJC_METACLASS_$_GLFWWindowDelegate in libglfw.a(cocoa_window.o)
      ...
  "_OBJC_CLASS_$_NSApplication", referenced from:
      _OBJC_CLASS_$_GLFWApplication in libglfw.a(cocoa_init.o)
  "_OBJC_CLASS_$_NSBundle", referenced from:
      objc-class-ref in libglfw.a(cocoa_init.o)
  "___CFConstantStringClassReference", referenced from:
      CFString in libglfw.a(cocoa_init.o)
      CFString in libglfw.a(cocoa_init.o)
      CFString in libglfw.a(cocoa_init.o)
      CFString in libglfw.a(cocoa_init.o)
      CFString in libglfw.a(cocoa_init.o)
      CFString in libglfw.a(cocoa_init.o)
      CFString in libglfw.a(cocoa_init.o)
      ...
  "_OBJC_CLASS_$_NSString", referenced from:
      objc-class-ref in libglfw.a(cocoa_init.o)
      objc-class-ref in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSMenu", referenced from:
      objc-class-ref in libglfw.a(cocoa_init.o)
  "_OBJC_CLASS_$_NSMenuItem", referenced from:
      objc-class-ref in libglfw.a(cocoa_init.o)
  "_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
      objc-class-ref in libglfw.a(cocoa_init.o)
      objc-class-ref in libglfw.a(cocoa_window.o)
  "_OBJC_METACLASS_$_NSThread", referenced from:
      _OBJC_METACLASS_$_GLFWThread in libglfw.a(cocoa_init.o)
  "_OBJC_CLASS_$_NSThread", referenced from:
      _OBJC_CLASS_$_GLFWThread in libglfw.a(cocoa_init.o)
  "_CGDisplayBestModeForParametersAndRefreshRateWithProperty", referenced from:
      __glfwPlatformOpenWindow in libglfw.a(cocoa_window.o)
  "_CGCaptureAllDisplays", referenced from:
      __glfwPlatformOpenWindow in libglfw.a(cocoa_window.o)
  "_CGDisplaySwitchToMode", referenced from:
      __glfwPlatformOpenWindow in libglfw.a(cocoa_window.o)
      __glfwPlatformCloseWindow in libglfw.a(cocoa_window.o)
  "_CGDisplayIDToOpenGLDisplayMask", referenced from:
      __glfwPlatformOpenWindow in libglfw.a(cocoa_window.o)
  "_NSDefaultRunLoopMode", referenced from:
      __glfwPlatformPollEvents in libglfw.a(cocoa_window.o)
      __glfwPlatformWaitEvents in libglfw.a(cocoa_window.o)
  "_objc_msgSend_stret", referenced from:
      -[GLFWWindowDelegate windowDidResize:] in libglfw.a(cocoa_window.o)
      -[GLFWContentView mouseMoved:] in libglfw.a(cocoa_window.o)
      __glfwPlatformSetWindowPos in libglfw.a(cocoa_window.o)
  "_CGSetLocalEventsSuppressionInterval", referenced from:
      __glfwPlatformSetMouseCursorPos in libglfw.a(cocoa_window.o)
  "_CGDisplayBounds", referenced from:
      __glfwPlatformSetMouseCursorPos in libglfw.a(cocoa_window.o)
  "_CGDisplayMoveCursorToPoint", referenced from:
      __glfwPlatformSetMouseCursorPos in libglfw.a(cocoa_window.o)
  "_CGAssociateMouseAndMouseCursorPosition", referenced from:
      __glfwPlatformShowMouseCursor in libglfw.a(cocoa_window.o)
      __glfwPlatformHideMouseCursor in libglfw.a(cocoa_window.o)
  "_CGReleaseAllDisplays", referenced from:
      __glfwPlatformCloseWindow in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSDate", referenced from:
      objc-class-ref in libglfw.a(cocoa_window.o)
      objc-class-ref in libglfw.a(cocoa_time.o)
  "_OBJC_METACLASS_$_NSView", referenced from:
      _OBJC_METACLASS_$_GLFWContentView in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSView", referenced from:
      _OBJC_CLASS_$_GLFWContentView in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSCursor", referenced from:
      objc-class-ref in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSOpenGLContext", referenced from:
      objc-class-ref in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSObject", referenced from:
      _OBJC_CLASS_$_GLFWWindowDelegate in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSWindow", referenced from:
      objc-class-ref in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSOpenGLPixelFormat", referenced from:
      objc-class-ref in libglfw.a(cocoa_window.o)
  "_OBJC_CLASS_$_NSScreen", referenced from:
      objc-class-ref in libglfw.a(cocoa_window.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [src/photonio] Error 1
make[1]: *** [src/CMakeFiles/photonio.dir/all] Error 2
make: *** [all] Error 2
The process "/usr/bin/make" exited with code 2.
Error while building project photonio (target: Desktop)
When executing build step 'Make'

I have included the new glfw.h I saw in a previous post here but still no
luck. I have also tried to tell cmake

SET(EXTRA_LIBS "-framework Cocoa -framework OpenGL")

But still the same linker erros.

Any ideas? :slight_smile:

anonymous wrote on Wednesday, November 23, 2011:

I found the solution:

http://www.vtk.org/Wiki/CMake:HowToUseExistingOSXFrameworks

For those not using cmake you must use -F or -framework to link