Difference between revisions of "Tutorial:Getting started: Compiling MSL with external libraries"
(→To compile GSL) |
|||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Certain functions of MSL require the installation of some open-source external libraries. | Certain functions of MSL require the installation of some open-source external libraries. | ||
+ | * '''GSL''' (GNU Scientific Library) [[http://www.gnu.org/software/gsl/]] | ||
* '''BOOST''' (portable C++ source libraries) [[http://www.boost.org]] | * '''BOOST''' (portable C++ source libraries) [[http://www.boost.org]] | ||
− | |||
* '''GLPK''' (GNU linear programming kit) [[http://www.gnu.org/software/glpk/]] | * '''GLPK''' (GNU linear programming kit) [[http://www.gnu.org/software/glpk/]] | ||
* '''R''' (R statistical and graphics project) [[http://www.r-project.org/]] | * '''R''' (R statistical and graphics project) [[http://www.r-project.org/]] | ||
+ | === What external libraries are really needed? === | ||
+ | Only '''GSL''' is currently recommended and turned on by default in the Makefile | ||
+ | |||
+ | The other external libraries are needed only to support particular object or applications. | ||
=== How to enable inclusion of the external libraries=== | === How to enable inclusion of the external libraries=== | ||
− | By default MSL | + | By default MSL '''requires the GSL''' library and will be compiled _without_ the support of the other external libraries and some functionality won't be available. To include the libraries, you need to set some environmental variables. |
If you use '''bash''', add the following lines to your .bashrc | If you use '''bash''', add the following lines to your .bashrc | ||
<source lang="bash"> | <source lang="bash"> | ||
− | # $MSL_GSL set to "T" if GSL is installed or else to "F" (default) | + | # $MSL_GSL set to "T" if GSL is installed or else to "F" (default is T) |
− | # $MSL_BOOST set to "T" if BOOST is installed or else to "F" (default) | + | # $MSL_BOOST set to "T" if BOOST is installed or else to "F" (default is F) |
− | # $MSL_GLPK set to "T" if GLPK is installed or else to "F" (default) | + | # $MSL_GLPK set to "T" if GLPK is installed or else to "F" (default is F) |
− | # $MSL_R set to "T" if R is installed or else to "F" (default) | + | # $MSL_R set to "T" if R is installed or else to "F" (default is F) |
export MSL_GSL=T | export MSL_GSL=T | ||
− | export MSL_GLPK= | + | export MSL_GLPK=F |
− | export MSL_BOOST= | + | export MSL_BOOST=F |
− | export MSL_R= | + | export MSL_R=F |
#export MSL_EXTERNAL_LIB_DIR=/usr/lib | #export MSL_EXTERNAL_LIB_DIR=/usr/lib | ||
#export MSL_EXTERNAL_INCLUDE_DIR=/usr/include | #export MSL_EXTERNAL_INCLUDE_DIR=/usr/include | ||
Line 45: | Line 49: | ||
</source> | </source> | ||
− | The default location of the libraries is '''/usr/lib'''. If you have installed them in a custom location set the $ | + | The default location of the libraries is '''/usr/lib'''. If you have installed them in a custom location (such as that used below, ~/software/mslib/ext_libs) set the $MSL_EXTERNAL_LIB_DIR environmental variable to the correct location. You will also want to set the $MSL_EXTERNAL_LIB_INCLUDE_DIR if using a custom location (such as that used below, ~/software/mslib/ext_includes). |
+ | |||
+ | === GSL === | ||
+ | Many functions of MSL depend on [[http://www.gnu.org/software/gsl/ GNU Scientific library (GSL)]], which is therefore highly recommended. | ||
+ | |||
+ | For example, GSL is required by the following objects: | ||
+ | * [[MSL_Objects:RandomNumberGenerator | RandomNumberGenerator]] | ||
+ | * [[MSL_Objects:GSLMinimizer | GSLMinimizer]] | ||
+ | * [[MSL_Objects:MonteCarloOptimization| MonteCarloOptimization]] | ||
+ | * [[MSL_Objects:CCD | CCD]] | ||
+ | * [[MSL_Objects:BackRub | BackRub]] | ||
+ | * [[MSL_Objects:Quench | Quench]] | ||
+ | * [[MSL_Objects:SurfaceAreaAndVolume | SurfaceAreaAndVolume]] | ||
+ | |||
+ | If '''GSL''' is enabled, you should see ''-D__GSL_'' in the compilation command when using make. | ||
+ | |||
+ | |||
+ | ====To compile GSL==== | ||
+ | GSL can be installed from the software repository (in Ubuntu, libgsl0-dev) or downloaded and installed from a tar file. For a more specific reference see the GSL homepage, but here is an example of the installation procedure: | ||
+ | |||
+ | >tar xzvf gsl-1.14.tar.gz | ||
+ | >cd gsl-1.14 | ||
+ | >./configure --prefix=/path/to/desired/directory | ||
+ | >make | ||
+ | >make check | ||
+ | >make install | ||
+ | >cp .libs/libgsl.a ~/software/mslib/ext_libs/ | ||
+ | >cp cblas/.libs/libgslcblas.a ~/software/mslib/ext_libs/ | ||
+ | |||
+ | # Note the -H, this should follow the symlinks, otherwise you get copies of links with relative paths and then you get errors making MSL that say gsl/gsl_rng.h not found, when you see it there! | ||
+ | > mkdir ~/software/mslib/ext_includes/gsl | ||
+ | > cp -H gsl/* ~/software/mslib/ext_includes/gsl | ||
=== BOOST === | === BOOST === | ||
− | The following libraries from the [http://www.boost.org/ Boost C++ Libraries] are used in some MSL objects and programs | + | The following libraries from the [http://www.boost.org/ Boost C++ Libraries] are used in some MSL objects and programs. In Ubuntu, it is available in the package libboost-all-dev. |
* Serialization, used for ... in the following objects | * Serialization, used for ... in the following objects | ||
** [[MSL_Objects:Atom|Atom]] | ** [[MSL_Objects:Atom|Atom]] | ||
Line 99: | Line 134: | ||
Assuming MSL library is installed in ~/software/mslib/. You will need to make the ext_includes and ext_libs directories before copying. | Assuming MSL library is installed in ~/software/mslib/. You will need to make the ext_includes and ext_libs directories before copying. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== GLPK === | === GLPK === | ||
Line 138: | Line 145: | ||
cp /usr/lib/libglpk.a MSLHOME/ext_libs/ | cp /usr/lib/libglpk.a MSLHOME/ext_libs/ | ||
cp /usr/include/glpk.h MSLHOME/ext_includes/ | cp /usr/include/glpk.h MSLHOME/ext_includes/ | ||
+ | |||
+ | '''NOTE: the current libglpk in Ubuntu appears to be incompatible with MSL''' | ||
=== R === | === R === | ||
− | The [http://www.r-project.org/ R project] is used by the getDihedrals program. | + | The [http://www.r-project.org/ R project] is used by the getDihedrals program. In Ubuntu the package is r-base. |
If '''R''' is enabled, you should see ''-D__R__'' in the compilation command when using make. | If '''R''' is enabled, you should see ''-D__R__'' in the compilation command when using make. | ||
Line 146: | Line 155: | ||
==== To Compile R ==== | ==== To Compile R ==== | ||
− | ===== MAC OS ===== | + | ===== Compiling R on MAC OS ===== |
Install R and copy headers into MSL_EXTERNAL_INCLUDE_DIR | Install R and copy headers into MSL_EXTERNAL_INCLUDE_DIR | ||
cp -r /Library/Frameworks/R.framework/Resources/include/ $MSL_EXTERNAL_INCLUDE_DIR | cp -r /Library/Frameworks/R.framework/Resources/include/ $MSL_EXTERNAL_INCLUDE_DIR | ||
Line 163: | Line 172: | ||
http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Quick-start | http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Quick-start | ||
− | ===== LINUX OS ===== | + | ===== Compiling R on LINUX OS ===== |
<font color="red">Success using shared libraries and compiling MSL as shared lib, but static lib has not been done yet. I will link my Makefile for shared-R compile once its cleaned up a bit</font> | <font color="red">Success using shared libraries and compiling MSL as shared lib, but static lib has not been done yet. I will link my Makefile for shared-R compile once its cleaned up a bit</font> | ||
Line 193: | Line 202: | ||
Copy headers into MSL_EXTERNAL_INCLUDE_DIR | Copy headers into MSL_EXTERNAL_INCLUDE_DIR | ||
cp -r /Library/Frameworks/R.framework/Resources/include/ $MSL_EXTERNAL_INCLUDE_DIR | cp -r /Library/Frameworks/R.framework/Resources/include/ $MSL_EXTERNAL_INCLUDE_DIR | ||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 19:42, 26 November 2013
Certain functions of MSL require the installation of some open-source external libraries.
- GSL (GNU Scientific Library) [[1]]
- BOOST (portable C++ source libraries) [[2]]
- GLPK (GNU linear programming kit) [[3]]
- R (R statistical and graphics project) [[4]]
Contents
What external libraries are really needed?
Only GSL is currently recommended and turned on by default in the Makefile
The other external libraries are needed only to support particular object or applications.
How to enable inclusion of the external libraries
By default MSL requires the GSL library and will be compiled _without_ the support of the other external libraries and some functionality won't be available. To include the libraries, you need to set some environmental variables.
If you use bash, add the following lines to your .bashrc
# $MSL_GSL set to "T" if GSL is installed or else to "F" (default is T)
# $MSL_BOOST set to "T" if BOOST is installed or else to "F" (default is F)
# $MSL_GLPK set to "T" if GLPK is installed or else to "F" (default is F)
# $MSL_R set to "T" if R is installed or else to "F" (default is F)
export MSL_GSL=T
export MSL_GLPK=F
export MSL_BOOST=F
export MSL_R=F
#export MSL_EXTERNAL_LIB_DIR=/usr/lib
#export MSL_EXTERNAL_INCLUDE_DIR=/usr/include
#export MSL_MACOS=T
#export MSL_DEBUG=F
#export MSL_DIR=$HOME/software/mslib
If you use tcsh, add the following lines to your .cshrc
# $MSL_GSL set to "T" if GSL is installed or else to "F" (default)
# $MSL_BOOST set to "T" if BOOST is installed or else to "F" (default)
# $MSL_GLPK set to "T" if GLPK is installed or else to "F" (default)
# $MSL_R set to "T" if R is installed or else to "F" (default)
setenv MSL_GSL T
setenv MSL_GLPK T
setenv MSL_BOOST T
setenv MSL_R T
#setenv MSL_EXTERNAL_LIB_DIR /usr/lib
#setenv MSL_EXTERNAL_INCLUDE_DIR /usr/include
The default location of the libraries is /usr/lib. If you have installed them in a custom location (such as that used below, ~/software/mslib/ext_libs) set the $MSL_EXTERNAL_LIB_DIR environmental variable to the correct location. You will also want to set the $MSL_EXTERNAL_LIB_INCLUDE_DIR if using a custom location (such as that used below, ~/software/mslib/ext_includes).
GSL
Many functions of MSL depend on [GNU Scientific library (GSL)], which is therefore highly recommended.
For example, GSL is required by the following objects:
If GSL is enabled, you should see -D__GSL_ in the compilation command when using make.
To compile GSL
GSL can be installed from the software repository (in Ubuntu, libgsl0-dev) or downloaded and installed from a tar file. For a more specific reference see the GSL homepage, but here is an example of the installation procedure:
>tar xzvf gsl-1.14.tar.gz >cd gsl-1.14 >./configure --prefix=/path/to/desired/directory >make >make check >make install >cp .libs/libgsl.a ~/software/mslib/ext_libs/ >cp cblas/.libs/libgslcblas.a ~/software/mslib/ext_libs/
- Note the -H, this should follow the symlinks, otherwise you get copies of links with relative paths and then you get errors making MSL that say gsl/gsl_rng.h not found, when you see it there!
> mkdir ~/software/mslib/ext_includes/gsl > cp -H gsl/* ~/software/mslib/ext_includes/gsl
BOOST
The following libraries from the Boost C++ Libraries are used in some MSL objects and programs. In Ubuntu, it is available in the package libboost-all-dev.
- Serialization, used for ... in the following objects
- Archive, used for ... in the following objects
- Random, used for ... in the following objects
Note: if boost is included, version 1.40 (???) or later is required.
If BOOST is enabled, you should see -D__BOOST__ -DBOOST_DISABLE_THREADS in the compilation command when using make.
To Compile BOOST
>tar xzvf boost-VERSION.tar.gz >cd boost-VERSION >./bootstrap.sh --prefix=~/software/mslib/ext_libs >./b2 > cp ./stage/lib/libboost_*.a ~/software/mslib/ext_libs > cp -r boost ~/software/mslib/ext_includes/
Assuming MSL library is installed in ~/software/mslib/. You will need to make the ext_includes and ext_libs directories before copying.
GLPK
The GNU linear programming kit is required by the LinearProgrammingOptimization object.
If GLPK is enabled, you should see -D__GLPK__ in the compilation command when using make.
./configure --prefix=/usr/lib --disable-dl --disable-odbc --disable-mysql --enable-static --without-gmp --without-zlib make make install cp /usr/lib/libglpk.a MSLHOME/ext_libs/ cp /usr/include/glpk.h MSLHOME/ext_includes/
NOTE: the current libglpk in Ubuntu appears to be incompatible with MSL
R
The R project is used by the getDihedrals program. In Ubuntu the package is r-base.
If R is enabled, you should see -D__R__ in the compilation command when using make.
To Compile R
Compiling R on MAC OS
Install R and copy headers into MSL_EXTERNAL_INCLUDE_DIR
cp -r /Library/Frameworks/R.framework/Resources/include/ $MSL_EXTERNAL_INCLUDE_DIR
Download Rcpp
R CMD INSTALL Rcpp_0.8.5.tar.gz cp /Library/Frameworks/R.framework/Resources/library/Rcpp/lib/x86_64/libRcpp.a $MSL_EXTERNAL_LIB_DIR/ cp -r /Library/Frameworks/R.framework/Resources/library/Rcpp/include $MSL_EXTERNAL_INCLUDE_DIR/
R CMD INSTALL RInside_0.2.3.tar.gz cp /Library/Frameworks/R.framework/Resources/library/RInside/lib/x86_64/libRInside.a $MSL_EXTERNAL_LIB_DIR/ cp -r /Library/Frameworks/R.framework/Resources/library/RInside/include $MSL_EXTERNAL_INCLUDE_DIR/
If the above install does not work, one can install from source here is a good resource:
http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Quick-start
Compiling R on LINUX OS
Success using shared libraries and compiling MSL as shared lib, but static lib has not been done yet. I will link my Makefile for shared-R compile once its cleaned up a bit
First try using the 'apt' system in linux:
sudo apt-get install r-base
If the 'apt' version is not the latest version that you need, then install latest version of R:
sudo apt-get build-dep r-base tar xvzf R-2.11.1.tar.gz cd R-2.11.1 ./configure make sudo make install
Install Rcpp:
sudo /usr/local/bin/R CMD INSTALL Rcpp_0.8.5.tar.gz cp /Library/Frameworks/R.framework/Resources/library/Rcpp/lib/x86_64/libRcpp.a $MSL_EXTERNAL_LIB_DIR/ cp -r /Library/Frameworks/R.framework/Resources/library/Rcpp/include $MSL_EXTERNAL_INCLUDE_DIR/
Install RInside:
R CMD INSTALL RInside_0.2.3.tar.gz
cp /Library/Frameworks/R.framework/Resources/library/RInside/lib/x86_64/libRInside.a $MSL_EXTERNAL_LIB_DIR/ cp -r /Library/Frameworks/R.framework/Resources/library/RInside/include $MSL_EXTERNAL_INCLUDE_DIR/
Copy headers into MSL_EXTERNAL_INCLUDE_DIR
cp -r /Library/Frameworks/R.framework/Resources/include/ $MSL_EXTERNAL_INCLUDE_DIR