静态链接LAPACK [英] Statically linking against LAPACK

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

问题描述

我试图做一些软件的版本,我目前通过构建过程的脚本工作。我坚持的东西我从来没有想过我会是这样,在x86_64的Linux静态链接LAPACK。在配置过程中 AC_SEARCH_LIB([主],[LAPACK])的作品,但LAPACK单位编制不工作,例如 undefiend提及dsyev_ --no LAPACK / BLAS日常被忽视。

我确认我已经安装了图书馆,甚至用适当的选项编译他们自己,使他们与静态相同的结果。

下面是一个动态的作品我曾在我的LAPACK第一次的经验,几年前使用的例子,但不是静态: HTTP ://pastebin.com/cMm3wcwF

这两种方法我用编译有以下几种,

 的gcc -o -llapack征eigen.c
GCC -static -llapack -o征eigen.c


解决方案

您链接顺序是错误的。在code,需要他们,而不是之前后链接库。像这样的:

 的gcc -o征eigen.c -llapack
GCC -static -o征eigen.c -llapack

这应该可以解决问题联动。


要回答这个问题,后来为什么这个作品中,GNU LD 文档这样说:


  

这使得其中的命令,你写这个选项是有所不同;该
  连接器的搜索和处理库和目标文件的顺序
  它们被指定。因此,文件foo.o -lz文件bar.o'搜索库 Z'后
  文件foo.o的,但bar.o.前如果bar.o指`ž功能',
  这些功能可能不会被加载。


  
  

........


  
  

通常情况下,文件中可以找到这样的库文件,归档文件
  其成员为目标文件。链接器通过一个存档文件
  通过它扫描它定义符号是迄今会员
  一直引用但没有定义。但如果发现该文件是一个
  普通的目标文件,它以通常的方式是联系在一起的。


IE浏览器。连接器正在经历寻找未解决符号的文件,以使一遍,它遵循你提供的顺序文件(即左到右)。如果您尚未指定当一个文件被读取的依赖,链接器将无法满足依赖性。在链接列表中的每个对象被解析只有一次。

还要注意的是GNU LD可以做的情况下重新排序,其中链接共享库文件或目标文件时,检测到循环依赖。但是,静态库只解析未知符号一次。

I'm attempting to do a release of some software and am currently working through a script for the build process. I'm stuck on something I never thought I would be, statically linking LAPACK on x86_64 linux. During configuration AC_SEARCH_LIB([main],[lapack]) works, but compilation of the lapack units do not work, for example undefiend reference to 'dsyev_' --no lapack/blas routine goes unnoticed.

I've confirmed I have the libraries installed and even compiled them myself with the appropriate options to make them static with the same results.

Here is an example I had used in my first experience with LAPACK a few years ago that works dynamically, but not statically: http://pastebin.com/cMm3wcwF

The two methods I'm using to compile are the following,

gcc -llapack -o eigen eigen.c
gcc -static -llapack -o eigen eigen.c

解决方案

Your linking order is wrong. Link libraries after the code that requires them, not before. Like this:

gcc -o eigen eigen.c -llapack 
gcc -static -o eigen eigen.c -llapack

That should resolve the linkage problems.


To answer the subsequent question why this works, the GNU ld documentation say this:

It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o' searches libraryz' after file foo.o but before bar.o. If bar.o refers to functions in `z', those functions may not be loaded.

........

Normally the files found this way are library files—archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion.

ie. the linker is going to make one pass through a file looking for unresolved symbols, and it follows files in the order you provide them (ie. "left to right"). If you have not yet specified a dependency when a file is read, the linker will not be able to satisfy the dependency. Every object in the link list is parsed only once.

Note also that GNU ld can do reordering in cases where circular dependencies are detected when linking shared libraries or object files. But static libraries are only parsed for unknown symbols once.

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

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