2012-02-17 164 views
3

我想在項目上使用GLFW,但是當我編譯它時,我得到了很多未定義的引用錯誤,而其中很多都是在庫文件(libglfw.a)上。 我試了兩個,編譯庫並下載它,但沒有成功。 我使用的是在Netbeans上運行Windows 7 32位的MinGW和MSYS。 GLFW版本是2.7.3;GLFW未定義的引用

這些都是錯誤的:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf 
make[1]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism' 
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/prism.exe 
make[2]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism' 
mkdir -p build/Debug/MinGW-Windows 
rm -f build/Debug/MinGW-Windows/main.o.d 
g++.exe -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp 
mkdir -p dist/Debug/MinGW-Windows 
g++.exe  -o dist/Debug/MinGW-Windows/prism build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/ByteBuffer.o -Lexternal -lglfw 
build/Debug/MinGW-Windows/main.o: In function `main': 
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:35: undefined reference to `[email protected]' 
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:36: undefined reference to `[email protected]' 
build/Debug/MinGW-Windows/main.o: In function `Z6renderv': 
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:56: undefined reference to `[email protected]' 
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:57: undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(window.o):window.c:(.text+0x8ae): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe54): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe6c): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xef6): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf4f): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf7f): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x174c): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1935): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x19fe): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1a0e): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ea6): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ebc): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ed8): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ee7): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1f1a): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1a): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1bf): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1ef): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x28b): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x2cf): undefined reference to `[email protected]' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_glext.o):win32_glext.c:(.text+0x7d): undefined reference to `[email protected][2]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism' 
make[1]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism' 
' 
collect2: ld returned 1 exit status 
make[2]: *** [dist/Debug/MinGW-Windows/prism.exe] Error 1 
make[1]: *** [.build-conf] Error 2 
make: *** [.build-impl] Error 2 

CONSTRUIR FALHOU (valor da saída 2, tempo total: 1s) 
+0

@ildjarn我認爲沒關係 – 2012-02-17 22:32:35

+3

你不需要鏈接OpenGL庫嗎?我沒有看到'libGL'或'libGLU'。我知道'glClear'在'libGL'或'libGLU'中。作爲答案發布,因爲我95%確定這是問題... – JimR 2012-02-17 22:39:11

回答

10

難道你要了OpenGL庫鏈接呢?我沒有看到libGLlibGLU。我知道glClearlibGLlibGLU

+7

那麼,因爲這被接受爲答案,哪一個呢? – Ludwik 2014-04-20 21:06:31

6

在連接器,在Windows中,MinGW的:-lglew32 -lglfw3 -lopengl32 -lglu32 -lgdi32

把庫和包括MinGW的文件和DLL和EXE文件在Windows系統文件夾。

5

在我的情況下,問題是不同的。我正在連接opengl32,但仍然出現錯誤。問題原來是圖書館訂單:glfw必須鏈接之前 opengl32

在我的情況下,這是在Code :: Blocks IDE中的「鏈接庫」列表框中,但它在NetBeans或命令行上會類似。