Project

General

Profile

Bug #541

CMake, FindFFTW*.cmake modules and static linking

Added by Rossen Apostolov about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Category:
mdrun
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

Even if a static build is requested, the FindFFTW*.cmake scripts insist on linking against *.so, instead of *.a files.

Associated revisions

Revision 29cbabdb (diff)
Added by Szilárd Páll about 9 years ago

added CMake option GMX_PREFER_STATIC_LIBS (also fixes bug #541)

This option instructs CMake to prefer static external libs when both static
and shared version available. This makes possible linking statically against
external libraries (e.g. fftw, xml2).

The option only available on *NIX platforms, except APPLE and CYGWIN.

Note, that when the option is enabled UILD_SHARED_LIBS gets disabled.
Also note, that with this option on, the binaries built will still be
dynamically linked against system libraries.

History

#1 Updated by Roland Schulz about 9 years ago

the same applies for the XML libraries

#2 Updated by Szilárd Páll about 9 years ago

(In reply to comment #0)

Even if a static build is requested, the FindFFTW*.cmake scripts insist on
linking against *.so, instead of *.a files.

Note that there is no way to request a static build - yet! The BUILD_SHARED_LIBS option only refers to whether static or shared gromacs libs are built, so it's not equivalent of the --enable-static configure option.

I working on implementing this functionality.

#3 Updated by Roland Schulz about 9 years ago

because this was not concluded on the email thread. I copy my message here:

according to the bug Erik posted (http://www.vtk.org/Bug/view.php?id=1644) the proposed solution is to use -L and -l and not the file-name (with full path) of the library. And then use e.g. for gcc:
gcc -Wl,-Bstatic # archive only
gcc -Wl,-Bdynamic # shared-then-archive
depending on whether we want static or shared. And cmake is supposed to know the correct compiler/linker flags to choose static/shared for each platform and compiler.
Why don't we do this?

#4 Updated by Szilárd Páll about 9 years ago

(In reply to comment #3)

because this was not concluded on the email thread. I copy my message here:

according to the bug Erik posted (http://www.vtk.org/Bug/view.php?id=1644) the
proposed solution is to use -L and -l and not the file-name (with full path) of
the library. And then use e.g. for gcc:
gcc -Wl,-Bstatic # archive only
gcc -Wl,-Bdynamic # shared-then-archive
depending on whether we want static or shared. And cmake is supposed to know
the correct compiler/linker flags to choose static/shared for each platform and
compiler.
Why don't we do this?

Fixed in commit 29cbabdb:

added CMake option GMX_PREFER_STATIC_LIBS (also fixes bug #541)
This option instructs CMake to prefer static external libs when both static
and shared version available. This makes possible linking statically against
external libraries (e.g. fftw, xml2).
The option only available on *NIX platforms, except APPLE and CYGWIN.
Note, that when the option is enabled UILD_SHARED_LIBS gets disabled.
Also note, that with this option on, the binaries built will still be
dynamically linked against system libraries.

Also available in: Atom PDF