链接时,gcc忽略符号名称的大小写 [英] gcc ignore casing of symbol names while linking
问题描述
我正在开发的一种软件,它使用全小写的符号名称将NETLIB BLAS/LAPACK嵌入到其源代码中,但是现在在将应用程序移植到Windows时,我发现该平台的Intel MKL和其他几种BLAS/LAPACK实现都使用了所有软件-大写符号名称.有没有办法告诉gnu编译器/链接器在匹配符号名称时忽略大小写?
A software I am working on ships with NETLIB BLAS/LAPACK embedded into its sources using all-lowercase symbol names but now while porting the application to windows I discovered that Intel MKL and several other BLAS/LAPACK implementations for this platform use all-uppercase symbol names. Is there a way to tell the gnu compiler/linker to ignore case while matching symbol names?
.
.
.
undefined reference to `_dgeqp3'
.
.
.
$ nm /lib/LAPACK.lib | grep -i " T _dgeqp3"
00000000 T _DGEQP3
推荐答案
您看到的差异是由于Fortran调用约定引起的:在Fortran中,符号大小写并不重要,因此每个编译器都有一种翻译Fortran符号名称的方法转换为汇编器符号名称:GNU编译器通常将所有字符都转换为小写,Windows上的Intel则将其全部转换为大写.
The difference you're seeing is due to Fortran calling conventions: in Fortran, symbol case is unimportant, and thus every compiler has a way to translate Fortran symbol names into assembler symbol names: GNU compilers usually translate all to lowercase, Intel on Windows goes for uppercase.
如果使用的是Fortran代码,则可以在较旧的g77
编译器上使用-fsymbol-case-upper
选项(较新的gfortran
编译器没有此选项).否则,没有C的简单答案,除了:
If you're working with Fortran code, you can use the -fsymbol-case-upper
option on the older g77
compiler (the newer gfortran
compiler doesn't have this). Otherwise, no simple answer for C, except:
- 使用
#define
的 - 使用C接口连接BLAS和LAPACK.
这篇关于链接时,gcc忽略符号名称的大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!