我已经下载并编译: http: //leenissen.dk/fann/wp/
- cmake 版本 2.8.11.2
- gcc (Ubuntu/Linaro 4.8.1-10ubuntu8) 4.8.1
用于编译的命令:
cmake -D CMAKE_INSTALL_PREFIX:PATH=/usr .
安装:
sudo make && sudo make install
然后我进入 fann 项目中的 examples/ 目录并尝试通过运行来编译示例:
make all
我收到一个错误:
gcc -O3 xor_train.c -o xor_train -lfann -lm
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so: undefined reference to `sin'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so: undefined reference to `exp'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so: undefined reference to `cos'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so: undefined reference to `log'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so: undefined reference to `pow'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so: undefined reference to `sqrt'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so: undefined reference to `floor'
collect2: error: ld returned 1 exit status
make: *** [xor_train] Error 1
更新:
- 我遵循了图书馆给出的指示
- 我检查了另一台机器并提供了按预期工作的指令,所以我猜我的环境在某种程度上配置错误。
有关共享库依赖项的更多信息:
ldd /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/libfann.so
linux-vdso.so.1 => (0x00007fff3abfe000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6f3997c000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6f39f84000)
正如@michael-burr 所建议的,用 -Wl,-v 编译
/usr/bin/ld --sysroot=/ \
--build-id --eh-frame-hdr -m elf_x86_64 \
--hash-style=gnu --as-needed \
-dynamic-linker /lib64/ld-linux-x86-64.so.2 \
-z relro -o xor_train \
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o \
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o \
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o \
-L/usr/lib/gcc/x86_64-linux-gnu/4.8 \
-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu \
-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib \
-L/lib/x86_64-linux-gnu \
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu \
-L/usr/lib/../lib \
-L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. \
-v /tmp/cc0AHZgU.o -lfann -lm -lgcc --as-needed -lgcc_s --no-as-needed \
-lc -lgcc --as-needed -lgcc_s --no-as-needed \
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o \
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
GNU ld (GNU Binutils for Ubuntu) 2.23.52.20130913