Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to use GLEW and XServer / X11 in a C++ app as instructed in Chapter 15 of the OpenGL Superbible, 5th ed.

I'm using this Makefile:

LIBDIRS = -L/usr/X11R6/lib -L/usr/X11R6/lib64 -L/usr/local/lib
INCDIRS = -I/usr/include -L/usr/include 

CC = g++
CFLAGS = $(COMPILERFLAGS) -g $(INCDIRS)
LIBS = -lX11 -lXi -lXmu -lm -lGLEW -lGLU -lGL

GLXBasics: GLXBasics.o
        $(CC) $(CFLAGS) -o GLXBasics $(LIBDIRS) GLXBasics.cpp $(LIBS)

clean:
        rm -f *.o

and getting this result:

GLXBasics.cpp:4:18: fatal error: glew.h: No such file or directory

[EDIT:] After fixing a silly coding error, I now have trouble with X11, and my GLEW issues are history.

/usr/bin/ld: cannot find -lXi
/usr/bin/ld: cannot find -lXmu

[/EDIT]

If I comment out the inclusion of glew.h, it fails on the inclusion of glxew.h.

I have sudo-copied and pasted glew.h and glxew.h to /usr/include/GL. (Which is where I believe they're supposed to be?)

Forgive me in case I forgot to include something in my question - anything you'd like to know or see from my terminal just ask.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

GLXBasics.cpp:4:18: fatal error: glew.h: No such file or directory

I guess you have a line there with something like the line below?

#include <glew.h>

Change that to

#include <GL/glew.h>

This is required, as you've copied it into the GL/ subdirectory of the search paths specified in your INCDIRS.


I have sudo-copied and pasted glew.h and glxew.h to /usr/include/GL

I would recommend using /usr/local/include/GL as that will avoid conflicts with Ubuntu packages.

I now have trouble with X11, and my GLEW issues are history.

/usr/bin/ld: cannot find -lXi
/usr/bin/ld: cannot find -lXmu

because they are in /usr/local/include?

This error is is about the libraries (binaries), not about the headers. In case you install them manually, you should place them in /usr/local/lib instead of include/ (that's for header files). Or perhaps you're just missing the X development packages here? Please ask this in a new question if this has nothing to do with your header files.

Don't forget to update your INCDIR and LIBDIR to include the new /usr/local/include directories, e.g.:

INCDIRS = -I/usr/include -L/usr/include -I/usr/local/include -L/usr/local/include 
share|improve this answer
    
@mynameisnafe Please edit your question to provide more details. That is how this site works - comments aren't fit for that. –  gertvdijk Jun 25 '13 at 12:20
    
Ackowlnedged.. this is literally my first question! –  mynameisnafe Jun 25 '13 at 12:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.