2011-09-26 18 views
4

プロジェクトをビルドするときに、未定義の参照がいくつか表示されています。ここでは、ビルドログです:OpenGL + GLEW + MinGWアプリケーションリンクの問題

**** Build of configuration Debug for project test **** 

**** Internal Builder is used for build    **** 
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\main.o ..\src\main.cpp 
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\test.o ..\src\test.cpp 
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\window.o ..\src\window.cpp 
..\src\window.cpp: In member function 'void Window::StartRenderContext()': 
..\src\window.cpp:150:24: warning: NULL used in arithmetic 
..\src\window.cpp:161:28: warning: NULL used in arithmetic 
..\src\window.cpp:174:24: warning: NULL used in arithmetic 
g++ -mwindows -l glew32 -l glew32s -l glu32 -l opengl32 -o test.exe src\window.o src\test.o src\main.o 
src\window.o: In function `ZN6Window18StartRenderContextEv': 
C:\eclipse\workspace\test\Debug/../src/window.cpp:101: undefined reference to `[email protected]' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:102: undefined reference to `[email protected]' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:115: undefined reference to `glewInit' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:125: undefined reference to `[email protected]' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:126: undefined reference to `[email protected]' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:148: undefined reference to `__wglewChoosePixelFormatARB' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:159: undefined reference to `__wglewChoosePixelFormatARB' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:185: undefined reference to `__wglewCreateContextAttribsARB' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:194: undefined reference to `__wglewCreateContextAttribsARB' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:204: undefined reference to `__wglewCreateContextAttribsARB' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:214: undefined reference to `__wglewCreateContextAttribsARB' 
C:\eclipse\workspace\test\Debug/../src/window.cpp:227: undefined reference to `[email protected]' 
collect2: ld returned 1 exit status 
Build error occurred, build is stopped 
Time consumed: 8128 ms. 

ここに私のリンクコマンドです:

g++ -mwindows -l glew32 -l glew32s -l glu32 -l opengl32 -o test.exe src\window.o src\test.o src\main.o 

は、この正しいですか?私はglewの64ビットバイナリを使用しています(私は32は何も意味しないと思います)。彼らはビジュアルスタジオで使用されることを意味していましたか?

は、ここに私のコードに含まれます:私は、Eclipse CDTインディゴ、MinGWの、Win32の、OpenGLの、およびGLEWを使用しています

#include "Windows.h" 
#include "GL/glew.h" 
#include "GL/wglew.h" 
#include "GL/gl.h" 
#include "GL/glu.h" 
#include "test.h" 

+0

なぜですかあなたは 'wglew.h 'を含んでいますか?なぜ 'glew.h 'をインクルードした後に' gl.h'をインクルードするのですか? – genpfault

+0

私はwglleを初期化するためにwglを使用しています。これはそのために必要な専用ライブラリです。 glとgluに関しては、関数呼び出しを解決することを期待していました。それはなかったので、私はそれらを削除しようとする可能性があります。 wglewも削除して、実際にこれらの問題を解決できるかどうかを確認しますが、わかりません。 – AutoBotAM

+0

申し訳ありませんが、includeを 'glew.h'と' wglew.h 'に絞り込みました。私も 'glew32s.lib'だけを含んでおり、' GLEW_STATIC'を定義しています未定義の参照と同じ!誰かがMinGWでEclipse Indigo CDT環境でglewアプリケーションを試してみたら、結果を投稿できますか? xD – AutoBotAM

答えて

1

"glew undefined reference"の問題を解決しました。

私の開発環境は、Windows 7(x64)でMinGWを使用したEclipse CDTです。

ソリューションは、以下の3つのステップである:

  1. は、ソースコードを追加します。#define GLEW_STATIC
  2. は、リンカフラグを追加します。-lglew32s -lopengl32 -lfreeglut
  3. フラグをコンパイル追加:gcc -DGLEW_STATIC

必要であれば、あなたは持っています-lglu32 -glut32などを追加します。