[tlbuild] Building asymptote statically against libstdc++

Mojca Miklavec mojca.miklavec.lists at gmail.com
Thu May 12 12:02:57 CEST 2016


(Was: gcc-6.1 and gcc-7.0 build results)

On 30 April 2016 at 00:10, Nelson H. F. Beebe wrote:
>
>         * The Makefile does not use the standard LDFLAGS value to pass
>           linker options; it does that with a variable named LFLAGS which
>           appears in these Makefile assigments:
>
>                 LFLAGS =
>                 LIBS = $(LFLAGS)  -lglut -lGLU -lGL -lreadline -lrt -lz -lm -lncurses  $(GCLIBS)
>
> The problem with g++ is that each version has its own -lstdc++,
> usually incompatible with those of other g++ compiler versions.  Thus,
> if you use a nonnative g++ compiler, the executables produced will
> have references to libstdc++.o in locations likely unknown at other
> sites.
>
> I found that this manual adjustment of two Makefile variables to force
> use of a static -lstc++ produced a working asy:
>
>         CFLAGS =  -I${prefix}/include -std=c++11 -I${prefix}/include -fno-var-tracking
>
> and
>
>         LFLAGS='/usr/uumath/ashare/gcc/gcc-6.1.0/lib64/libstdc++.a'
> or
>         LFLAGS=/usr/uumath/ashare/gcc/gcc-7-20160424/lib64/libstdc++.a
>
> The resulting asy then has this library dependency:
>
>         % ldd asy | grep libstdc
>         libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ff1d90b5000)
>
> and that should run on any recent x86-64 GNU/Linux system.
>
> Given that asymptote is likely to be compiled with g++, it might be
> sensible to include a final variable on the link command that creates
> asy to allow overriding the default -lstdc++, e.g.,
>
>         LIBSTDCXX=-lstdc++
>         LIBS = $(LFLAGS)  -lglut -lGLU -lGL -lreadline -lrt -lz -lm -lncurses  $(GCLIBS) $(LIBSTDCXX)
>
> If the CFLAGS and LFLAGS irregularities were fixed, then I could simply write
>
>         make LIBSTDCXX=/usr/uumath/ashare/gcc/gcc-7-20160424/lib64/libstdc++.a all check
>
> to get a build and validation of asymptote.

Here's what I eventually did to get rid of the dependency on libstdc++
based on the mixture of your report and the advice from Taco:

--- Makefile.in.orig
+++ Makefile.in
@@ -11,7 +11,7 @@
 GCPPLIB = @GCPPLIB@
 GCLIBS = $(GCPPLIB) $(GCLIB)
 LFLAGS = @LDFLAGS@
-LIBS = $(LFLAGS) @PTHREAD_LIBS@ @LIBS@ $(GCLIBS)
+LIBS = $(LFLAGS) $(GCLIBS) -nodefaultlibs -Wl,-Bstatic -lstdc++
-Wl,-Bdynamic @PTHREAD_LIBS@ @LIBS@ -lgcc_eh -lgcc -lc
 DOSLIBS = $(subst -lncurses, -ltermcap, $(LIBS)) -s -static

 PERL = perl


I'm not sure if that's the proper way to do it (any advice welcome),
but it seems to have worked (following the *exact* instructions from
you did not help in my case).

Mojca


More information about the tlbuild mailing list