views:

91

answers:

1

Hi,

My Home directory is shared among several linux computers via Network File System. I would like to install some C C++ library from source under my Home directory, and wish they can be used under all the linux computers.

Do I have to install different versions of the library under different directories of my Home for different computer?

Assuming I have a C C++ program that calls these libraries, how do I specify different include and link files and directories for different computer in Makefile? Is it to determine the directories based on the hostname of the computer?

Is it possible to combine the different versions of the .a and .so files and header files of the libary for different linux computers so that the include and link files and directories of the libary are the same for all the computers and I don't have to specify different directories for different computer in the Makefile of my C C++ program?

Thanks and regards!

A: 

This is easy and common.

By C C++ I assume you mean you have libraries compiled with a C compiler, and those compiled with a C++ compiler.

If the version of the compiler you are using is the same, then you do not need different libraries for each version. If they are different it may still be possible to use the same C libraries, but C++ becomes more problematic.

If the files are in your home directory, the easiest thing to do in your Makefile is make all of the paths relative to $HOME. This environment variable should be set correctly on each system.

If you need to reference different libraries on the different machines, the most straightforward way would be to put them in a directory with the same name as the hostname. Something like this:

CXXFLAGS=-I$(HOME)/app/$(HOST)/include

You could do something more fancy by extracting the gcc version number and using that, but its probably overkill for just a couple of machines.

KeithB
Thanks!The gcc versions are different for the two machines. For the first one, it is gcc/g++ 3.4.6 20060404 (Red Hat 3.4.6-10); for the second one, it is gcc/g++ (Ubuntu 4.3.2-1ubuntu12) 4.3.2.The first machine is CentOS release 4.7 (Final) and x86_64, and the second one Ubuntu 8.10 and x86_64.If I have to install the library in different directories, how to specify them for different machines in Makefile?Thanks
Tim