This tutorial demonstrates how to compile the example codes of libnucnet. It assumes you are in a Linux or Unix environment. If you are using a different operating system, please adjust the following instructions as appropriate.
The libnucnet codes depend on libxml2, the XML C parser and toolkit of Gnome, gsl, the GNU Scientific Library, and wn_matrix. The examples also require xsltproc, which is part of libxslt, the XSLT C library for GNOME.
To find out if you have libxml2 properly installed on your system, type at the command line:
xml2-config
If libxml2 is properly installed, the command will return a Usage description and a list of Options. Note that you can check which version of libxml2 is installed by typing
xml2-config --version
If libxml2 is not properly installed, the result of running xml2-config will be the line
xml2-config: command not found
In this case, you will need to install libxml2 by following the appropriate instructions from this blog post before compiling libnucnet codes.
To find out if you have gsl properly installed on your system, type at the command line:
gsl-config
If gsl is properly installed, the command will return a Usage description and a list of Options. Note that you can check which version of gsl is installed by typing
gsl-config --version
If gsl is not properly installed, the result of running gsl-config will be the line
gsl-config: command not found
In this case, you will need to install gsl by following the appropriate instructions from this blog post before compiling libnucnet codes.
To find out if you have xsltproc properly installed on your system, type at the command line:
xslt-config
If it is not installed, install it as you did libxml2.
To install wn_matrix, see the download and compile tutorials for the latest release of wn_matrix.
After downloading libnucnet, go to the directory examples/ of the distribution. For example, if your current installation of libnucnet is in the directory ~/modules/libnucnet/0.4/, type
cd ~/modules/libnucnet/0.4/examples
Now compile the examples by typing
make all
This will generate all the executable files. You can also make them separately. For example, type
make create_nuc_collection
to generate the executable file create_nuc_collection. Please note that we have the compiler flags set for gcc and for memory checking with Valgrind. You may wish to edit the Makefile. Look for this part of the Makefile:
#/////////////////////////////////////////////////////////////////////////////// # The following lines must be edited according to where you have # placed your libnucnet and wn_matrix modules. You may also # edit to choose a different compiler (e.g., g++), to use Valgrind or # not, or to profile: #/////////////////////////////////////////////////////////////////////////////// GC=gcc MODULES = ../../../.. LIBNUCNETDIR = ../src/ MATRIXSRCDIR = $(MODULES)/wn_matrix/0.13/src/ VALGRIND= yes PROFILE= no #/////////////////////////////////////////////////////////////////////////////// # End of lines to be edited. #///////////////////////////////////////////////////////////////////////////////=
You should only need to change the lines in this section. If you installed wn_matrix in the ~/modules/ as described in the wn_matrix download tutorial, you should not have to change anything. If you installed a different version of wn_matrix or installed it elsewhere, you might need to change MODULES or MATRIXSRCDIR. For example, if you are using wn_matrix 0.12 instead of 0.13, you will want to change MATRIXSRCDIR to read:
MATRIXSRCDIR = $(MODULES)/wn_matrix/0.12/src/
On the other hand, if you installed version 0.13 of wn_matrix in /home/your_user_name/my_webnucleo_stuff/modules/wn_matrix/0.13, then you will need to change the MODULES line to read:
MODULES = /home/your_user_name/my_webnucleo_stuff/modules
If you use a different version of wn_matrix than 0.13 and you installed it in a different place, then you will need to change both MODULES and MATRIXSRCDIR appropriately.
You might also want to change the compiler from gcc to g++ by setting GC=g++ or to optimize by setting VALGRIND=no. If you choose PROFILE= yes, the executable will leave a gmon.out file that you can view with gprof.
Note that we have set the compiler flags to check the executable with Valgrind. Valgrind works best without optimization, so you can optimize your executables by setting VALGRIND= no.
To remove the object files created during compilation, type
make clean
To remove all the object and executable files, type
make cleanall