# Cannot find -lX11

This topic is 4883 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I've finally gotten my new computer set up (AMD 64 3000+ and NVIDIA 5200) with SuSE 9.1 Pro. I'm trying to run NeHe's first lesson (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01 , Linux code by Richard Campbell). However, I receive the following error message when I run the makefile: ct@linux:~/lesson01> make lesson1 gcc -Wall -I/usr/include/ -o lesson1 -L/usr/X11R6/lib lesson1.o -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lX11 collect2: ld returned 1 exit status make: *** [lesson1] Error 1 This confuses me because I have the correct libraries in /usr/X11R6/lib. Specifically, libX11.so.6 and libX11.so.6.2. I also have the following Mesa packages installed: XFree86-Mesa, XFree86-Mesa-32bit, XFree86-Mesa-devel, and XFree86-devel-32bit. And addition to that, I have freeglut, freeglut-32bit and freeglut-devel. Anyone have any ideas? I'd really appreciate any help. Lots of thanks, CT

##### Share on other sites
The compiler can't find libX11 because it doesn't look in /usr/X11R6/lib . The -L flag followed by a directory, will make gcc look in that directory for libraries.

##### Share on other sites

* * * * * * * * *

INCLUDE = -I/usr/include/
LIBDIR = -L/usr/X11R6/lib

COMPILERFLAGS = -Wall
CC = gcc
CFLAGS = $(COMPILERFLAGS)$(INCLUDE)
LIBRARIES = -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm

...

lesson% : lesson%.o
$(CC)$(CFLAGS) -o $@$(LIBDIR) $<$(LIBRARIES)

* * * * * * * * *

And the command producing the error is:
gcc -Wall -I/usr/include/ -o lesson1 -L/usr/X11R6/lib lesson1.o -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm

* * * * * * * * *

So I'm thinking it should know where the /usr/X11R6/lib directory is right? Maybe I'm just a bit confused or something.

Thanks again,
CT

##### Share on other sites
Ahhh, just figured it out. I had to do -L/usr/X11R6/lib64 instead of -L/usr/X11R6/lib. Whew. Thanks again for your help.