View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0012912CMakeModulespublic2012-01-24 21:232013-07-30 09:09
Reportertgallagher 
Assigned Totgallagher 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformLinuxOSUbuntuOS Version11.10
Product VersionCMake 2.8.7 
Target VersionFixed in Version 
Summary0012912: FindLAPACK does not work when trying static linking
DescriptionThe FindLAPACK module does not work when trying to use static linking. When trying to compile the test file to check if the library works, it gives:

/usr/bin/gfortran CMakeFiles/cmTryCompileExec.dir/testFortranCompiler.f.o -o cmTryCompileExec
 -rdynamic -Wl,--start-group /usr/lib/liblapack.a /usr/lib/libblas.a -Wl,--end-group
/usr/lib/libblas.a(xerbla.o): In function `xerbla_':
(.text+0x0): multiple definition of `xerbla_'
/usr/lib/liblapack.a(xerbla.o):(.text+0x0): first defined here
collect2: ld returned 1 exit status
make[2]: *** [cmTryCompileExec] Error 1
make[2]: Leaving directory `/data/lagrangianBuild/CMakeFiles/CMakeTmp'
make[1]: *** [CMakeFiles/cmTryCompileExec.dir/all] Error 2
make[1]: Leaving directory `/data/lagrangianBuild/CMakeFiles/CMakeTmp'
make: *** [all] Error 2

The double-definition is because the static liblapack already has all the code it needs from libblas in it, but the FindLAPACK module calls FindBLAS and links against both liblapack and libblas.

The solution is to check if BLA_STATIC is set, do not call find_package(BLAS) because the lapack library will already have all the functions it needs in it.
Steps To ReproduceCompile something using the find_package(LAPACK REQUIRED) signature with BLA_STATIC defined.
Additional InformationI have many other fixes related to FindBLAS and FindLAPACK as well as a new module request. If approved for the new module and given access, I can fix this bug as well.
TagsNo tags attached.
Attached Files

 Relationships
related to 0014320closedKitware Robot FindLAPACK doesn't work if BLA_STATIC is set to ON 

  Notes
(0028414)
tgallagher (developer)
2012-01-26 20:38

The problem is actually with the build of LAPACK provided by Ubuntu. Without linking to libblas doesn't work as there are many missing references. Linking with libblas also does not work as the liblapack from Ubuntu contains a duplicate function.

It's possible to overcome this by using the:

-Wl,--allow-multiple-definition

when linking. But, this may have unintended consequences. There is nothing to do from CMake's side to fix this.
(0028415)
tgallagher (developer)
2012-01-26 20:40

The problem is with Ubuntu's distribution of LAPACK and not CMake.

 Issue History
Date Modified Username Field Change
2012-01-24 21:23 tgallagher New Issue
2012-01-25 17:22 Brad King Assigned To => tgallagher
2012-01-25 17:22 Brad King Status new => assigned
2012-01-26 20:38 tgallagher Note Added: 0028414
2012-01-26 20:38 tgallagher OS OpenSuSE => Ubuntu
2012-01-26 20:38 tgallagher OS Version 12.1 => 11.10
2012-01-26 20:40 tgallagher Note Added: 0028415
2012-01-26 20:40 tgallagher Status assigned => closed
2012-01-26 20:40 tgallagher Resolution open => no change required
2013-07-30 09:09 Brad King Relationship added related to 0014320


Copyright © 2000 - 2018 MantisBT Team