Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc ignore casing of symbol names while linking

Tags:

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
like image 442
Cetin Sert Avatar asked Feb 14 '10 00:02

Cetin Sert


2 Answers

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.

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:

  • using #define's
  • using the C interfaces to BLAS and LAPACK.
like image 142
F'x Avatar answered Oct 03 '22 18:10

F'x


I think you might be in for some trouble. Section 6.4.2.1 of the C spec says "Lowercase and uppercase letters are distinct" with respect to identifiers. That means that as far as your compiler and linker are concerned, _DGEQP3 and _dgeqp3 are different symbols. You can probably add some #define statements in a platform-specific header to line things up for you.

Is it because you're linking against a windows library rather than whatever you were using before that this bug showed up?

like image 38
Carl Norum Avatar answered Oct 03 '22 17:10

Carl Norum