- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 MinGW 在 Windows 上构建一个基本的 FANN(快速人工神经网络)项目。然而,每当我尝试链接可执行文件时,我都会遇到一堆 undefined reference
错误。有趣的是,如果我根本不链接该库,我会收到更多错误,这意味着该库至少有一部分正在工作。我尝试编译和链接的文件的代码是:
#include "doublefann.h"
int main() {
const unsigned int num_input_neurons = 9;
const unsigned int num_output_neurons = 1;
const unsigned int num_layers = 3;
const unsigned int num_hidden_neurons = 9;
const float desired_error = (const float) 0;
const unsigned int max_epochs = 500000;
const unsigned int epochs_between_reports = 1000;
struct fann *ann = fann_create_standard(num_layers,
num_input_neurons,
num_hidden_neurons,
num_output_neurons);
fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
fann_train_on_file(ann,
"titanic-training.data",
max_epochs,
epochs_between_reports,
desired_error);
fann_save(ann, "titanic.net");
fann_destroy(ann);
return 0;
}
我用来编译和链接的命令是:
gcc -Wall -Ifann\src\include titanic-train.c -Lfann\bin -lfanndouble -o titanic-train.exe
我返回的错误是:
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0x7f): undefined reference to `fann_set_activation_function_hidden'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0x93): undefined reference to `fann_set_activation_function_output'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0xbf): undefined reference to `fann_train_on_file'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0xd3): undefined reference to `fann_save'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0xdf): undefined reference to `fann_destroy'
c:/fragileprograms/mingw-native/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o: bad reloc address 0x64 in section `.rdata'
c:/fragileprograms/mingw-native/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
如果我根本不链接库,我会得到:
C:\Users\kunkelwe\AppData\Local\Temp\ccyOO3jL.o:titanic-train.c:(.text+0x67): undefined reference to `fann_create_standard'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0x7f): undefined reference to `fann_set_activation_function_hidden'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0x93): undefined reference to `fann_set_activation_function_output'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0xbf): undefined reference to `fann_train_on_file'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0xd3): undefined reference to `fann_save'
C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o:titanic-train.c:(.text+0xdf): undefined reference to `fann_destroy'
c:/fragileprograms/mingw-native/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\kunkelwe\AppData\Local\Temp\ccsWQg66.o: bad reloc address 0x64 in section `.rdata'
c:/fragileprograms/mingw-native/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
编辑:
根据 Haroogan 的要求,我运行了 nm fanndouble.lib
。输出相当广泛,因此我没有将其全部粘贴到此处,而是通过此处的 Pastebin 提供了它:http://pastebin.com/raw.php?i=vybFhEcX
我不熟悉 nm
,但文件中似乎确实存在缺失的符号。
编辑#2:
doublefann.h的内容为:http://pastebin.com/mrHKJi8C
以及 fann.h 的内容,其中包括:http://pastebin.com/gTrHCYAg
用MinGW重新编译库可以解决这个问题吗?
编辑#3:
哈罗根建议的改变奏效了!除了这些更改之外,我还必须通过添加以下内容来修改 FANN 的 CMakeLists.txt 文件:
if (WIN32)
ADD_DEFINITIONS(-DFANN_DLL_EXPORTS)
endif (WIN32)
然后,在项目根目录中运行 cmake -G "MinGW Makefiles"
和 mingw32-make
生成一个文件 libdoublefann.dll,当链接到该文件时并包含在 .exe 目录中,终于允许我运行我的程序。
最佳答案
在doublefann.h
中的第#116行:
#if (_MSC_VER > 1300)
更改为:
#if (_MSC_VER > 1300) || defined(__MINGW32__) || defined(__MINGW64__)
此外,第 121 行:
#if defined(_MSC_VER) && (defined(FANN_USE_DLL) || defined(FANN_DLL_EXPORTS))
更改为:
#if (defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)) && \
(defined(FANN_USE_DLL) || defined(FANN_DLL_EXPORTS))
关于c - 使用 FANN 的链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19286450/
在 FANN 中,导入训练数据后,我会根据我正在使用的激活函数对其进行缩放。我使用 FANN_SIGMOID_SYMMETRIC,所以它应该是 -1.0 和 1.0。 我的训练数据范围是[-100,1
使用 FANN图书馆我得到了不可预测的结果。训练文件: 132 600 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0
我编译了一个简单的程序: #include #include #include int main(int argc, char* argv[]) { struct fann *ann =
我正在使用带有给定代码的 FANN 库。 #include #include "doublefann.h" int main() { const NUM_ITERATIONS = 10000
我正在尝试使用 MinGW 在 Windows 上构建一个基本的 FANN(快速人工神经网络)项目。然而,每当我尝试链接可执行文件时,我都会遇到一堆 undefined reference 错误。有趣
我正在尝试 FANN PHP 模块,并且能够成功运行此处的示例 http://php.net/manual/en/fann.examples-1.php 我将其修改为能够处理 5 个输入,并使用任意函
我正在使用 FANN 库构建神经网络来处理回归问题。问题是,一旦网络在相关训练集上接受了训练(这似乎工作得很好),每个单独的测试输出完全相同的输出。换句话说,给定我的 16 个预测变量的任何状态,根据
我正在开发一款使用 FANN(快速人工神经网络库)的软件。在多次尝试编写自己的 ANN 代码以编译 FANN 示例程序(这里是 C++ XOR 近似程序)的尝试失败后,我尝试过。这是来源。 #incl
我尝试在 FANN 库的帮助下编写简单的垃圾邮件分类器。为此,我收集了一些垃圾邮件和非垃圾邮件,并收集了一本最常用的英语单词词典。我使用以下代码创建了一个具有一个隐藏层的神经网络: num_input
我想通过将配置保存到数据库中来使用 FANN,然后在运行期间加载它。所有功能似乎都在将网络保存/加载到配置文件中。但是我的应用程序不能有临时文件。 如何将训练保存到字符串中/从字符串加载网络?我正在使
我一直在试验 FANN库,它似乎是一个很棒的神经网络库,但我在如何使用它方面遇到了一些问题。 所以我在这里尝试做的是训练一个神经网络,为了弄乱库,给它一个输入并期望一个输出。 FANN::neural
使用 FANN 我无法成功运行从 FANN 网站复制粘贴的代码。我在 Windows 7 和 MS Visual Studio 2008 上使用 FANN 2.2.0 版。我的 XOR 示例训练程序代
我在快速人工神经网络文档中发现种子函数是 fann_seed_rand() 但我不明白它是如何工作的。调用或不调用似乎都是一样的。 如何修复种子?主要目标是让 fann_shuffle_data()
我正在使用 FANN 来使用神经网络。 (Link to FANN) 我需要在训练网络后获得权重矩阵,但我没有从文档中找到任何内容。 (Link to documentation) 你知道如何得到这个
我有以下循环: for (int i = 1; i ::iterator it = batchFiles.begin(); it != batchFiles.end(); ++it) {
在这里,我阅读了有关 C/C++ 人工神经网络中 FANN 的很好的引用资料。实际上我正在使用 C++(在带有 g++ v4.6.1 的 Ubuntu 上)。用 C 编写的库具有 C++ 的包装器。但
我有一个标准的神经网络,我已经训练了一段时间,但直到完善为止。培训类(class)完成后,我将网络保存在磁盘上。 一段时间后,我想从它离开的地方恢复训练网络。问题是,似乎每次我开始新的训练类(clas
我刚刚构建并安装了 libfann以及相关的 python 绑定(bind)。 python 设置似乎运行正常: $ sudo python setup.py install Running SWIG
我已经尝试使用所有 apt-get 安装、pip 和直接从源代码在 Ubuntu 上安装 FANN Python 绑定(bind),但是当我尝试导入 FANN 时,同样的错误不断发生。即,它告诉我fa
我是一名优秀的程序员,十分优秀!