LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Trying to get Mesa3D graphics lib to work (https://www.linuxquestions.org/questions/programming-9/trying-to-get-mesa3d-graphics-lib-to-work-203559/)

fatherg 07-10-2004 08:37 PM

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.

The_Nerd 07-11-2004 01:46 AM

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!

fatherg 07-11-2004 02:36 PM

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.

johnMG 07-11-2004 05:16 PM

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
.

fatherg 07-12-2004 01:23 AM

doh!

fatherg 07-12-2004 01:29 AM

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

compiled fine, but I can't execute it.


All times are GMT -5. The time now is 02:35 AM.