[CMake] Auxiliary fortran link libraries?
John Cary
cary at txcorp.com
Mon Jul 19 09:37:19 EDT 2010
So this is very cool.
Somehow it is not quite working for me. My project is entirely
C++ with C and C++ libraries, but it links to a system lapack
and blas that reference the fortran libraries, so my final link
has the errors,
<start of long link line>
trilinos/lib/libml.a /contrib/trilinos/lib/libamesos.a
/contrib/trilinos/lib/libifpack.a /contrib/trilinos/lib/libepetraext.a
/contrib/trilinos/lib/libgaleri.a /contrib/trilinos/lib/libtriutils.a
/contrib/trilinos/lib/libepetra.a /contrib/trilinos/lib/libteuchos.a
/contrib/lapack_cmake-3.2.1-ser/lib/liblapack.a
/contrib/lapack_cmake-3.2.1-ser/lib/libblas.a -lz
Undefined symbols:
"__gfortran_transfer_character", referenced from:
_xerbla_ in liblapack.a(xerbla.f.o)
"__gfortran_transfer_integer", referenced from:
_xerbla_ in liblapack.a(xerbla.f.o)
_dlamc2_ in liblapack.a(dlamch.f.o)
_slamc2_ in liblapack.a(slamch.f.o)
I do have
ENABLE_LANGUAGE(Fortran)
INCLUDE(FortranCInterface)
in my CMakeLists.txt, and it is finding what you say below:
numbersix.cary$ grep IMPLICIT CMakeFiles/CMakeFortranCompiler.cmake
SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "gfortran")
SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES
"/usr/local/lib/gcc/x86_64-apple-darwin10/4.5.0;/usr/local/lib")
So is my problem that my project actually has no .{F,F90} files
that are compiled?
Can I force the addition of these libraries without referencing
them explicitly?
Thx.....John Cary
On 7/19/10 6:35 AM, Brad King wrote:
> On 07/18/2010 09:10 PM, John Cary wrote:
>
>> Thanks for your help with this. I did
>> INCLUDE(FortranCInterface), but I did not
>> see in CMakeCache.txt any variables that
>> might contain the fortran libs needed by
>> the C/C++ linkers (e.g., libgfortran).
>> Did I miss something?
>>
> The FortranCInterface module detects the *mangling* of Fortran symbols
> with respect to C and does not deal with implicit Fortran library
> dependencies. CMake 2.8 automatically handles the implicit libraries
> for mixed-language binaries.
>
> After configuring your build tree look in CMakeFiles/CMake*Compiler.cmake.
> There are variables like these:
>
> SET(CMAKE_C_IMPLICIT_LINK_LIBRARIES "...")
> SET(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "...")
> SET(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;...")
> SET(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "...")
> SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "gfortranbegin;gfortran;...")
> SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "...")
>
> However, you should never need to reference them explicitly. When CMake
> generates the link line for a binary that includes both Fortran and C++
> we automatically use these variables to list the libraries not known to
> be implicitly linked by the compiler used to drive the linker.
>
> -Brad
>
>
More information about the CMake
mailing list