Access libraries in C++

Hi,

I've a C++ project that uses cairo graphics libraries (see cairographics.org).

In my class I do
#include <cairo.h>

If I must install the cairo graphics program, I must be root. What I want is that this library only be acessed by this project. Talking in Java language, I would love that cairo library would be a jar, that will be acessed in my project. How can this be possible in C++ world?

Thanks,
Pedro

I don't know if I was explicit. What I want is to access cairo library without have to install it. In the java world, jars are used. In C++, how is it?

After you install the Cairo package, the header files and the libraries files i.e. *.so (unix equivalent of dll) will be available. You would use the API's mentioned in the header files and you would need these library files to compile.

Another way would be to load the .so dynamically using dlopen, dlsym and dlclose calls. But this would be so much of an overhead.

To use the library it must be installed. However, you can install it in your home directory rather than under /usr and build your code with appropriate flags to tell the compiler where your headers are (e.g -I/path/to/your/headers) and the linker where the libraries are (e.g. -L/path/to/your/libs).
The details of how to install to a non-default location will depend on how the library is packaged (e.g. source tarball, RPM package, etc) and which one you want to use.