我正在編譯一個在ubuntu(linux)中使用opengl的示例程序。代碼的一小片段如下:當我在c中編譯程序時,爲什麼會得到一個未定義的引用(例如`glColor3f')?
#include <stdlib.h>
#include <GL/glut.h>
void createBox(GLfloat centroX, GLfloat centroY,
GLfloat corR, GLfloat corG, GLfloat corB)
{
/* Cor */
glColor3f(corR, corG, corB);
我已經安裝了所有的包在OpenGL(在Ubuntu)制定,即:
freeglut3 freeglut3-dev libglew1.5 libglew1.5-dev libglu1-mesa
libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev
我編譯這樣的例子:
gcc -lGL CG_ex04.c -o main
,我得到以下
/tmp/ccDWmJDZ.o: In function `createBox':
CG_ex04.c:(.text+0x31): undefined reference to `glColor3f'
和其他錯誤沿同一行。
有誰知道我在做什麼錯?
Thanx提前尋求幫助。
這與你的編譯器有關,而不是你使用的庫。請刪除opengl和glut標籤:-) – 2010-11-14 19:17:02
修復標籤和標題。請記住,下次您發佈問題時。標籤意味着*與您的問題*相關,不能僅僅因爲您的程序使用特定的API而使用。 – 2010-11-17 15:19:54