Angus1
July 21st, 2012, 03:17 PM
Hi, I've been (slowly) getting the hang of the very basics of c/c++ recently, with very little prior programming experience (MQL4 and programming arduinos). I haven't had too many problems writing simple programs to solve mathmatical problems, but for the life of me, I can't make the FANN library work. I've tried with Visual Studio and had no luck, so thought I'd give the suggested CMake install on linux a try. The installation went fine, but when I try to use any FANN functions I get something along the lines of this:
angus@angus-Rev-1-0:~$ cd /home/angus/fanntest
angus@angus-Rev-1-0:~/fanntest$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/angus/fanntest
angus@angus-Rev-1-0:~/fanntest$ make
[100%] Building CXX object CMakeFiles/hello.dir/fann1.o
/home/angus/fanntest/fann1.cpp: In function ‘int main()’:
/home/angus/fanntest/fann1.cpp:4:56: error: ‘fann_create’ was not declared in this scope
make[2]: *** [CMakeFiles/hello.dir/fann1.o] Error 1
make[1]: *** [CMakeFiles/hello.dir/all] Error 2
make: *** [all] Error 2
when all relevent include files are placed in the same folder as the code I get this:
angus@angus-Rev-1-0:~$ cd /home/angus/fann1
angus@angus-Rev-1-0:~/fann1$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/angus/fann1
angus@angus-Rev-1-0:~/fann1$ make
Scanning dependencies of target fann1
[100%] Building C object CMakeFiles/fann1.dir/fann1.o
/home/angus/fann1/fann1.c: In function ‘main’:
/home/angus/fann1/fann1.c:8:24: warning: initialization makes pointer from integer without a cast [enabled by default]
Linking C executable fann1
CMakeFiles/fann1.dir/fann1.o: In function `fann_run':
fann1.c:(.text+0x1ac2): undefined reference to `exp'
fann1.c:(.text+0x1b06): undefined reference to `exp'
fann1.c:(.text+0x1f70): undefined reference to `exp'
fann1.c:(.text+0x1f99): undefined reference to `exp'
fann1.c:(.text+0x2087): undefined reference to `sin'
fann1.c:(.text+0x209c): undefined reference to `cos'
fann1.c:(.text+0x20b1): undefined reference to `sin'
fann1.c:(.text+0x20de): undefined reference to `cos'
CMakeFiles/fann1.dir/fann1.o: In function `fann_init_weights':
fann1.c:(.text+0x384d): undefined reference to `pow'
CMakeFiles/fann1.dir/fann1.o: In function `fann_save_internal_fd':
fann1.c:(.text+0x5919): undefined reference to `floor'
fann1.c:(.text+0x597b): undefined reference to `floor'
fann1.c:(.text+0x59dd): undefined reference to `floor'
fann1.c:(.text+0x5bae): undefined reference to `floor'
fann1.c:(.text+0x61a5): undefined reference to `floor'
CMakeFiles/fann1.dir/fann1.o:fann1.c:(.text+0x62fd): more undefined references to `floor' follow
CMakeFiles/fann1.dir/fann1.o: In function `fann_activation_derived':
fann1.c:(.text+0x85dc): undefined reference to `cos'
fann1.c:(.text+0x85f5): undefined reference to `sin'
fann1.c:(.text+0x8617): undefined reference to `cos'
fann1.c:(.text+0x8639): undefined reference to `sin'
CMakeFiles/fann1.dir/fann1.o: In function `fann_activation':
fann1.c:(.text+0x8760): undefined reference to `exp'
fann1.c:(.text+0x87a0): undefined reference to `exp'
fann1.c:(.text+0x8bcf): undefined reference to `exp'
fann1.c:(.text+0x8bf4): undefined reference to `exp'
fann1.c:(.text+0x8cd3): undefined reference to `sin'
fann1.c:(.text+0x8ce4): undefined reference to `cos'
fann1.c:(.text+0x8cf5): undefined reference to `sin'
fann1.c:(.text+0x8d1e): undefined reference to `cos'
CMakeFiles/fann1.dir/fann1.o: In function `fann_compute_MSE':
fann1.c:(.text+0x91cf): undefined reference to `log'
CMakeFiles/fann1.dir/fann1.o: In function `fann_update_weights_sarprop':
fann1.c:(.text+0xa701): undefined reference to `sqrt'
fann1.c:(.text+0xa7ed): undefined reference to `exp'
fann1.c:(.text+0xa9af): undefined reference to `exp'
CMakeFiles/fann1.dir/fann1.o: In function `fann_save_train_internal_fd':
fann1.c:(.text+0xccbf): undefined reference to `floor'
fann1.c:(.text+0xcd09): undefined reference to `floor'
fann1.c:(.text+0xce63): undefined reference to `floor'
fann1.c:(.text+0xcead): undefined reference to `floor'
CMakeFiles/fann1.dir/fann1.o: In function `fann_set_input_scaling_params':
fann1.c:(.text+0xdeb2): undefined reference to `sqrt'
CMakeFiles/fann1.dir/fann1.o: In function `fann_set_output_scaling_params':
fann1.c:(.text+0xe3de): undefined reference to `sqrt'
CMakeFiles/fann1.dir/fann1.o: In function `fann_initialize_candidates':
fann1.c:(.text+0xfb30): undefined reference to `pow'
CMakeFiles/fann1.dir/fann1.o: In function `main':
fann1.c:(.text+0x112b4): undefined reference to `fann_create'
collect2: ld returned 1 exit status
make[2]: *** [fann1] Error 1
make[1]: *** [CMakeFiles/fann1.dir/all] Error 2
make: *** [all] Error 2
Which seems to imply to me that I need to set it up to use math.h.
The code that gives the second terminal result is:
#include "math.h"
#include "stdio.h"
#include "doublefann.c"
int main()
{
struct fann *ann = fann_create(1, 0.7, 3, 26, 13, 3);
fann_train_on_file(ann, "frequencies.data", 200, 10, 0.0001);
fann_save(ann, "language_classify.net");
fann_destroy(ann);
return 0;
}
Can anyone shed any light? I'm gussing it's something simple like I need to add a reference to the library to the CMakeLists.txt file, which currently just reads:
cmake_minimum_required(VERSION 2.0)
project(FANN1)
add_executable(fann1 fann1.c)
The FANN library can be found here - http://leenissen.dk/
Thanks for any help you can give,
Angus
angus@angus-Rev-1-0:~$ cd /home/angus/fanntest
angus@angus-Rev-1-0:~/fanntest$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/angus/fanntest
angus@angus-Rev-1-0:~/fanntest$ make
[100%] Building CXX object CMakeFiles/hello.dir/fann1.o
/home/angus/fanntest/fann1.cpp: In function ‘int main()’:
/home/angus/fanntest/fann1.cpp:4:56: error: ‘fann_create’ was not declared in this scope
make[2]: *** [CMakeFiles/hello.dir/fann1.o] Error 1
make[1]: *** [CMakeFiles/hello.dir/all] Error 2
make: *** [all] Error 2
when all relevent include files are placed in the same folder as the code I get this:
angus@angus-Rev-1-0:~$ cd /home/angus/fann1
angus@angus-Rev-1-0:~/fann1$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/angus/fann1
angus@angus-Rev-1-0:~/fann1$ make
Scanning dependencies of target fann1
[100%] Building C object CMakeFiles/fann1.dir/fann1.o
/home/angus/fann1/fann1.c: In function ‘main’:
/home/angus/fann1/fann1.c:8:24: warning: initialization makes pointer from integer without a cast [enabled by default]
Linking C executable fann1
CMakeFiles/fann1.dir/fann1.o: In function `fann_run':
fann1.c:(.text+0x1ac2): undefined reference to `exp'
fann1.c:(.text+0x1b06): undefined reference to `exp'
fann1.c:(.text+0x1f70): undefined reference to `exp'
fann1.c:(.text+0x1f99): undefined reference to `exp'
fann1.c:(.text+0x2087): undefined reference to `sin'
fann1.c:(.text+0x209c): undefined reference to `cos'
fann1.c:(.text+0x20b1): undefined reference to `sin'
fann1.c:(.text+0x20de): undefined reference to `cos'
CMakeFiles/fann1.dir/fann1.o: In function `fann_init_weights':
fann1.c:(.text+0x384d): undefined reference to `pow'
CMakeFiles/fann1.dir/fann1.o: In function `fann_save_internal_fd':
fann1.c:(.text+0x5919): undefined reference to `floor'
fann1.c:(.text+0x597b): undefined reference to `floor'
fann1.c:(.text+0x59dd): undefined reference to `floor'
fann1.c:(.text+0x5bae): undefined reference to `floor'
fann1.c:(.text+0x61a5): undefined reference to `floor'
CMakeFiles/fann1.dir/fann1.o:fann1.c:(.text+0x62fd): more undefined references to `floor' follow
CMakeFiles/fann1.dir/fann1.o: In function `fann_activation_derived':
fann1.c:(.text+0x85dc): undefined reference to `cos'
fann1.c:(.text+0x85f5): undefined reference to `sin'
fann1.c:(.text+0x8617): undefined reference to `cos'
fann1.c:(.text+0x8639): undefined reference to `sin'
CMakeFiles/fann1.dir/fann1.o: In function `fann_activation':
fann1.c:(.text+0x8760): undefined reference to `exp'
fann1.c:(.text+0x87a0): undefined reference to `exp'
fann1.c:(.text+0x8bcf): undefined reference to `exp'
fann1.c:(.text+0x8bf4): undefined reference to `exp'
fann1.c:(.text+0x8cd3): undefined reference to `sin'
fann1.c:(.text+0x8ce4): undefined reference to `cos'
fann1.c:(.text+0x8cf5): undefined reference to `sin'
fann1.c:(.text+0x8d1e): undefined reference to `cos'
CMakeFiles/fann1.dir/fann1.o: In function `fann_compute_MSE':
fann1.c:(.text+0x91cf): undefined reference to `log'
CMakeFiles/fann1.dir/fann1.o: In function `fann_update_weights_sarprop':
fann1.c:(.text+0xa701): undefined reference to `sqrt'
fann1.c:(.text+0xa7ed): undefined reference to `exp'
fann1.c:(.text+0xa9af): undefined reference to `exp'
CMakeFiles/fann1.dir/fann1.o: In function `fann_save_train_internal_fd':
fann1.c:(.text+0xccbf): undefined reference to `floor'
fann1.c:(.text+0xcd09): undefined reference to `floor'
fann1.c:(.text+0xce63): undefined reference to `floor'
fann1.c:(.text+0xcead): undefined reference to `floor'
CMakeFiles/fann1.dir/fann1.o: In function `fann_set_input_scaling_params':
fann1.c:(.text+0xdeb2): undefined reference to `sqrt'
CMakeFiles/fann1.dir/fann1.o: In function `fann_set_output_scaling_params':
fann1.c:(.text+0xe3de): undefined reference to `sqrt'
CMakeFiles/fann1.dir/fann1.o: In function `fann_initialize_candidates':
fann1.c:(.text+0xfb30): undefined reference to `pow'
CMakeFiles/fann1.dir/fann1.o: In function `main':
fann1.c:(.text+0x112b4): undefined reference to `fann_create'
collect2: ld returned 1 exit status
make[2]: *** [fann1] Error 1
make[1]: *** [CMakeFiles/fann1.dir/all] Error 2
make: *** [all] Error 2
Which seems to imply to me that I need to set it up to use math.h.
The code that gives the second terminal result is:
#include "math.h"
#include "stdio.h"
#include "doublefann.c"
int main()
{
struct fann *ann = fann_create(1, 0.7, 3, 26, 13, 3);
fann_train_on_file(ann, "frequencies.data", 200, 10, 0.0001);
fann_save(ann, "language_classify.net");
fann_destroy(ann);
return 0;
}
Can anyone shed any light? I'm gussing it's something simple like I need to add a reference to the library to the CMakeLists.txt file, which currently just reads:
cmake_minimum_required(VERSION 2.0)
project(FANN1)
add_executable(fann1 fann1.c)
The FANN library can be found here - http://leenissen.dk/
Thanks for any help you can give,
Angus