简体   繁体   中英

Armadillo with wxWidgets: polyfit fails to link

I have been using wxWidgets to make visual examples of a few of Armadillo's functions. 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:

> 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. I am using Windows 10 and Visual Studio 2022.

Here is the code that causes the link error. It compiles and links find if the polyfit line is commented out.

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. I also tried downloading the latest win64 OpenBLAS libraries, but the same link errors occurred.

I tried replacing the libopenblas.lib and dll from 2016 with those downloaded today. No change. It does not link if the polyfit function is called, but compiles fine if it is commented out.

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. This usually works, but for polyfit it does not.

The solution is to copy the example Visual Studio solution file example1_win64.sln and rename it. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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