From The Player Project
Some developers (myself included) prefer to install applications in our user directory (e.g., /home/[username]/local) rather than in a system directory; this avoids screwing up other users of the machine if you have some funky experimental code you want to work with. It's also useful if you don't have root access.
Naturally, local installs can make it a bit tricky for the various packages to find the right headers, libs and so on. Historically, we have worked around this by specifying "--with-foo=path" arguments to the configure scripts; unfortunately, this method is fraught with danger and is now being phased out. Here, then, is the recommended way to do it:
- Pick a spot for "local" installs; for me it is "/home/ahoward/local". The install scripts will create relevant subdirs under this, such as:
- Set up the necessary compiler paths in your .bashrc, .bash_profile, or other shell configuration file if you're not using bash; e.g.:
$ export PATH=~/local/bin:$PATH $ export CPATH=~/local/include:$CPATH $ export LD_LIBRARY_PATH=~/local/lib:$LIBRARY_PATH
The first line sets the executable path; the second sets the path for C and C++ header files; the third line sets the library search path.
NOTE: The ~ character is a shortcut for your user's home directory; in this example it expands to /home/ahoward
- Set up some additional paths in your .bashrc, .bash_profile, or other shell configuration file if you're not using bash
$ export PKG_CONFIG_PATH=~/local/lib/pkgconfig:$PKG_CONFIG_PATH $ export PYTHONPATH=~/local/lib/python2.2/site-packages:$PYTHONPATH
The first line sets the pkg-config path (for applications using pkg-config, which will be everything in the P/S/G project pretty soon); the second line is for Python modules (e.g. Python bindings to the libplayerc client lib).
- Check to see if you have set CFLAGS or LDFLAGS:
$ env | grep CFLAGS $ env | grep LDFLAGS
These variables can change how the compiler and linker behave. If either one is set, and if it points to a place where there is another installation of Player/Stage/Gazebo/librtk (e.g., LDFLAGS="-L/usr/local/lib", CFLAGS="-I/usr/local/include"), then you must unset it:
$ unset LDFLAGS $ unset CFLAGS
Note that if these variables are set to something that doesn't change the compiler/linker paths (e.g., CFLAGS="-g -Wall") then you can leave them alone.
- Build applications using the "-DCMAKE_INSTALL_PREFIX" argument; e.g.;
$ cmake -DCMAKE_INSTALL_PREFIX=/home/ahoward/local . $ make install
Everything should now build seamlessly without any additional frigging around, and your locally installed packages will be used in preference to any system-wide installs.
If you have a system-wide installation you want to use, you will need to unset the LD_LIBRARY_PATH, and manually specify the executable path when running the program, e.g. '/usr/bin/player'