Copies of FANN can be obtained from our Download page.
FANN is available under the terms of the GNU Lesser General Public License.
FANN bindings to several other programming languages is also available from the Language Bindings page.
Windows Installation
FANN includes prebuilt DLL and LIB files as well as prebuilt executables for some of the examples. To use these in your own project, simply reference the DLL/LIB files as well as the header files.
To compile FANN and the examples yourself, you will need Visual Studio 2010 or use the Cross Platform Install method described below.
To build the library and examples with Visual Studio 2010, first navigate to the VS2010 directory in the FANN distribution and open the fann.sln solution. In the Visual Studio menu bar, choose “Build” -> “Build Solution”. When the build process is complete, the library and examples can be found in the “bin” directory.
Cross Platform Install
The FANN cross platform install system is based on CMAKE and have been tested on ubuntu Linux and Mac OSX, but should work on other platforms too. Once you have installed CMAKE, you can execute the following commands, in the FANN directory, to compile and install FANN.
cmake .
sudo make install
Once you have installed the library you can test it out by going to the examples directory and type make runtest, which will compile the examples and run a few of them to test that everything is working.
Sometimes you want to install to a different location than the default /usr/local. You can do that by adding the CMAKE_INSTALL_PREFIX to cmake, by for example installing to /usr like this cmake -D CMAKE_INSTALL_PREFIX:PATH=/usr .
When all else fails
FANN is pretty simple and does not require a lot of extra stuff, so when all else fails, simply include the file doublefann.c or floatfann.c in your project and everything should work.
An example of how this is done can be seen in the rundebugtest target in examples/Makefile.
./xor_train: error while loading shared libraries: libfann.so.2: cannot open shared object file: No such file or directory
make: *** [runtest] Error 127
what this error about?
I got the same error when installing in Ubuntu. Can any one help on this matter?
run “ldconfig” command
Running
ldconfigwithsudoworked for me! Thanks.This works fine for me too, thx!
@Dek Wan :
You got this error because the /usr/local/lib isn’t in your library path, a simple solution could be to add a symbolic link to your actual library path, try this out :
$> ln -s /usr/local/lib/*fann* /usr/lib/
Actually installation was successful but when running the example given above gave this error
Training network
./xor_train
./xor_train: error while loading shared libraries: libfann.so.2: cannot open shared object file: No such file or directory
make: *** [runtest] Error 127
Try this out :
$> ln -s /usr/local/lib/*fann* /usr/lib/
or simply copy by hand all the installed files in the /local/lib/library (if you didn’t change the install path) to the /usr/lib folder, it’s actually the simplest solution I got, with no need to change the library path of your system.
I install fann correctly, also xor example works fine. But I modify the xor.data in the example directory to be
5 2 1
1.200000 1.133333
0
1.266667 1.000000
0
1.266667 1.200000
0
2.066667 5.266667
1
0.594595 1.513514
2
Also, xor_train.c: max_epochs to be 500000. The others are the same. But the result is not that right:
XOR test (1.200000,1.133333) -> 0.014159, should be 0.000000, difference=0.014159
XOR test (1.266667,1.000000) -> 0.014159, should be 0.000000, difference=0.014159
XOR test (1.266667,1.200000) -> 0.014159, should be 0.000000, difference=0.014159
XOR test (2.066667,5.266667) -> 1.000000, should be 1.000000, difference=-0.000000
XOR test (0.594595,1.513514) -> 1.000000, should be 2.000000, difference=1.000000
Any ideas what should I do now? Many thanks.
To anyone seeing the error:
./xor_train: error while loading shared libraries: libfann.so.2: cannot open shared object file: No such file or directory
make: *** [runtest] Error 127
This happens when you install a shared library and don’t run ldconfig after. I was able to get it to work by running “sudo ldconfig” after installation.
When I do the cmake . on Ubuntu 12.04, I get:
CMake Error at CMakeLists.txt:13 (SET_TARGET_PROPERTIES):
set_target_properties called with incorrect number of arguments.
CMake Error at CMakeLists.txt:14 (INSTALL):
install TARGETS given no LIBRARY DESTINATION for shared library target
"floatfann".
CMake Error at CMakeLists.txt:25 (SET_TARGET_PROPERTIES):
set_target_properties called with incorrect number of arguments.
CMake Error at CMakeLists.txt:26 (INSTALL):
install TARGETS given no LIBRARY DESTINATION for shared library target
"doublefann".
CMake Error at CMakeLists.txt:37 (SET_TARGET_PROPERTIES):
set_target_properties called with incorrect number of arguments.
CMake Error at CMakeLists.txt:38 (INSTALL):
install TARGETS given no LIBRARY DESTINATION for shared library target
"fixedfann".
CMake Error at CMakeLists.txt:49 (SET_TARGET_PROPERTIES):
set_target_properties called with incorrect number of arguments.
CMake Error at CMakeLists.txt:50 (INSTALL):
install TARGETS given no LIBRARY DESTINATION for shared library target
"fann".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 2.8)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
How can I fix this?
I have the same error message. I have Ubuntu 12.04 64-bit on my desktop.
I had the same problem. The problem was that I run cmake inside src/ directory. But you should cmake it in the top level of unzipped FANN code.
I had this problem, and I think it was caused by the fact that I did not know how to use cmake properly. Initially, I tried running “cmake src/” instead of “cmake .” I just re-extracted the zip folder and tried again running the correct command and it worked.
After i installed the program, When i try to run the sample train program, it is giving error
nn_training.c:(.text+0×62): undefined reference to `fann_create_standard’
nn_training.c:(.text+0x7a): undefined reference to `fann_set_activation_function_hidden’
nn_training.c:(.text+0x8e): undefined reference to `fann_set_activation_function_output’
nn_training.c:(.text+0xba): undefined reference to `fann_train_on_file’
nn_training.c:(.text+0xce): undefined reference to `fann_save’
nn_training.c:(.text+0xda): undefined reference to `fann_destroy’
This is because the file “fann.h” is not getting linked properly.
How to solve this error??
this is very easy manner to search details about fann
Im using FANN on my Macbookpro. I have installed it very easily but testrun is failed. Can someone have a look at it tell me if there is any issue with my installation?
Console output follows:
bhupendra@vpn examples$ make runtest
gcc -O3 xor_train.c -o xor_train -lfann -lm
gcc -O3 xor_test.c -o xor_test -lfann -lm
gcc -O3 -DFIXEDFANN xor_test.c -o xor_test_fixed -lfixedfann -lm
gcc -O3 simple_train.c -o simple_train -lfann -lm
gcc -O3 steepness_train.c -o steepness_train -lfann -lm
gcc -O3 simple_test.c -o simple_test -lfann -lm
gcc -O3 robot.c -o robot -lfann -lm
gcc -O3 mushroom.c -o mushroom -lfann -lm
gcc -O3 cascade_train.c -o cascade_train -lfann -lm
gcc -O3 scaling_test.c -o scaling_test -lfann -lm
gcc -O3 scaling_train.c -o scaling_train -lfann -lm
Training network
./xor_train
Creating network.
Training network.
Max epochs 1000. Desired error: 0.0000000000.
Epochs 1. Current error: 0.2998471856. Bit fail 4.
Epochs 10. Current error: 0.1645403504. Bit fail 4.
Epochs 20. Current error: 0.1343973279. Bit fail 4.
Epochs 30. Current error: 0.1321901083. Bit fail 4.
Epochs 40. Current error: 0.1320076436. Bit fail 4.
Epochs 50. Current error: 0.1318376809. Bit fail 4.
Epochs 60. Current error: 0.1316868365. Bit fail 4.
Epochs 70. Current error: 0.1314437091. Bit fail 4.
Epochs 80. Current error: 0.1314807087. Bit fail 4.
Epochs 90. Current error: 0.1314186156. Bit fail 4.
Epochs 100. Current error: 0.1313483715. Bit fail 4.
Epochs 110. Current error: 0.1314515471. Bit fail 4.
Epochs 120. Current error: 0.1313693523. Bit fail 4.
Epochs 130. Current error: 0.1314102709. Bit fail 4.
Epochs 140. Current error: 0.1313417256. Bit fail 4.
Epochs 150. Current error: 0.1313553154. Bit fail 4.
Epochs 160. Current error: 0.1313396096. Bit fail 4.
Epochs 170. Current error: 0.1313699782. Bit fail 4.
Epochs 180. Current error: 0.1313713491. Bit fail 4.
Epochs 190. Current error: 0.1313034594. Bit fail 4.
Epochs 200. Current error: 0.1313286722. Bit fail 4.
Epochs 210. Current error: 0.1313354671. Bit fail 4.
Epochs 220. Current error: 0.1313285679. Bit fail 4.
Epochs 230. Current error: 0.1312805712. Bit fail 4.
Epochs 240. Current error: 0.1312561035. Bit fail 4.
Epochs 250. Current error: 0.1312738359. Bit fail 4.
Epochs 260. Current error: 0.1312966943. Bit fail 4.
Epochs 270. Current error: 0.1312941313. Bit fail 4.
Epochs 280. Current error: 0.1312871873. Bit fail 4.
Epochs 290. Current error: 0.1312831491. Bit fail 4.
Epochs 300. Current error: 0.1312471628. Bit fail 4.
Epochs 310. Current error: 0.1312719584. Bit fail 4.
Epochs 320. Current error: 0.1312411875. Bit fail 4.
Epochs 330. Current error: 0.1312507540. Bit fail 4.
Epochs 340. Current error: 0.1312562227. Bit fail 4.
Epochs 350. Current error: 0.1312428415. Bit fail 4.
Epochs 360. Current error: 0.1312461942. Bit fail 4.
Epochs 370. Current error: 0.1312564313. Bit fail 4.
Epochs 380. Current error: 0.1312440932. Bit fail 4.
Epochs 390. Current error: 0.1312446594. Bit fail 4.
Epochs 400. Current error: 0.1312422752. Bit fail 4.
Epochs 410. Current error: 0.1312395483. Bit fail 4.
Epochs 420. Current error: 0.1312251985. Bit fail 4.
Epochs 430. Current error: 0.1311910152. Bit fail 4.
Epochs 440. Current error: 0.1311998963. Bit fail 4.
Epochs 450. Current error: 0.1312367022. Bit fail 4.
Epochs 460. Current error: 0.1312312782. Bit fail 4.
Epochs 470. Current error: 0.1312316060. Bit fail 4.
Epochs 480. Current error: 0.1312264204. Bit fail 4.
Epochs 490. Current error: 0.1312348247. Bit fail 4.
Epochs 500. Current error: 0.1311919093. Bit fail 4.
Epochs 510. Current error: 0.1312199533. Bit fail 4.
Epochs 520. Current error: 0.1312156916. Bit fail 4.
Epochs 530. Current error: 0.1312299967. Bit fail 4.
Epochs 540. Current error: 0.1312159747. Bit fail 4.
Epochs 550. Current error: 0.1312028170. Bit fail 4.
Epochs 560. Current error: 0.1311953217. Bit fail 4.
Epochs 570. Current error: 0.1312059760. Bit fail 4.
Epochs 580. Current error: 0.1312075257. Bit fail 4.
Epochs 590. Current error: 0.1312050819. Bit fail 4.
Epochs 600. Current error: 0.1312092394. Bit fail 4.
Epochs 610. Current error: 0.1311953366. Bit fail 4.
Epochs 620. Current error: 0.1312166899. Bit fail 4.
Epochs 630. Current error: 0.1312093884. Bit fail 4.
Epochs 640. Current error: 0.1312118769. Bit fail 4.
Epochs 650. Current error: 0.1312177479. Bit fail 4.
Epochs 660. Current error: 0.1311965585. Bit fail 4.
Epochs 670. Current error: 0.1311824322. Bit fail 4.
Epochs 680. Current error: 0.1311974674. Bit fail 4.
Epochs 690. Current error: 0.1311904341. Bit fail 4.
Epochs 700. Current error: 0.1312078834. Bit fail 4.
Epochs 710. Current error: 0.1312024593. Bit fail 4.
Epochs 720. Current error: 0.1312027872. Bit fail 4.
Epochs 730. Current error: 0.1312017739. Bit fail 4.
Epochs 740. Current error: 0.1312023550. Bit fail 4.
Epochs 750. Current error: 0.1311884224. Bit fail 4.
Epochs 760. Current error: 0.1311852485. Bit fail 4.
Epochs 770. Current error: 0.1312024593. Bit fail 4.
Epochs 780. Current error: 0.1311842203. Bit fail 4.
Epochs 790. Current error: 0.1311897635. Bit fail 4.
Epochs 800. Current error: 0.1311981380. Bit fail 4.
Epochs 810. Current error: 0.1311885417. Bit fail 4.
Epochs 820. Current error: 0.1311869621. Bit fail 4.
Epochs 830. Current error: 0.1311998963. Bit fail 4.
Epochs 840. Current error: 0.1312031895. Bit fail 4.
Epochs 850. Current error: 0.1311789453. Bit fail 4.
Epochs 860. Current error: 0.1311890185. Bit fail 4.
Epochs 870. Current error: 0.1311903894. Bit fail 4.
Epochs 880. Current error: 0.1311752647. Bit fail 4.
Epochs 890. Current error: 0.1311975718. Bit fail 4.
Epochs 900. Current error: 0.1312029064. Bit fail 4.
Epochs 910. Current error: 0.1311938316. Bit fail 4.
Epochs 920. Current error: 0.1311802417. Bit fail 4.
Epochs 930. Current error: 0.1311967373. Bit fail 4.
Epochs 940. Current error: 0.1311729103. Bit fail 4.
Epochs 950. Current error: 0.1311972737. Bit fail 4.
Epochs 960. Current error: 0.1311960965. Bit fail 4.
Epochs 970. Current error: 0.1312002838. Bit fail 4.
Epochs 980. Current error: 0.1312011927. Bit fail 4.
Epochs 990. Current error: 0.1311844289. Bit fail 4.
Epochs 1000. Current error: 0.1312025189. Bit fail 4.
Testing network. 0.131195
XOR test (-1.000000,-1.000000) -> -0.845081, should be -1.000000, difference=0.154919
XOR test (-1.000000,1.000000) -> -0.012242, should be 1.000000, difference=1.012242
XOR test (1.000000,-1.000000) -> 0.843651, should be 1.000000, difference=0.156349
XOR test (1.000000,1.000000) -> 0.012936, should be -1.000000, difference=1.012936
Saving network.
Cleaning up.
Testing network with floats
./xor_test
Creating network.
Layer / Neuron 0123456
L 1 / N 3 Abb….
L 1 / N 4 ACC….
L 1 / N 5 ACC….
L 1 / N 6 …….
L 2 / N 7 …FECa
L 2 / N 8 …….
Input layer : 2 neurons, 1 bias
Hidden layer : 3 neurons, 1 bias
Output layer : 1 neurons
Total neurons and biases : 8
Total connections : 13
Connection rate : 1.000
Network type : FANN_NETTYPE_LAYER
Training algorithm : FANN_TRAIN_RPROP
Training error function : FANN_ERRORFUNC_TANH
Training stop function : FANN_STOPFUNC_BIT
Bit fail limit : 0.010
Learning rate : 0.700
Learning momentum : 0.000
Quickprop decay : -0.000100
Quickprop mu : 1.750
RPROP increase factor : 1.200
RPROP decrease factor : 0.500
RPROP delta min : 0.000
RPROP delta max : 50.000
Cascade output change fraction : 0.010000
Cascade candidate change fraction : 0.010000
Cascade output stagnation epochs : 12
Cascade candidate stagnation epochs : 12
Cascade max output epochs : 150
Cascade min output epochs : 50
Cascade max candidate epochs : 150
Cascade min candidate epochs : 50
Cascade weight multiplier : 0.400
Cascade candidate limit :1000.000
Cascade activation functions[0] : FANN_SIGMOID
Cascade activation functions[1] : FANN_SIGMOID_SYMMETRIC
Cascade activation functions[2] : FANN_GAUSSIAN
Cascade activation functions[3] : FANN_GAUSSIAN_SYMMETRIC
Cascade activation functions[4] : FANN_ELLIOT
Cascade activation functions[5] : FANN_ELLIOT_SYMMETRIC
Cascade activation functions[6] : FANN_SIN_SYMMETRIC
Cascade activation functions[7] : FANN_COS_SYMMETRIC
Cascade activation functions[8] : FANN_SIN
Cascade activation functions[9] : FANN_COS
Cascade activation steepnesses[0] : 0.250
Cascade activation steepnesses[1] : 0.500
Cascade activation steepnesses[2] : 0.750
Cascade activation steepnesses[3] : 1.000
Cascade candidate groups : 2
Cascade no. of candidates : 80
Testing network.
XOR test (-1.000000, -1.000000) -> -0.845081, should be -1.000000, difference=0.154919
XOR test (-1.000000, 1.000000) -> -0.012242, should be 1.000000, difference=1.012242
XOR test (1.000000, -1.000000) -> 0.843651, should be 1.000000, difference=0.156349
XOR test (1.000000, 1.000000) -> 0.012936, should be -1.000000, difference=1.012936
Cleaning up.
Testing network with fixed points
./xor_test_fixed
Creating network.
Layer / Neuron 0123456
L 1 / N 3 Abb….
L 1 / N 4 ACC….
L 1 / N 5 ACC….
L 1 / N 6 …….
L 2 / N 7 …FECa
L 2 / N 8 …….
Input layer : 2 neurons, 1 bias
Hidden layer : 3 neurons, 1 bias
Output layer : 1 neurons
Total neurons and biases : 8
Total connections : 13
Connection rate : 1.000
Network type : FANN_NETTYPE_LAYER
Decimal point : 13
Multiplier :8192
Bit fail limit : 82
Testing network.
XOR test (-8192, -8192) -> -6287, should be -8192, difference=0.232544
Test failed
XOR test (-8192, 8192) -> -122, should be 8192, difference=1.014893
Test failed
XOR test (8192, -8192) -> 6037, should be 8192, difference=0.263062
Test failed
XOR test (8192, 8192) -> -122, should be -8192, difference=0.985107
Test failed
Cleaning up.
make: *** [runtest] Error 255
bhupendra@vpn examples$
Got it!!!

Posting it for anyone having same issue on Mac.
For OSX you need to change optimization to ’0′ instead of ’3′. Just change these two lines in the ./example/Makefile
>>
%: %.c Makefile
$(GCC) -O0 $< -o $@ -lfann -lm
%_fixed: %.c Makefile
$(GCC) -O0 -DFIXEDFANN $>
Output of the testrun:
bhupendra@vpn examples$ make runtest
gcc -O0 xor_train.c -o xor_train -lfann -lm
gcc -O0 xor_test.c -o xor_test -lfann -lm
gcc -O0 -DFIXEDFANN xor_test.c -o xor_test_fixed -lfixedfann -lm
gcc -O0 simple_train.c -o simple_train -lfann -lm
gcc -O0 steepness_train.c -o steepness_train -lfann -lm
gcc -O0 simple_test.c -o simple_test -lfann -lm
gcc -O0 robot.c -o robot -lfann -lm
gcc -O0 mushroom.c -o mushroom -lfann -lm
gcc -O0 cascade_train.c -o cascade_train -lfann -lm
gcc -O0 scaling_test.c -o scaling_test -lfann -lm
gcc -O0 scaling_train.c -o scaling_train -lfann -lm
Training network
./xor_train
Creating network.
Training network.
Max epochs 1000. Desired error: 0.0000000000.
Epochs 1. Current error: 0.2865722179. Bit fail 4.
Epochs 10. Current error: 0.1378555745. Bit fail 4.
Epochs 20. Current error: 0.0009042433. Bit fail 4.
Epochs 28. Current error: 0.0000391395. Bit fail 0.
Testing network. 0.000023
XOR test (-1.000000,-1.000000) -> -0.991215, should be -1.000000, difference=0.008785
XOR test (-1.000000,1.000000) -> 0.988305, should be 1.000000, difference=0.011695
XOR test (1.000000,-1.000000) -> 0.991032, should be 1.000000, difference=0.008968
XOR test (1.000000,1.000000) -> -0.991266, should be -1.000000, difference=0.008734
Saving network.
Cleaning up.
Testing network with floats
./xor_test
Creating network.
Layer / Neuron 0123456
L 1 / N 3 CCB….
L 1 / N 4 CCC….
L 1 / N 5 BBb….
L 1 / N 6 …….
L 2 / N 7 …BCdd
L 2 / N 8 …….
Input layer : 2 neurons, 1 bias
Hidden layer : 3 neurons, 1 bias
Output layer : 1 neurons
Total neurons and biases : 8
Total connections : 13
Connection rate : 1.000
Network type : FANN_NETTYPE_LAYER
Training algorithm : FANN_TRAIN_RPROP
Training error function : FANN_ERRORFUNC_TANH
Training stop function : FANN_STOPFUNC_BIT
Bit fail limit : 0.010
Learning rate : 0.700
Learning momentum : 0.000
Quickprop decay : -0.000100
Quickprop mu : 1.750
RPROP increase factor : 1.200
RPROP decrease factor : 0.500
RPROP delta min : 0.000
RPROP delta max : 50.000
Cascade output change fraction : 0.010000
Cascade candidate change fraction : 0.010000
Cascade output stagnation epochs : 12
Cascade candidate stagnation epochs : 12
Cascade max output epochs : 150
Cascade min output epochs : 50
Cascade max candidate epochs : 150
Cascade min candidate epochs : 50
Cascade weight multiplier : 0.400
Cascade candidate limit :1000.000
Cascade activation functions[0] : FANN_SIGMOID
Cascade activation functions[1] : FANN_SIGMOID_SYMMETRIC
Cascade activation functions[2] : FANN_GAUSSIAN
Cascade activation functions[3] : FANN_GAUSSIAN_SYMMETRIC
Cascade activation functions[4] : FANN_ELLIOT
Cascade activation functions[5] : FANN_ELLIOT_SYMMETRIC
Cascade activation functions[6] : FANN_SIN_SYMMETRIC
Cascade activation functions[7] : FANN_COS_SYMMETRIC
Cascade activation functions[8] : FANN_SIN
Cascade activation functions[9] : FANN_COS
Cascade activation steepnesses[0] : 0.250
Cascade activation steepnesses[1] : 0.500
Cascade activation steepnesses[2] : 0.750
Cascade activation steepnesses[3] : 1.000
Cascade candidate groups : 2
Cascade no. of candidates : 80
Testing network.
XOR test (-1.000000, -1.000000) -> -0.991215, should be -1.000000, difference=0.008785
XOR test (-1.000000, 1.000000) -> 0.988305, should be 1.000000, difference=0.011695
XOR test (1.000000, -1.000000) -> 0.991032, should be 1.000000, difference=0.008968
XOR test (1.000000, 1.000000) -> -0.991266, should be -1.000000, difference=0.008734
Cleaning up.
Testing network with fixed points
./xor_test_fixed
Creating network.
Layer / Neuron 0123456
L 1 / N 3 CCB….
L 1 / N 4 CCC….
L 1 / N 5 BBb….
L 1 / N 6 …….
L 2 / N 7 …BCdd
L 2 / N 8 …….
Input layer : 2 neurons, 1 bias
Hidden layer : 3 neurons, 1 bias
Output layer : 1 neurons
Total neurons and biases : 8
Total connections : 13
Connection rate : 1.000
Network type : FANN_NETTYPE_LAYER
Decimal point : 13
Multiplier :8192
Bit fail limit : 82
Testing network.
XOR test (-8192, -8192) -> -8192, should be -8192, difference=0.000000
XOR test (-8192, 8192) -> 7888, should be 8192, difference=0.037109
XOR test (8192, -8192) -> 7967, should be 8192, difference=0.027466
XOR test (8192, 8192) -> -8192, should be -8192, difference=0.000000
Cleaning up.
bhupendra@vpn examples$