简体   繁体   English

带 wxWidgets 的犰狳:polyfit 无法链接

[英]Armadillo with wxWidgets: polyfit fails to link

I have been using wxWidgets to make visual examples of a few of Armadillo's functions.我一直在使用 wxWidgets 制作一些 Armadillo 功能的可视化示例。 Both matrix transpose and FFT worked perfectly, but when I tried to do a simple polyfit call, the linker fails with a series of errors like these:矩阵转置和 FFT 都运行良好,但是当我尝试进行简单的 polyfit 调用时,linker 失败并出现如下一系列错误:

> error LNK2019: unresolved external symbol sdot_ referenced in function "double __cdecl   arma::blas::dot<double>(unsigned __int64,double const *,double const *)" (?? $dot@N@blas@arma@@YAN_KPEBN1@Z)

However, the exact same calls link and run perfectly if I am not also using wxWidgets to display the result.但是,如果我不使用 wxWidgets 来显示结果,则完全相同的调用可以完美地链接和运行。 I am using Windows 10 and Visual Studio 2022.我正在使用 Windows 10 和 Visual Studio 2022。

Here is the code that causes the link error.这是导致链接错误的代码。 It compiles and links find if the polyfit line is commented out.它编译并链接查找 polyfit 行是否被注释掉。

vector <double> xcoords = { 7,8,9,10,11,12,13,14,15,16,17 };
vector <double> ycoords = { 32,35,29,34,30,24,32,24,23,28,21 };
arma::vec x = arma::vec(xcoords);
arma::vec y = arma::vec(ycoords);
arma::vec p = arma::polyfit(x, y, 2);

When I installed Armadillo, I ran Cmake. to build the library, but since libopenblas.dll and.lib were already provided, it didn't create an armadillo.lib file.当我安装 Armadillo 时,我运行 Cmake. 来构建库,但是由于已经提供了 libopenblas.dll 和 .lib,所以它没有创建 armadillo.lib 文件。 I also tried downloading the latest win64 OpenBLAS libraries, but the same link errors occurred.我也尝试下载最新的 win64 OpenBLAS 库,但出现了同样的链接错误。

I tried replacing the libopenblas.lib and dll from 2016 with those downloaded today.我尝试用今天下载的替换 2016 年的 libopenblas.lib 和 dll。 No change.没变。 It does not link if the polyfit function is called, but compiles fine if it is commented out.如果调用 polyfit function,它不会链接,但如果将其注释掉,则可以正常编译。

You would think that a program that calls Armadillo functions would compile and run if you just tell the compiler where the includes are and the linker where the libraries are.你会认为调用 Armadillo 函数的程序可以编译并运行,只要你告诉编译器包含的位置和 linker 库的位置。 This usually works, but for polyfit it does not.这通常有效,但对于 polyfit 则无效。

The solution is to copy the example Visual Studio solution file example1_win64.sln and rename it.解决方案是复制示例 Visual Studio 解决方案文件 example1_win64.sln 并重命名。 Then, open that solution and replace the example code with your own, and the program will compile and link.然后,打开该解决方案并将示例代码替换为您自己的代码,程序将编译并链接。

It is probably a good idea to move that solution file into a directory you create where Visual Studio keeps all its projects, C:\Users\your_name\source\repos将该解决方案文件移动到您创建的目录中可能是个好主意,Visual Studio 会在该目录中保存其所有项目,C:\Users\your_name\source\repos

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM