Я пытаюсь изучить opengl, используя glfw, но продолжаю получать неопределенные справочные ошибки, я пытаюсь скомпилировать этот простой код для целей тестирования:
#include <GLFW/glfw3.h>
int main(void)
{
if (!glfwInit())
return -1;
glfwTerminate();
return 0;
}
У меня есть тест файлов. cpp ( исходный файл) и libglfw3.a (загруженный с веб-сайта glfw ) в той же папке, в то время как GLFW / glfw3.h находится в том же файле, что и другие заголовки c ++, такие как iostream, vector, et c ...
Я могу просто сгенерировать файл .o:
g++ -c test.cpp
И это дает мне test.o, но когда я пытаюсь связать его с такими библиотеками:
g++ test.o libglfw3.a -lopengl32 -o test.exe
Я получаю следующие ошибки:
test.o:test.cpp:(.text+0xe): undefined reference to `glfwInit'
test.o:test.cpp:(.text+0x23): undefined reference to `glfwTerminate'
collect2.exe: error: ld returned 1 exit status
С чем еще я должен связывать эти файлы? что-то не так с моим кодом, чего мне здесь не хватает?
Редактировать: Хорошо, теперь я попытался использовать 64-битные предварительно скомпилированные двоичные файлы вместо 32-битных, и теперь я получаю это:
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
Warning: corrupt .drectve at end of def file
glfw3.lib(glfw.dir/Release/init.obj):(.text$mn+0x73): undefined reference to `__imp___stdio_common_vsprintf'
glfw3.lib(glfw.dir/Release/init.obj):(.text$mn+0x327): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/init.obj):(.xdata[$unwind$_glfwInputError]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.text$mn+0x196): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.text$mn+0x82): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.text$mn+0x91): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.text$mn+0x9b): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.text$mn+0x206): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.text$mn+0x45): more undefined references to `__security_check_cookie' follow
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.xdata[$unwind$_glfwPollMonitorsWin32]+0x20): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.xdata[$unwind$_glfwSetVideoModeWin32]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.xdata[$unwind$_glfwPlatformGetMonitorPos]+0x14): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.xdata[$unwind$_glfwPlatformGetMonitorWorkarea]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.xdata[$unwind$_glfwPlatformGetVideoModes]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_monitor.obj):(.xdata[$unwind$_glfwPlatformGetVideoMode]+0x14): more undefined references to `__GSHandlerCheck' follow
glfw3.lib(glfw.dir/Release/win32_init.obj):(.text$mn+0xe7): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.text$mn+0x97): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.text$mn+0xbc): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.text$mn+0x3bc): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.text$mn+0x1d2): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.text$mn+0x48): more undefined references to `__security_check_cookie' follow
glfw3.lib(glfw.dir/Release/win32_init.obj):(.xdata[$unwind$_glfwIsWindowsVersionOrGreaterWin32]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.xdata[$unwind$_glfwIsWindows10BuildOrGreaterWin32]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.xdata[$unwind$_glfwInputErrorWin32]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.xdata[$unwind$_glfwUpdateKeyNamesWin32]+0x20): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.xdata[$unwind$_glfwPlatformInit]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_init.obj):(.xdata[$unwind$loadLibraries]+0x8): more undefined references to `__GSHandlerCheck' follow
glfw3.lib(glfw.dir/Release/window.obj):(.text$mn+0x29e): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/window.obj):(.xdata[$unwind$glfwCreateWindow]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/input.obj):(.text$mn+0x286): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/input.obj):(.text$mn+0x794): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/input.obj):(.xdata[$unwind$glfwUpdateGamepadMappings]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/input.obj):(.xdata[$unwind$parseMapping]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/context.obj):(.text$mn+0x594): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/context.obj):(.xdata[$unwind$_glfwRefreshContextAttribs]+0x18): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/egl_context.obj):(.text$mn+0x4b7): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/egl_context.obj):(.text$mn+0x49): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/egl_context.obj):(.text$mn+0x534): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/egl_context.obj):(.xdata[$unwind$_glfwInitEGL]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/egl_context.obj):(.xdata[$unwind$_glfwCreateContextEGL]+0x18): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.text$mn+0x447): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.text$mn+0x2d): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.text$mn+0x6c): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.text$mn+0x3a3): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.text$mn+0x77f): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.xdata[$unwind$_glfwInitWGL]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.xdata[$unwind$_glfwCreateContextWGL]+0x14): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/wgl_context.obj):(.xdata[$unwind$choosePixelFormat]+0x10): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.text$mn+0x50): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.text$mn+0x1a7): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.text$mn+0x50): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.text$mn+0x225): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.text$mn+0x84): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.text$mn+0x3ee): more undefined references to `__security_check_cookie' follow
glfw3.lib(glfw.dir/Release/win32_window.obj):(.xdata[$unwind$_glfwPlatformSetWindowPos]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.xdata[$unwind$_glfwPlatformGetWindowSize]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.xdata[$unwind$_glfwPlatformSetWindowSize]+0x8): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.xdata[$unwind$_glfwPlatformSetWindowSizeLimits]+0x8): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.xdata[$unwind$_glfwPlatformSetWindowAspectRatio]+0x8): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_window.obj):(.xdata[$unwind$_glfwPlatformGetFramebufferSize]+0xc): more undefined references to `__GSHandlerCheck' follow
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.text$mn+0x1d3): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.text$mn+0x10e): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.text$mn+0x233): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.text$mn+0x38e): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.text$mn+0x60): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.text$mn+0x518): more undefined references to `__security_check_cookie' follow
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.xdata[$unwind$_glfwInitJoysticksWin32]+0x8): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.xdata[$unwind$_glfwDetectJoystickConnectionWin32]+0x8): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.xdata[$unwind$_glfwDetectJoystickDisconnectionWin32]+0x14): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.xdata[$unwind$_glfwPlatformPollJoystick]+0x28): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.xdata[$unwind$_glfwPlatformUpdateGamepadGUID]+0x8): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/win32_joystick.obj):(.xdata[$unwind$deviceObjectCallback]+0x10): more undefined references to `__GSHandlerCheck' follow
glfw3.lib(glfw.dir/Release/osmesa_context.obj):(.text$mn+0x21b): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/osmesa_context.obj):(.text$mn+0x4c): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/osmesa_context.obj):(.text$mn+0x1cd): undefined reference to `__security_check_cookie'
glfw3.lib(glfw.dir/Release/osmesa_context.obj):(.xdata[$unwind$_glfwInitOSMesa]+0xc): undefined reference to `__GSHandlerCheck'
glfw3.lib(glfw.dir/Release/osmesa_context.obj):(.xdata[$unwind$_glfwCreateContextOSMesa]+0x10): undefined reference to `__GSHandlerCheck'
collect2.exe: error: ld returned 1 exit status
Я имею в виду, что я делаю прогресс, потому что теперь функции определены, все, что они используют, отсутствует. Все еще не означает, что использование 64-битных библиотек означает, что файл .exe не будет работать в 32-битной системе? Во всяком случае, я собираюсь выяснить, что все эти ошибки / предупреждения, но если кто-то знает, что они означают, я был бы очень рад, если бы вы могли сказать мне.