LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-10-2004, 08:37 PM   #1
fatherg
Member
 
Registered: Mar 2004
Posts: 55

Rep: Reputation: 15
Trying to get Mesa3D graphics lib to work


Hi, I am running Red Hat 9 on a Celeron 2.8 Ghz w/ 768MB of RAM, and an NVIDIA GeForce FX 5900 SE w/ 128MB. I don't think that I've installed the Mesa 3D Lib correctly. I typed 'make linux-x86' and with what I've read thats supposed to install it... I'm also using SDL.

The progam I'm currently writing is one that draws a triangle with 3 different colored vertexes. (The 'hello world' of Open GL progs). Every gl function I call is 'undefined' in my g++ error messages.

Here are my errors:

g++ glInit.cpp -o glInit `sdl-config --cflags --libs` -I/usr/X11R6/include -L/usr/X11R6/lib

/tmp/ccdVNC81.o(.text+0xec): In function `main':
: undefined reference to `glViewport'
/tmp/ccdVNC81.o(.text+0xfc): In function `main':
: undefined reference to `glMatrixMode'
/tmp/ccdVNC81.o(.text+0x104): In function `main':
: undefined reference to `glLoadIdentity'
/tmp/ccdVNC81.o(.text+0x133): In function `main':
: undefined reference to `glFrustum'
/tmp/ccdVNC81.o(.text+0x143): In function `main':
: undefined reference to `glClearColor'
/tmp/ccdVNC81.o(.text+0x153): In function `main':
: undefined reference to `glMatrixMode'
/tmp/ccdVNC81.o(.text+0x15b): In function `main':
: undefined reference to `glLoadIdentity'
/tmp/ccdVNC81.o(.text+0x168): In function `main':
: undefined reference to `glClear'
/tmp/ccdVNC81.o(.text+0x175): In function `main':
: undefined reference to `glBegin'
/tmp/ccdVNC81.o(.text+0x189): In function `main':
: undefined reference to `glColor3f'
/tmp/ccdVNC81.o(.text+0x1a0): In function `main':
: undefined reference to `glVertex3f'
/tmp/ccdVNC81.o(.text+0x1b4): In function `main':
: undefined reference to `glColor3f'
/tmp/ccdVNC81.o(.text+0x1ce): In function `main':
: undefined reference to `glVertex3f'
/tmp/ccdVNC81.o(.text+0x1e2): In function `main':
: undefined reference to `glColor3f'
/tmp/ccdVNC81.o(.text+0x1fc): In function `main':
: undefined reference to `glVertex3f'
/tmp/ccdVNC81.o(.text+0x204): In function `main':
: undefined reference to `glEnd'
/tmp/ccdVNC81.o(.text+0x209): In function `main':
: undefined reference to `glFlush'
collect2: ld returned 1 exit status

here is my src:

//glInit.cpp
#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>

int main()
{
int i;

if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
printf("Error %s\n", SDL_GetError());
return 1;
}

atexit(SDL_Quit);

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 6);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);

if(SDL_SetVideoMode(640, 480, 16, SDL_OPENGL) == NULL)
{
printf("Error: %s\n", SDL_GetError());
return 1;
}

SDL_WM_SetCaption("OpenGL with SDL!", "OpenGL");

glViewport(80, 0, 480, 480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0);
glClearColor(0, 0, 0, 0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(1.0, 0, 0);
glVertex3f(0.0, 1.0, -2.0);
glColor3f(0, 1.0, 0);
glVertex3f(1.0, -1.0, -2.0);
glColor3f(0, 0, 1.0);
glVertex3f(-1.0, -1.0, -2.0);
glEnd();
glFlush();

SDL_GL_SwapBuffers();

SDL_Delay(5000);
return 0;
}

I've also tried cp 'ing the contents of Mesa-6.0/include/GL/ directory to /usr/include/GL
as well as Mesa-6.0/lib/ to /usr/lib/libGL/ . . . any suggestions? By the way I'm sort of a linux noob, but I do have a little experience with writing SDL progs in gcc.
 
Old 07-11-2004, 01:46 AM   #2
The_Nerd
Member
 
Registered: Aug 2002
Distribution: Debian
Posts: 540

Rep: Reputation: 32
try linking the OpenGL library. Example:

g++ -O3 -o OpenGLProg OpenGLProg.cpp -lGL -lGLU `sdl-config --cflags --libs`

That should do it!

Btw! Congrats on using SDL! You rock!
 
Old 07-11-2004, 02:36 PM   #3
fatherg
Member
 
Registered: Mar 2004
Posts: 55

Original Poster
Rep: Reputation: 15
I just tried to compile:
$ g++ -O3 -o glInit glInit.cpp -|GL -|GLU `sdl-config --cflags --libs`
bash: GL: command not found
bash: GLU: command not found
g++: -E required when input is from standard input

How can I tell if I've installed Mesa3D lib correctly? I think it may be the problem.
 
Old 07-11-2004, 05:16 PM   #4
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 31
Code:
$ g++ -O3 -o glInit glInit.cpp -|GL -|GLU `sdl-config --cflags --libs`
bash: GL: command not found
bash: GLU: command not found
g++: -E required when input is from standard input
You're mistakenly typing
Code:
-|
instead of
Code:
-l
.
 
Old 07-12-2004, 01:23 AM   #5
fatherg
Member
 
Registered: Mar 2004
Posts: 55

Original Poster
Rep: Reputation: 15
doh!
 
Old 07-12-2004, 01:29 AM   #6
fatherg
Member
 
Registered: Mar 2004
Posts: 55

Original Poster
Rep: Reputation: 15
[fatherg@localhost gl]$ sh compile
[fatherg@localhost gl]$ ./glInit
Error: Couldn't find matching GLX visual

compiled fine, but I can't execute it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mplayer's /usr/local/lib/codecs work... but what of ffmpeg? babyphil Slackware 1 09-06-2005 02:49 AM
More trouble with Mesa3d fatherg Programming 0 07-13-2004 04:36 PM
Mesa3d removal jfrey Linux - Software 0 05-24-2003 12:38 AM
Mesa3d didnt install properly kwigibo Linux - Software 3 05-08-2003 08:39 AM
Mesa3D HELP??? greay Linux - General 1 05-31-2001 07:15 AM


All times are GMT -5. The time now is 09:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration