[gmx-developers] Re: help needed: static builds with cmake
roland at utk.edu
Fri Oct 29 17:42:14 CEST 2010
On Fri, Oct 29, 2010 at 7:16 AM, Szilárd Páll <szilard.pall at cbr.su.se>wrote:
> > On Thu, Oct 28, 2010 at 6:42 PM, Szilárd Páll <szilard.pall at cbr.su.se>
> > wrote:
> >> Hi,
> >> > Too me this looks like a bug in cmake. It has
> >> > (in Modules/Platform/Linux.cmake) LINK_STATIC_C_FLAGS "-Wl,-Bstatic".
> >> > But I
> >> > think it should include the -static for gcc. It might have been
> >> > sufficient
> >> > to have the Wl,-Bstatic but at least now gcc requires also the static
> >> > option. If you agree we should file a cmake bug report.
> >> I'm not sure it's a bug. The man page of ld clearly states that
> >> -Bstatic, -static, -dn, and -non_shared are equivalent. It's just that
> >> while gcc -Bstatic gets simply passed down to the linker, -static
> >> actually does something and this something makes things work -- I
> >> guess. Also, asking on the CMake mailing list first might might be a
> >> good idea.
> > Yes their are equivalent for ld. But not for gcc. Gcc adds the required
> > libraries (e.g. libc, crt1.o, ...) before calling ld. And if you use
> > dynamic libraries the required libraries include libgcc_s. Thus you get
> > error. But since this is a compiler argument, I think it is wrong that
> > adds -Wl,-Bstatic without -static. "-Wl,-static" would be as wrong as
> > "-Wl,Bstatic". Only -static (without the "-Wl") is OK (optionally
> > with the other flags). Because it is not enough to tell the linker
> > telling the compiler to generate the correct list of required libs.
> OK, that makes sense. I'll post today on the CMake mailing list and
> will get back with an update.
> >> s
> >> > Does step 1 apply to the gromacs internal libraries (libmd, libgmx,
> >> > If
> >> > so, I think step 1 by itself is good enough.
> >> No, for the gramcs internal libs there is the BUILD_SHARED_LIBS
> >> option. This is for the external libraries (fftw3, libxml2, etc).
> > Yes. Just realized that.
> > I suggest to add step 1 and wait on step 2. Step 1 by itself is very
> > It reduces the number of required libraries (often probably enough). And
> > allows to compile a fully static library relatively easily. One only
> > to add the static flag correctly for the compiler (e.g. -static for GCC).
> > And one won't get error messages like "attempted static link of dynamic
> > object".
> I'll add step 1. Just checked and it seems that on most UNIX systems
> static libraries have ".a" suffix (a suffix preference list is used
> internally in CMake). Can you (or anyone else) confirm that on most
> common HPC *NIX systems this is the case?
> Moreover, as it's not very harmful to have an exclusive check that
> enables the option for all UNIX but APPLE and CYGWIN (CMake
> terminology) I'll do that.
Don't know about HPUX. Cygwin should work too. And even MingW. If you
use CMAKE_STATIC_LIBRARY_SUFFIX which is lib for MingW. How about you just
disable the option if CMAKE_STATIC_LIBRARY_SUFFIX is not set by Cmake?
ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
865-241-1537, ORNL PO BOX 2008 MS6309
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gromacs.org_gmx-developers