我已经生成了一个名为libglfw3.a
的文件并添加了库(在Libraries (-l)
下)glfw3
。
我还在libglfw3.a
中添加了包含Library search path (-L)
的文件夹的路径。
但是,当我尝试编译时,链接器仍会返回错误。
我的代码非常基本,如下所示。
#include <GLFW/glfw3.h>
int main() {
glfwInit();
glfwTerminate();
return 0;
}
控制台输出是:
make all
Building target: TestProject
Invoking: MacOS X C++ Linker
g++ -o "TestProject" ./src/Main.o /Users/pixel/Documents/Library/libglfw3.a
Undefined symbols for architecture x86_64:
"_CFArrayAppendValue", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
_addJoystickElement in libglfw3.a(iokit_joystick.m.o)
"_CFArrayApplyFunction", referenced from:
_matchCallback in libglfw3.a(iokit_joystick.m.o)
"_CFArrayCreateMutable", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
_matchCallback in libglfw3.a(iokit_joystick.m.o)
"_CFArrayGetCount", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
_matchCallback in libglfw3.a(iokit_joystick.m.o)
_removeJoystick in libglfw3.a(iokit_joystick.m.o)
_pollJoystickEvents in libglfw3.a(iokit_joystick.m.o)
__glfwPlatformGetJoystickAxes in libglfw3.a(iokit_joystick.m.o)
__glfwPlatformGetJoystickButtons in libglfw3.a(iokit_joystick.m.o)
...
"_CFArrayGetValueAtIndex", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
_removeJoystick in libglfw3.a(iokit_joystick.m.o)
_pollJoystickEvents in libglfw3.a(iokit_joystick.m.o)
"_CFArrayRemoveAllValues", referenced from:
_removeJoystick in libglfw3.a(iokit_joystick.m.o)
"_CFBundleCopyResourcesDirectoryURL", referenced from:
_changeToResourcesDirectory in libglfw3.a(cocoa_init.m.o)
"_CFBundleGetBundleWithIdentifier", referenced from:
__glfwInitContextAPI in libglfw3.a(nsgl_context.m.o)
"_CFBundleGetFunctionPointerForName", referenced from:
__glfwPlatformGetProcAddress in libglfw3.a(nsgl_context.m.o)
"_CFBundleGetMainBundle", referenced from:
_changeToResourcesDirectory in libglfw3.a(cocoa_init.m.o)
"_CFDictionaryCreateMutable", referenced from:
_createMatchingDictionary in libglfw3.a(iokit_joystick.m.o)
"_CFDictionaryGetValue", referenced from:
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
"_CFDictionaryGetValueIfPresent", referenced from:
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
"_CFDictionarySetValue", referenced from:
_createMatchingDictionary in libglfw3.a(iokit_joystick.m.o)
"_CFGetTypeID", referenced from:
_getElementsCFArrayHandler in libglfw3.a(iokit_joystick.m.o)
"_CFNumberCreate", referenced from:
_createMatchingDictionary in libglfw3.a(iokit_joystick.m.o)
"_CFRelease", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
_modeIsGood in libglfw3.a(cocoa_monitor.m.o)
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
_changeToResourcesDirectory in libglfw3.a(cocoa_init.m.o)
__glfwPlatformTerminate in libglfw3.a(cocoa_init.m.o)
...
"_CFRunLoopGetMain", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_CFRunLoopRunInMode", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_CFStringCompare", referenced from:
_modeIsGood in libglfw3.a(cocoa_monitor.m.o)
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
_changeToResourcesDirectory in libglfw3.a(cocoa_init.m.o)
"_CFStringCreateWithCString", referenced from:
__glfwPlatformGetProcAddress in libglfw3.a(nsgl_context.m.o)
"_CFStringGetCString", referenced from:
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
_matchCallback in libglfw3.a(iokit_joystick.m.o)
"_CFStringGetLength", referenced from:
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
"_CFStringGetMaximumSizeForEncoding", referenced from:
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
"_CFURLCopyLastPathComponent", referenced from:
_changeToResourcesDirectory in libglfw3.a(cocoa_init.m.o)
"_CFURLGetFileSystemRepresentation", referenced from:
_changeToResourcesDirectory in libglfw3.a(cocoa_init.m.o)
"_CGAcquireDisplayFadeReservation", referenced from:
_beginFadeReservation in libglfw3.a(cocoa_monitor.m.o)
"_CGAssociateMouseAndMouseCursorPosition", referenced from:
__glfwPlatformApplyCursorMode in libglfw3.a(cocoa_window.m.o)
"_CGDisplayBounds", referenced from:
_transformY in libglfw3.a(cocoa_window.m.o)
__glfwPlatformGetMonitorPos in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayCopyAllDisplayModes", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayCopyDisplayMode", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayFade", referenced from:
_beginFadeReservation in libglfw3.a(cocoa_monitor.m.o)
_endFadeReservation in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayGammaTableCapacity", referenced from:
__glfwPlatformGetGammaRamp in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayIOServicePort", referenced from:
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayIsAsleep", referenced from:
__glfwPlatformGetMonitors in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayModeCopyPixelEncoding", referenced from:
_modeIsGood in libglfw3.a(cocoa_monitor.m.o)
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayModeGetHeight", referenced from:
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayModeGetIOFlags", referenced from:
_modeIsGood in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayModeGetRefreshRate", referenced from:
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayModeGetWidth", referenced from:
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayModeRelease", referenced from:
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwRestoreVideoMode in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayMoveCursorToPoint", referenced from:
__glfwPlatformSetCursorPos in libglfw3.a(cocoa_window.m.o)
"_CGDisplayScreenSize", referenced from:
__glfwPlatformGetMonitors in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplaySetDisplayMode", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwRestoreVideoMode in libglfw3.a(cocoa_monitor.m.o)
"_CGDisplayUnitNumber", referenced from:
__glfwPlatformGetMonitors in libglfw3.a(cocoa_monitor.m.o)
"_CGEventSourceCreate", referenced from:
__glfwPlatformInit in libglfw3.a(cocoa_init.m.o)
"_CGEventSourceSetLocalEventsSuppressionInterval", referenced from:
__glfwPlatformInit in libglfw3.a(cocoa_init.m.o)
"_CGGetDisplayTransferByTable", referenced from:
__glfwPlatformGetGammaRamp in libglfw3.a(cocoa_monitor.m.o)
"_CGGetOnlineDisplayList", referenced from:
__glfwPlatformGetMonitors in libglfw3.a(cocoa_monitor.m.o)
"_CGMainDisplayID", referenced from:
_transformY in libglfw3.a(cocoa_window.m.o)
"_CGReleaseDisplayFadeReservation", referenced from:
_endFadeReservation in libglfw3.a(cocoa_monitor.m.o)
"_CGSetDisplayTransferByTable", referenced from:
__glfwPlatformSetGammaRamp in libglfw3.a(cocoa_monitor.m.o)
"_CGWarpMouseCursorPosition", referenced from:
__glfwPlatformSetCursorPos in libglfw3.a(cocoa_window.m.o)
"_CGWindowLevelForKey", referenced from:
_createWindow in libglfw3.a(cocoa_window.m.o)
"_CVDisplayLinkCreateWithCGDisplay", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
"_CVDisplayLinkGetNominalOutputVideoRefreshPeriod", referenced from:
_vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
"_CVDisplayLinkRelease", referenced from:
__glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
__glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
"_IODisplayCreateInfoDictionary", referenced from:
_getDisplayName in libglfw3.a(cocoa_monitor.m.o)
"_IOHIDDeviceCopyMatchingElements", referenced from:
_matchCallback in libglfw3.a(iokit_joystick.m.o)
"_IOHIDDeviceGetProperty", referenced from:
_matchCallback in libglfw3.a(iokit_joystick.m.o)
"_IOHIDDeviceGetValue", referenced from:
_getElementValue in libglfw3.a(iokit_joystick.m.o)
"_IOHIDElementGetLogicalMax", referenced from:
_addJoystickElement in libglfw3.a(iokit_joystick.m.o)
"_IOHIDElementGetLogicalMin", referenced from:
_addJoystickElement in libglfw3.a(iokit_joystick.m.o)
"_IOHIDElementGetType", referenced from:
_addJoystickElement in libglfw3.a(iokit_joystick.m.o)
"_IOHIDElementGetTypeID", referenced from:
_getElementsCFArrayHandler in libglfw3.a(iokit_joystick.m.o)
"_IOHIDElementGetUsage", referenced from:
_addJoystickElement in libglfw3.a(iokit_joystick.m.o)
"_IOHIDElementGetUsagePage", referenced from:
_addJoystickElement in libglfw3.a(iokit_joystick.m.o)
"_IOHIDManagerCreate", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_IOHIDManagerOpen", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_IOHIDManagerRegisterDeviceMatchingCallback", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_IOHIDManagerRegisterDeviceRemovalCallback", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_IOHIDManagerScheduleWithRunLoop", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_IOHIDManagerSetDeviceMatchingMultiple", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_IOHIDValueGetIntegerValue", referenced from:
_getElementValue in libglfw3.a(iokit_joystick.m.o)
"_NSApp", referenced from:
-[GLFWApplicationDelegate applicationDidFinishLaunching:] in libglfw3.a(cocoa_window.m.o)
__glfwPlatformPostEmptyEvent in libglfw3.a(cocoa_window.m.o)
_initializeAppKit in libglfw3.a(cocoa_window.m.o)
__glfwPlatformShowWindow in libglfw3.a(cocoa_window.m.o)
__glfwPlatformPollEvents in libglfw3.a(cocoa_window.m.o)
__glfwPlatformWaitEvents in libglfw3.a(cocoa_window.m.o)
_createMenuBar in libglfw3.a(cocoa_window.m.o)
...
"_NSAppKitVersionNumber", referenced from:
_convertRectToBacking in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView scrollWheel:] in libglfw3.a(cocoa_window.m.o)
_createWindow in libglfw3.a(cocoa_window.m.o)
_createMenuBar in libglfw3.a(cocoa_window.m.o)
"_NSCalibratedRGBColorSpace", referenced from:
__glfwPlatformCreateCursor in libglfw3.a(cocoa_window.m.o)
"_NSDefaultRunLoopMode", referenced from:
__glfwPlatformPollEvents in libglfw3.a(cocoa_window.m.o)
__glfwPlatformWaitEvents in libglfw3.a(cocoa_window.m.o)
"_NSFilenamesPboardType", referenced from:
-[GLFWContentView initWithGlfwWindow:] in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView performDragOperation:] in libglfw3.a(cocoa_window.m.o)
"_NSSelectorFromString", referenced from:
_createMenuBar in libglfw3.a(cocoa_window.m.o)
"_NSStringPboardType", referenced from:
__glfwPlatformSetClipboardString in libglfw3.a(cocoa_window.m.o)
__glfwPlatformGetClipboardString in libglfw3.a(cocoa_window.m.o)
"_NSZeroPoint", referenced from:
+[GLFWContentView initialize] in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSApplication", referenced from:
_OBJC_CLASS_$_GLFWApplication in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSArray", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
objc-class-ref in libglfw3.a(cocoa_init.m.o)
"_OBJC_CLASS_$_NSBitmapImageRep", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSBundle", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSCursor", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSDate", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSEvent", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSImage", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSMenu", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSMenuItem", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSObject", referenced from:
_OBJC_CLASS_$_GLFWWindowDelegate in libglfw3.a(cocoa_window.m.o)
_OBJC_CLASS_$_GLFWApplicationDelegate in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSOpenGLContext", referenced from:
objc-class-ref in libglfw3.a(nsgl_context.m.o)
"_OBJC_CLASS_$_NSOpenGLPixelFormat", referenced from:
objc-class-ref in libglfw3.a(nsgl_context.m.o)
"_OBJC_CLASS_$_NSPasteboard", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSString", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSTrackingArea", referenced from:
objc-class-ref in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSView", referenced from:
_OBJC_CLASS_$_GLFWContentView in libglfw3.a(cocoa_window.m.o)
"_OBJC_CLASS_$_NSWindow", referenced from:
_OBJC_CLASS_$_GLFWWindow in libglfw3.a(cocoa_window.m.o)
"_OBJC_METACLASS_$_NSApplication", referenced from:
_OBJC_METACLASS_$_GLFWApplication in libglfw3.a(cocoa_window.m.o)
"_OBJC_METACLASS_$_NSObject", referenced from:
_OBJC_METACLASS_$_GLFWWindowDelegate in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWApplicationDelegate in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWContentView in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWWindow in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWApplication in libglfw3.a(cocoa_window.m.o)
"_OBJC_METACLASS_$_NSView", referenced from:
_OBJC_METACLASS_$_GLFWContentView in libglfw3.a(cocoa_window.m.o)
"_OBJC_METACLASS_$_NSWindow", referenced from:
_OBJC_METACLASS_$_GLFWWindow in libglfw3.a(cocoa_window.m.o)
"___CFConstantStringClassReference", referenced from:
CFString in libglfw3.a(cocoa_window.m.o)
CFString in libglfw3.a(cocoa_window.m.o)
CFString in libglfw3.a(cocoa_window.m.o)
CFString in libglfw3.a(cocoa_window.m.o)
CFString in libglfw3.a(cocoa_window.m.o)
CFString in libglfw3.a(cocoa_window.m.o)
CFString in libglfw3.a(cocoa_window.m.o)
...
"__objc_empty_cache", referenced from:
_OBJC_CLASS_$_GLFWWindowDelegate in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWWindowDelegate in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWApplicationDelegate in libglfw3.a(cocoa_window.m.o)
_OBJC_CLASS_$_GLFWApplicationDelegate in libglfw3.a(cocoa_window.m.o)
_OBJC_CLASS_$_GLFWContentView in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWContentView in libglfw3.a(cocoa_window.m.o)
_OBJC_METACLASS_$_GLFWWindow in libglfw3.a(cocoa_window.m.o)
...
"_kCFAllocatorDefault", referenced from:
__glfwPlatformGetProcAddress in libglfw3.a(nsgl_context.m.o)
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
_createMatchingDictionary in libglfw3.a(iokit_joystick.m.o)
"_kCFRunLoopDefaultMode", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_kCFTypeArrayCallBacks", referenced from:
__glfwInitJoysticks in libglfw3.a(iokit_joystick.m.o)
"_kCFTypeDictionaryKeyCallBacks", referenced from:
_createMatchingDictionary in libglfw3.a(iokit_joystick.m.o)
"_kCFTypeDictionaryValueCallBacks", referenced from:
_createMatchingDictionary in libglfw3.a(iokit_joystick.m.o)
"_objc_msgSend", referenced from:
-[GLFWWindowDelegate windowDidResize:] in libglfw3.a(cocoa_window.m.o)
-[GLFWWindowDelegate windowDidMove:] in libglfw3.a(cocoa_window.m.o)
_enterFullscreenMode in libglfw3.a(cocoa_window.m.o)
__glfwPlatformIconifyWindow in libglfw3.a(cocoa_window.m.o)
-[GLFWApplicationDelegate applicationDidFinishLaunching:] in libglfw3.a(cocoa_window.m.o)
__glfwPlatformPostEmptyEvent in libglfw3.a(cocoa_window.m.o)
+[GLFWContentView initialize] in libglfw3.a(cocoa_window.m.o)
...
"_objc_msgSendSuper2", referenced from:
-[GLFWWindowDelegate initWithGlfwWindow:] in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView initWithGlfwWindow:] in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView dealloc] in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView updateTrackingAreas] in libglfw3.a(cocoa_window.m.o)
-[GLFWApplication sendEvent:] in libglfw3.a(cocoa_window.m.o)
"_objc_msgSend_stret", referenced from:
-[GLFWWindowDelegate windowDidResize:] in libglfw3.a(cocoa_window.m.o)
_convertRectToBacking in libglfw3.a(cocoa_window.m.o)
__glfwPlatformGetWindowPos in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView mouseMoved:] in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView viewDidChangeBackingProperties] in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView updateTrackingAreas] in libglfw3.a(cocoa_window.m.o)
-[GLFWContentView performDragOperation:] in libglfw3.a(cocoa_window.m.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [TestProject] Error 1
答案 0 :(得分:2)
来自GLFW: Building Applications:
如果您使用的是静态库版本的GLFW,请将它和Cocoa,OpenGL,IOKit和CoreVideo框架作为依赖项添加到项目中。它们都可以在/ System / Library / Frameworks中找到。
像上面这样添加上面的框架:
g++ -o "TestProject" ./src/Main.o /Users/pixel/Documents/Library/libglfw3.a -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
至于在Eclipse Mars中添加编译器标志,我个人不使用Eclipse,但这是我找到的(来自here):
现在可以使用捆绑包的 build.properties 文件中的 compilerArg属性为每个捆绑包指定自定义编译器参数...