gpt4 book ai didi

c++ - 如何在 C++ 中使用 FANN

转载 作者:太空宇宙 更新时间:2023-11-04 09:50:46 24 4
gpt4 key购买 nike

在这里,我阅读了有关 C/C++ 人工神经网络中 FANN 的很好的引用资料。实际上我正在使用 C++(在带有 g++ v4.6.1 的 Ubuntu 上)。用 C 编写的库具有 C++ 的包装器。但我不让它工作。甚至包含 xor_sample.cpp 的示例也能正常工作。

我有一个包含这样一行的 Makefile:

xor_sample:
g++ -I $(FANNINCLUDE) xor_sample.cpp -o xor_sample

作为 FANNINCLUDE 到 FANN/src/include 的路径,其中 header 是(floatfan.hfann_cpp.h)。

有人真的为 C++ 编译过它吗?我做错了什么?我的意图是使用头文件(不安装库并与 -lfann 链接)。这可能吗?

编辑:我得到这个错误

/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<char, std::char_traits<char>, std::allocator<char> > const&)':
xor_sample.cpp:(.text._ZN4FANN13training_data20read_train_from_fileERKSs[FANN::training_data::read_train_from_file(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x20): undefined reference to `fann_read_train_from_file'
/tmp/ccIpH6p4.o: In function `FANN::training_data::save_train_to_fixed(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)':
xor_sample.cpp:(.text._ZN4FANN13training_data19save_train_to_fixedERKSsj[FANN::training_data::save_train_to_fixed(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, 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&)':
xor_sample.cpp:(.text._ZN4FANN10neural_net12init_weightsERKNS_13training_dataE[FANN::neural_net::init_weights(FANN::training_data const&)]+0x2a): undefined reference to `fann_init_weights'
/tmp/ccIpH6p4.o: In function `FANN::neural_net::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
xor_sample.cpp:(.text._ZN4FANN10neural_net4saveERKSs[FANN::neural_net::save(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x30): undefined reference to `fann_save'
/tmp/ccIpH6p4.o: In function `FANN::neural_net::save_to_fixed(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
xor_sample.cpp:(.text._ZN4FANN10neural_net13save_to_fixedERKSs[FANN::neural_net::save_to_fixed(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)]+0x30): undefined reference to `fann_save_to_fixed'
/tmp/ccIpH6p4.o: In function `FANN::neural_net::train_on_data(FANN::training_data const&, 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&, 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&, FANN::training_data&, 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&, FANN::training_data&, 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&, FANN::training_data&, 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&, FANN::training_data&, 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&, FANN::training_data&, 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

最佳答案

如果您只需要安装它们,它们已经在 ubuntu 存储库中

sudo apt-get install libfann1 libfann1-dev

如果你仍然想从源代码安装它,他们的页面上有一个指南 http://leenissen.dk/fann/wp/help/installing-fann/如果这不能让您更进一步,请尝试使用以下方法安装到其他位置:cmake -D CMAKE_INSTALL_PREFIX:PATH=/usr.

希望对你有帮助

关于c++ - 如何在 C++ 中使用 FANN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11380371/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com