title: How to use FANN in C++
body: <p>Here I have read good references about FANN for Artificial Neural Networks in C/C++.
  Actually I am using C++ (on Ubuntu with g++ v4.6.1). The library written in C, has a wrapper for C++. But I don't get it to work. Even the example included xor_sample.cpp works.</p>
  
  <p>I have a Makefile with a line like this:</p>
  
  <pre><code>xor_sample:
      g++ -I $(FANNINCLUDE) xor_sample.cpp -o xor_sample
  </code></pre>
  
  <p>Being <code>FANNINCLUDE</code> the path to FANN/src/include, where the headers are (<code>floatfan.h</code> and <code>fann_cpp.h</code>).</p>
  
  <p>Has somebody actually compiled it for C++? What I am doing wrong?
  My intention is to use the headers files (NOT installing the library and linking with -<code>lfann</code>). Is this possible?</p>
  
  <p>EDIT: I get this errors</p>
  
  <pre><code>/tmp/ccIpH6p4.o: In function `FANN::training_data::destroy_train()':
  xor_sample.cpp:(.text._ZN4FANN13training_data13destroy_trainEv[FANN::training_data::destroy_train()]+0x18): undefined reference to `fann_destroy_train'
  /tmp/ccIpH6p4.o: In function `FANN::training_data::read_train_from_file(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)':
  xor_sample.cpp:(.text._ZN4FANN13training_data20read_train_from_fileERKSs[FANN::training_data::read_train_from_file(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)]+0x20): undefined reference to `fann_read_train_from_file'
  /tmp/ccIpH6p4.o: In function `FANN::training_data::save_train_to_fixed(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, unsigned int)':
  xor_sample.cpp:(.text._ZN4FANN13training_data19save_train_to_fixedERKSsj[FANN::training_data::save_train_to_fixed(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;, unsigned int)]+0x37): undefined reference to `fann_save_train_to_fixed'
  /tmp/ccIpH6p4.o: In function `FANN::training_data::length_train_data()':
  xor_sample.cpp:(.text._ZN4FANN13training_data17length_train_dataEv[FANN::training_data::length_train_data()]+0x1f): undefined reference to `fann_length_train_data'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::destroy()':
  xor_sample.cpp:(.text._ZN4FANN10neural_net7destroyEv[FANN::neural_net::destroy()]+0x18): undefined reference to `fann_get_user_data'
  xor_sample.cpp:(.text._ZN4FANN10neural_net7destroyEv[FANN::neural_net::destroy()]+0x39): undefined reference to `fann_destroy'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::create_standard_array(unsigned int, unsigned int const*)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net21create_standard_arrayEjPKj[FANN::neural_net::create_standard_array(unsigned int, unsigned int const*)]+0x1f): undefined reference to `fann_create_standard_array'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::run(float*)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net3runEPf[FANN::neural_net::run(float*)]+0x26): undefined reference to `fann_run'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::init_weights(FANN::training_data const&amp;)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net12init_weightsERKNS_13training_dataE[FANN::neural_net::init_weights(FANN::training_data const&amp;)]+0x2a): undefined reference to `fann_init_weights'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::save(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net4saveERKSs[FANN::neural_net::save(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)]+0x30): undefined reference to `fann_save'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::save_to_fixed(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net13save_to_fixedERKSs[FANN::neural_net::save_to_fixed(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)]+0x30): undefined reference to `fann_save_to_fixed'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::train_on_data(FANN::training_data const&amp;, unsigned int, unsigned int, float)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net13train_on_dataERKNS_13training_dataEjjf[FANN::neural_net::train_on_data(FANN::training_data const&amp;, unsigned int, unsigned int, float)]+0x3f): undefined reference to `fann_train_on_data'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::get_MSE()':
  xor_sample.cpp:(.text._ZN4FANN10neural_net7get_MSEEv[FANN::neural_net::get_MSE()]+0x20): undefined reference to `fann_get_MSE'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::set_callback(int (*)(FANN::neural_net&amp;, FANN::training_data&amp;, unsigned int, unsigned int, float, unsigned int, void*), void*)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net12set_callbackEPFiRS0_RNS_13training_dataEjjfjPvES4_[FANN::neural_net::set_callback(int (*)(FANN::neural_net&amp;, FANN::training_data&amp;, unsigned int, unsigned int, float, unsigned int, void*), void*)]+0x1c): undefined reference to `fann_get_user_data'
  xor_sample.cpp:(.text._ZN4FANN10neural_net12set_callbackEPFiRS0_RNS_13training_dataEjjfjPvES4_[FANN::neural_net::set_callback(int (*)(FANN::neural_net&amp;, FANN::training_data&amp;, unsigned int, unsigned int, float, unsigned int, void*), void*)]+0x81): undefined reference to `fann_set_user_data'
  xor_sample.cpp:(.text._ZN4FANN10neural_net12set_callbackEPFiRS0_RNS_13training_dataEjjfjPvES4_[FANN::neural_net::set_callback(int (*)(FANN::neural_net&amp;, FANN::training_data&amp;, unsigned int, unsigned int, float, unsigned int, void*), void*)]+0x9c): undefined reference to `fann_set_callback'
  xor_sample.cpp:(.text._ZN4FANN10neural_net12set_callbackEPFiRS0_RNS_13training_dataEjjfjPvES4_[FANN::neural_net::set_callback(int (*)(FANN::neural_net&amp;, FANN::training_data&amp;, unsigned int, unsigned int, float, unsigned int, void*), void*)]+0xb3): undefined reference to `fann_set_callback'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::print_parameters()':
  xor_sample.cpp:(.text._ZN4FANN10neural_net16print_parametersEv[FANN::neural_net::print_parameters()]+0x18): undefined reference to `fann_print_parameters'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::set_learning_rate(float)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net17set_learning_rateEf[FANN::neural_net::set_learning_rate(float)]+0x1f): undefined reference to `fann_set_learning_rate'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::set_activation_function_hidden(FANN::activation_function_enum)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net30set_activation_function_hiddenENS_24activation_function_enumE[FANN::neural_net::set_activation_function_hidden(FANN::activation_function_enum)]+0x1f): undefined reference to `fann_set_activation_function_hidden'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::set_activation_function_output(FANN::activation_function_enum)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net30set_activation_function_outputENS_24activation_function_enumE[FANN::neural_net::set_activation_function_output(FANN::activation_function_enum)]+0x1f): undefined reference to `fann_set_activation_function_output'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::set_activation_steepness_hidden(float)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net31set_activation_steepness_hiddenEf[FANN::neural_net::set_activation_steepness_hidden(float)]+0x1f): undefined reference to `fann_set_activation_steepness_hidden'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::set_activation_steepness_output(float)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net31set_activation_steepness_outputEf[FANN::neural_net::set_activation_steepness_output(float)]+0x1f): undefined reference to `fann_set_activation_steepness_output'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::get_network_type()':
  xor_sample.cpp:(.text._ZN4FANN10neural_net16get_network_typeEv[FANN::neural_net::get_network_type()]+0x1f): undefined reference to `fann_get_network_type'
  /tmp/ccIpH6p4.o: In function `FANN::neural_net::internal_callback(fann*, fann_train_data*, unsigned int, unsigned int, float, unsigned int)':
  xor_sample.cpp:(.text._ZN4FANN10neural_net17internal_callbackEP4fannP15fann_train_datajjfj[FANN::neural_net::internal_callback(fann*, fann_train_data*, unsigned int, unsigned int, float, unsigned int)]+0xe): undefined reference to `fann_get_user_data'
  collect2: ld returned 1 exit status
  make: *** [xor_sample] Error 1
  </code></pre>