簡體   English   中英

Raspberry Pi 3,未定義fann_create_standard

[英]Raspberry Pi 3 ,fann_create_standard not defined

我最近通過樹莓派的突觸管理器下載了FANN(快速人工神經網絡)庫。 我正在嘗試運行默認應用程序,如下所示:

 #include "fann.h"
 #include "floatfann.h"
 include "fann_data.h"

 int main()
 {
const unsigned int num_input = 2;
const unsigned int num_output = 1;
const unsigned int num_layers = 3;
const unsigned int num_neurons_hidden = 3;
const float desired_error = (const float) 0.001;
const unsigned int max_epochs = 500000;
const unsigned int epochs_between_reports = 1000;

struct fann *ann = fann_create_standard(num_layers, num_input,
    num_neurons_hidden, num_output);

fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);

fann_train_on_file(ann, "xor.data", max_epochs,
    epochs_between_reports, desired_error);

fann_save(ann, "xor_float.net");

fann_destroy(ann);

return 0;
}

我得到以下輸出:

enter code here


||=== Build: Debug in ArtificialNeuralNetworkExample (compiler: GNU GCC    Compi ler) ===|
obj/Debug/main.o||In function `main':|
/home/pi/Documents/ArtificialNeuralNetworkExample/main.c|14|undefined reference to `fann_create_standard'|
/home/pi/Documents/ArtificialNeuralNetworkExample/main.c|17|undefined reference to `fann_set_activation_function_hidden'|
/home/pi/Documents/ArtificialNeuralNetworkExample/main.c|18|undefined reference to `fann_set_activation_function_output'|
/home/pi/Documents/ArtificialNeuralNetworkExample/main.c|20|undefined reference to `fann_train_on_file'|
/home/pi/Documents/ArtificialNeuralNetworkExample/main.c|23|undefined reference to `fann_save'|
/home/pi/Documents/ArtificialNeuralNetworkExample/main.c|25|undefined reference to `fann_destroy'|
||=== Build failed: 6 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

還嘗試使用gcc鏈接庫,如下所示:

gcc -lfann main.c

不知道該怎么辦。

我相信,您需要更改庫在編譯語句中出現的順序。

 gcc -lfann main.c

應該

 gcc main.c -lfann

因為main.c中使用的函數存在於libfann.so

引用在線gcc手冊

-l library

[....]在命令中編寫此選項的位置有所不同; 鏈接器按照指定的順序搜索和處理庫和目標文件。 因此, foo.o -lz bar.o搜索庫z文件后, foo.o但在此之前bar.o 如果bar.o引用z中的函數,則可能不會加載這些函數。

在你的情況,你面對類似的情況,你的情況下,圖書館應在出現后main.c從庫中的函數中使用main.c

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM