We will install the
Fast Artificial Neural Network library on the Debian operating system (one of the Linux distributions). You can install the library in two ways.
- installation from repositories;
- installation of all elements separately.
The first method of course makes installation a bit easier, but it's not worth it. That's what I actually had to face. When I needed to install on Debian. I found an installation guide that described the first method. Having fluently read it and already having time to rejoice (as it turned out later, not for long), I began to carry out exactly all the steps for installing the library described in the manual. Nuances did not arise. It seems the library has been installed and the extension for PHP too. It seemed that everything had to work. But it was not there. First, I connected the neural network I used on
denwere . But the result was zero. It turned out that even the library itself did not pass. After re-reading the installation manual and similar manuals from other resources, I understood that everything should work. But in the end nothing worked. It took me two days to solve the installation problem. When all possible options (and there were some of them) were exhausted, the thought “flashed” on me, and what if the distribution kit from the repositories of the library itself is “broken”. And as it turned out later, it was so. Therefore, I recommend that you use the second installation method, in the end everything will work, and your nerves will be in perfect order.
Installation start
For installation we need the following tools:
')
- make program;
- gcc compiler;
- phpize utility from php5-dev package.
If the first two tools can already be installed, the third, most likely not. But we will check all three just in case.
dpkg -l | grep make
ii makedev 2.3.1-88 creates device files in / dev
dpkg -l | grep gcc
ii gcc-3.3-base 1: 3.3.6-15 The GNU Compiler Collection (base package)
ii gcc-4.1-base 4.1.2-25 The GNU Compiler Collection (base package)
ii gcc-4.3-base 4.3.2-1.1 The GNU Compiler Collection (base package)
ii libgcc1 1: 4.3.2-1.1 GCC support library
dpkg -l | grep php5-dev
Well, as expected, we really have not installed anything. Before starting the installation, it is advisable to update the repositories. To do this, use the command:
apt-get update
Now you need to install the missing toolkit:
apt-get install make
apt-get install gcc
apt-get install php5-dev
Next, you need to get information about the architecture in order to know which packages of the Fast Artificial Neural Network library (although Debian will not let you install packages with unsuitable architecture) to install. To do this, use the command:
uname –m
By the result, we see that the server has an architecture:
i686
Go to the
/ usr / local / src directory and download the following packages for the i686 architecture:
cd / usr / local / src
wget http://ubuntu.mirror.cambrium.nl/ubuntu//pool/universe/libf/libfann1/
libfann1_1.2.0-1_i386.deb
wget http://ubuntu.mirror.cambrium.nl/ubuntu//pool/universe/libf/libfann1/
libfann1-dev_1.2.0-1_i386.deb
Make sure all downloaded:
ls -1
libfann1_1.2.0-1_i386.deb
libfann1-dev_1.2.0-1_i386.deb
Now they need to be installed in a specific order:
dpkg -i libfann1_1.2.0-1_i386.deb
dpkg -i libfann1-dev_1.2.0-1_i386.deb
Installing an extension for PHP
In order to proceed with the installation of the extension, you need to download it:
wget http://pecl.php.net/get/fann
Check or archive on site:
ls -1
fann
Further it is necessary to unpack it:
tar xvfz fann
package.xml
fann-0.1.1 / config.m4
fann-0.1.1 / fann.c
fann-0.1.1 / php_fann.h
fann-0.1.1 / demo.php
fann-0.1.1 / CREDITS
fann-0.1.1 / EXPERIMENTAL
Then go to the directory
/usr/local/src/fann-0.1.1 cd fann-0.1.1
Everything, it remains only to compile everything. First you need to run the
phpize command. Which will prepare the PHP extension environment.
phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
Next, you need to run the
configure script.
./configure
Everything, it now remains to build the PHP extension with the
make program
make
If you see something similar to the following lines:
fann.c: 393: error: 'zif_fannOO___set' undeclared (first use in this function)
fann.c: 393: error: (Each undeclared identifier is reported only once
fann.c: 393: error: for each function it appears in.)
fann.c: 403: error: B-? zif_fannOO ___ getB-? undeclared (first use in this function)
you need to comment out the line 28
# define PHP_FANN_OO 1 in the file
php_fann.h . And repeat the call to the
make program.
make
libtool: install: cp ./.libs/fann.so /usr/local/src/fann-0.1.1/modules/fann.so
libtool: install: cp ./.libs/fann.lai /usr/local/src/fann-0.1.1/modules/fann.la
libtool: finish: PATH = "/ usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / sbin: / bin:
/ sbin "ldconfig -n /usr/local/src/fann-0.1.1/modules
-------------------------------------------------- --------------------
Libraries have been installed in:
/usr/local/src/fann-0.1.1/modules
If you ever want to link against the installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR '
flag during the following:
- add LIBDIR to the `LD_LIBRARY_PATH 'environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH 'environment variable
during linking
- use the `-Wl, -rpath -Wl, LIBDIR 'linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf '
See any operating system documentation about shared libraries for
more information, such as the ld (1) and ld.so (8) manual pages.
-------------------------------------------------- --------------------
Build complete.
Don't forget to run 'make test'.
Everything, the extension is assembled and it remains to install it:
make install
Installing shared extensions: / usr / lib / php5 / 20090626 /
If you added an extension to
/etc/php5/cli/php.ini , then you can see if the module is connected with the following command:
php -m | grep fann
fann
I personally try to synchronize settings immediately everywhere:
- /etc/php5/apache2/php.ini;
- / etc / php5 / cgi / php.ini;
- / etc / php5 / cli / php.ini.
In order to test the library, you need to run the demo.php module. It is located in the
/usr/local/src/fann-0.1.1 directory.
There is still a small nuance. You may not be able to use the network trained in another version of the Fast Artificial Neural Network library, with this library. It is necessary to retrain it under Linux. But nothing wrong with that.