Xi library?

In my Makefile I have the following:

objects = main.o Asteroid.o Bullet.o Projectile.o Ship.o
asteroids: $(objects)
g++ -o asteroids $(objects) -lX11 -lXi -lglut -lGL -lGLU -lm

I got the library switches from the OpenGL SuperBible. I was wondering what the -lXi switch is for because I tried the same program on my laptop and the -lXi switch is not recognized?

thanks,
mike

Install the libXi and libXi-devel packages on your laptop.

On UNIX/Linux, -l<library> is the standard way to tell the compiler/linker to link an executable or shared library with the specified library.

Generally speaking, -lFOO tells he compiler to go look for a library libFOO.so or libFOO.a. Where it looks by default for this library is based on whether you’re compiling on a 32-bit machine (/usr/lib) or 64-bit machine (/usr/lib64). Other directories may be searched as well.

On your laptop, you most likely don’t have the libXi binary and development (headers) packages installed. For instance, here on OpenSuSE 12.2:


> rpm -qa | grep Xi
libXinerama1-1.1.2-2.1.2.x86_64
libXinerama-devel-1.1.2-2.1.2.x86_64
libXi-devel-1.6.1-2.1.2.x86_64
libXi6-1.6.1-2.1.2.x86_64

>rpm -ql libXi6
/usr/lib64/libXi.so.6
/usr/lib64/libXi.so.6.1.0

Here the name of my Xi packages are “libXi6” and “libXi-devel”.

So if I specify -lXi on the linker line, that says to go look for the libXi.so.* library, which the linker will find in /usr/lib64.
Could have put /usr/lib64/libXi.so.6 on the linker line instead, but that’s needless verbosity and doesn’t support cross-architecture compiles nor having the library installed someplace else on the system.