English 中文(简体)
试图安装和使用 LAPACK+++, 装入共享库的问题
原标题:Trying to install and use LAPACK++, problems with loading shared libraries

我最近才开始使用图书馆,我对拉帕卡++(lapack++)和使其运作有些困难,我将解释我迄今所做的和尝试。

我首先安装了 BLAS 和 LAPACK, 并且那很好。 我现在安装了 LAPACK+++ 版本 2.5.2 (http://lapackpp. sourceforge. net/), 这样我就可以在 C/ C++ 中调用各种线性代数例。 在我配置、 制造并安装后, 将所有 C/ C++ 头文件都放置在 / usr/ local/ including/lapackpp/ 其中的一些文件 。

arch.h
bmd.h 
gmf.h    
lapackc.h 
lautil.h     
spdmd.h 
ultgmd.h
bfd.h
...

以及以下文件,载于/usr/local/lib

liblapackpp.la
liblapackpp.so
liblapackpp.so.14
liblapackpp.so.14.2.0

现在如果我试着用 g++ 来编译

#include <lapackpp/lapackpp.h>
using namespace std;

int main(int argc, char** argv) {
return 0;
}

我得到以下输出...

In file included from /usr/local/include/lapackpp/lapackc.h:14,
from /usr/local/include/lapackpp/lapack.h:10,
from /usr/local/include/lapackpp/lapackpp.h:16,
from test.cpp:1:
/usr/local/include/lapackpp/lacomplex.h:45:23: error: laversion.h: No such file or directory
/usr/local/include/lapackpp/lacomplex.h:48:17: error: f2c.h: No such file or directory
In file included from /usr/local/include/lapackpp/lapackpp.h:47,
from test.cpp:1:
/usr/local/include/lapackpp/latmpl.h:36:22: error: lafnames.h: No such file or directory

我通过在页眉文件中明确写出页眉文件的位置来解决了这个问题,因为页眉文件造成了麻烦。

Eg. I replaced #include with #include

这样做之后,我的代码编译精细。

如果我现在试着编译代码

#include <cstdlib>
#include <iostream>
#include <lapackpp/lapackpp.h>

using namespace std;

int main(int argc, char** argv) {

LaGenMatDouble A(5,5);
cout << "This is a test." << endl;

return 0;
}

通过打字

g++ test.cpp -o test -I usr/local/include/lapackpp

我犯以下错误

/tmp/ccAq6nkP.o: In function `main :
test.cpp:(.text+0x22): undefined reference to `LaGenMatDouble::LaGenMatDouble(int, int) 
test.cpp:(.text+0x4f): undefined reference to `LaGenMatDouble::~LaGenMatDouble() 
test.cpp:(.text+0x67): undefined reference to `LaGenMatDouble::~LaGenMatDouble() 
collect2: ld returned 1 exit status

(关于LaGenMatDouble的信息是这里)

这说明我可能跟图书馆联系错了?

在一些谷歌后,我意识到我需要连接到信头文件, 使用 -I 和共享的图书馆 L 和图书馆本身 使用 -llapackpp, 所以我输入

g++ test.cpp -o test -I usr/local/include/lapackpp -L usr/local/lib -llapackpp

which compiled the code, now when I ran the program 通过打字 ./test I go the error

./test: error while loading shared libraries: liblapackpp.so.14: cannot open shared object file: No such file or directory

现在我困惑了

我不确定这是否与问题有关 但当我打字时

pkg-config lapackpp --libs

我得到

Package lapackpp was not found in the pkg-config search path. Perhaps you should add the directory containing `lapackpp.pc to the PKG_CONFIG_PATH environment variable No package lapackpp found

拉包和Blas也发生同样的情况。

我不确定该怎么办 任何帮助都会非常感激,谢谢!

最佳回答

链接是正常的, 因为您告诉链接库所在的链接, 但执行失败, 因为装载器不知道您的库的位置( 您可以检查执行 < code> ldd yourapp 的操作, 显示您应用程序所需的库) 。

通常,您可以通过告诉装入器图书馆所在位置的图书馆通过变量 LD_libraary_PATH , 但它是一个粗略的工具。 不同的解决方案是直接将该指令编码在可执行文件中, 如描述的 < href=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

问题回答

如果您在包裹 LAPACK (和/或 BLAS) 的 C++ 库后, 使用一个更现代化的库, 如 < a href=" http:// arma. sourceforge. net" rel= "nofollow" > Armadillo 。 除了使用 LAPACK 作为求解器和矩阵乘数的后端, 还可以使用表达式模板来加速操作 。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签