链接LAPACK / BLAS库 [英] Linking LAPACK/BLAS libraries

查看:642
本文介绍了链接LAPACK / BLAS库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:结果
我正在写在C和Fortran 77的混合项目,现在需要的LAPACK / BLAS库链接到项目(全部在Linux环境中)。有问题的LAPACK是netlib.org 3.2.1版本(包括BLAS)。该库是用最高级别的Makefile(请lapacklib,使blaslib)编译。

Background:
I am working on a project written in a mix of C and Fortran 77 and now need to link the LAPACK/BLAS libraries to the project (all in a Linux environment). The LAPACK in question is version 3.2.1 (including BLAS) from netlib.org. The libraries were compiled using the top level Makefile (make lapacklib and make blaslib).

问题:结果
链接期间的错误消息称,某些(不是全部)BLAS例程从LAPACK例程称为是不确定的。这给了我一些头痛,但图书馆的外观的顺序链接被更改的问题最终得到解决的时候(在Makefile)。

Problem:
During linking, error messages claimed that certain (not all) BLAS-routines called from LAPACK-routines were undefined. This gave me some headache but the problem was eventually solved when (in the Makefile) the order of appearance of the libraries to be linked was changed.

code:结果
在下文中,(a)是错误的,而(b)不。该联是由(C)进行的。结果,
    (一)LIBS = $(LAPACK)/blas_LINUX.a $(LAPACK)/lapack_LINUX.a结果
    (二)LIBS = $(LAPACK)/lapack_LINUX.a $(LAPACK)/blas_LINUX.a结果
    (三)GCC -Wall -O -o $ @ project.o project.a $(LIBS)

Code:
In the following, (a) gives errors while (b) does not. The linking is performed by (c).
(a) LIBS = $(LAPACK)/blas_LINUX.a $(LAPACK)/lapack_LINUX.a
(b) LIBS = $(LAPACK)/lapack_LINUX.a $(LAPACK)/blas_LINUX.a
(c) gcc -Wall -O -o $@ project.o project.a $(LIBS)

问:结果
可能是什么只有一些例程的未定义的引用的原因,是什么让出现的顺序有关?

Question:
What could be the reason for the undefined references of only some routines and what makes the order of appearance relevant?

推荐答案

的LAPACK库需要的东西从BLAS,然后从连接器的搜索从左到右。因此,把BLAS LAPACK(选项(B))后,工作。

The LAPACK library needs stuff from BLAS, and the linker searches from left to right. So, putting BLAS after LAPACK (option (b)), worked.

如果你想让它总是工作,不分先后顺序,可以使用连接基团:

If you want it to always work, regardless of the order, you can use linker groups:

-Wl,--start-group $(LAPACK)/blas_LINUX.a $(LAPACK)/lapack_LINUX.a -Wl,--end-group

这告诉连接器通过库循环,直到所有的符号得到解决(或者直到它注意到再次循环不会帮助)。

That tells the linker to loop through the libraries until all symbols get resolved (or until it notices that looping again won't help).

这篇关于链接LAPACK / BLAS库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆