From: wolf Date: Fri, 14 Jun 2002 08:04:16 +0000 (+0000) Subject: Linking shared libraries should usually be done using the C++ compiler rather than... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7156f09db6f7a25263c2d5a4f3c1667c8ea08b70;p=dealii-svn.git Linking shared libraries should usually be done using the C++ compiler rather than the C compiler, thus yesterdays change. However, it turns out (and I believe that past knowledge of this fact led to the use of CC in the first place) that this does not work for gcc2.95, although it does work for gcc3.0, gcc3.1, intel icc5.0 and 6.0, and pgcc4.0. For pgcc4.0, this is even necessary, as the C compiler alone cannot do this. Thus, have a new Makefile variable SHLIBLD, which we set and use for linking C++ shared libraries. git-svn-id: https://svn.dealii.org/trunk@6112 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index ceb3a34db7..13f9cc630c 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -256,9 +256,21 @@ AC_DEFUN(DEAL_II_SET_CXX_FLAGS, dnl if test "x$DEAL_II_ADVANCE_WARNING" = "xyes" ; then CXXFLAGSG="`echo $CXXFLAGSG | perl -pi -e 's/-W //g;'`" fi + + dnl In order to link shared libraries, almost all versions of gcc can + dnl use CXX, i.e. the C++ compiler. The exception is gcc2.95, for which + dnl we have to use the C compiler, unless we want to get linker errors + SHLIBLD="$CXX" + if test "$GXX_VERSION" = "gcc2.95"; then + SHLIBLD="$CC" + fi else - dnl Non-gcc compilers + dnl Non-gcc compilers. By default, use the C++ compiler also for linking + dnl shared libraries. If some compiler cannot do that and needs something + dnl different, then this must be specified in the respective section + dnl below, overriding this define: + SHLIBLD="$CXX" case "$GXX_VERSION" in ibm_xlc) diff --git a/deal.II/base/Makefile b/deal.II/base/Makefile index 7c65570130..baa1342d46 100644 --- a/deal.II/base/Makefile +++ b/deal.II/base/Makefile @@ -89,11 +89,11 @@ $(LIBDIR)/libbase.g.a: $(go-files) $(LIBDIR)/libbase.so: $(o-files) @echo "=====base=============optimized==$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(o-files) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(o-files) $(LIBDIR)/libbase.g.so: $(go-files) @echo "=====base=============debug======$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(go-files) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(go-files) diff --git a/deal.II/common/Make.global_options.in b/deal.II/common/Make.global_options.in index 98b9d30787..dc9e4c3df5 100644 --- a/deal.II/common/Make.global_options.in +++ b/deal.II/common/Make.global_options.in @@ -22,6 +22,7 @@ D = @DEAL2_DIR@ CC = @CC@ CXX = @CXX@ GXX-VERSION = @GXX_VERSION@ +SHLIBLD = @SHLIBLD@ LDFLAGS = @LDFLAGS@ F77 = @F77@ F77-VERSION = @F77_VERSION@ diff --git a/deal.II/configure b/deal.II/configure index 3bb2d788c8..a02da72747 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -2834,7 +2834,13 @@ rm -f conftest.$ac_objext conftest.$ac_ext CXXFLAGSG="`echo $CXXFLAGSG | perl -pi -e 's/-W //g;'`" fi + SHLIBLD="$CXX" + if test "$GXX_VERSION" = "gcc2.95"; then + SHLIBLD="$CC" + fi + else + SHLIBLD="$CXX" case "$GXX_VERSION" in ibm_xlc) @@ -3018,6 +3024,7 @@ echo "${ECHO_T}yes" >&6 + # Check whether --enable-multithreading or --disable-multithreading was given. if test "${enable_multithreading+set}" = set; then enableval="$enable_multithreading" @@ -6952,6 +6959,7 @@ s,@GXX_VERSION@,$GXX_VERSION,;t t s,@CXXFLAGSG@,$CXXFLAGSG,;t t s,@CXXFLAGSO@,$CXXFLAGSO,;t t s,@CXXFLAGSPIC@,$CXXFLAGSPIC,;t t +s,@SHLIBLD@,$SHLIBLD,;t t s,@LDFLAGSPIC@,$LDFLAGSPIC,;t t s,@enablemultithreading@,$enablemultithreading,;t t s,@withmultithreading@,$withmultithreading,;t t diff --git a/deal.II/configure.in b/deal.II/configure.in index a22cda94f2..9f31b0045c 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -106,6 +106,7 @@ AC_SUBST(GXX_VERSION) AC_SUBST(CXXFLAGSG) AC_SUBST(CXXFLAGSO) AC_SUBST(CXXFLAGSPIC) +AC_SUBST(SHLIBLD) AC_SUBST(LIBS) AC_SUBST(LDFLAGS) AC_SUBST(LDFLAGSPIC) diff --git a/deal.II/deal.II/Makefile b/deal.II/deal.II/Makefile index ec1d60fcca..2a8ac960d7 100644 --- a/deal.II/deal.II/Makefile +++ b/deal.II/deal.II/Makefile @@ -119,29 +119,29 @@ $(LIBDIR)/libdeal_II_3d.a: $(o-files-3d) $(LIBDIR)/libdeal_II_1d.g.so: $(go-files-1d) @echo "=====deal.II====1d====debug======$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(go-files-1d) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(go-files-1d) $(LIBDIR)/libdeal_II_1d.so: $(o-files-1d) @echo "=====deal.II====1d====optimized==$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(o-files-1d) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(o-files-1d) $(LIBDIR)/libdeal_II_2d.g.so: $(go-files-2d) @echo "=====deal.II====2d====debug======$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(go-files-2d) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(go-files-2d) $(LIBDIR)/libdeal_II_2d.so: $(o-files-2d) @echo "=====deal.II====2d====optimized==$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(o-files-2d) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(o-files-2d) $(LIBDIR)/libdeal_II_3d.g.so: $(go-files-3d) @echo "=====deal.II====3d====debug======$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(go-files-3d) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(go-files-3d) $(LIBDIR)/libdeal_II_3d.so: $(o-files-3d) @echo "=====deal.II====3d====optimized==$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(o-files-3d) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(o-files-3d) diff --git a/deal.II/doc/development/Makefile b/deal.II/doc/development/Makefile index e7d96bac5f..80639e119c 100644 --- a/deal.II/doc/development/Makefile +++ b/deal.II/doc/development/Makefile @@ -16,6 +16,7 @@ makefiles.html: Makefile makefiles.1.html $D/common/Make.global_options makefile @echo '
  • GXX-VERSION=$(GXX-VERSION)' >> $@ @echo '
  • F77=$(F77)' >> $@ @echo '
  • F77-VERSION=$(F77-VERSION)' >> $@ + @echo '
  • SHLIBLD=$(SHLIBLD)' >> $@ @echo '
  • PERL=$(PERL)' >> $@ @echo '
  • DEAL_II_MAJOR=$(DEAL_II_MAJOR)' >> $@ @echo '
  • DEAL_II_MINOR=$(DEAL_II_MINOR)' >> $@ diff --git a/deal.II/doc/development/makefiles.1.html b/deal.II/doc/development/makefiles.1.html index 08bf31075b..4f6b10b404 100644 --- a/deal.II/doc/development/makefiles.1.html +++ b/deal.II/doc/development/makefiles.1.html @@ -101,6 +101,16 @@ +
    SHLIBLD
    +

    + Executable name of compiler that is used to link object + files to shared libraries. This will usually be the C++ + compiler, but as this does not work for gcc 2.95, it is the + C compiler in that case. +

    +
    + +
    PERL

    Executable name of the `perl' program diff --git a/deal.II/lac/Makefile b/deal.II/lac/Makefile index e111fa0262..4726750f16 100644 --- a/deal.II/lac/Makefile +++ b/deal.II/lac/Makefile @@ -62,11 +62,11 @@ $(LIBDIR)/liblac.g.a: $(go-files) $(LIBDIR)/liblac.so: $(o-files) @echo "=====lac==============optimized==$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(o-files) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(o-files) $(LIBDIR)/liblac.g.so: $(go-files) @echo "=====lac==============debug======$(MT)== Linking library: $(@F)" - @$(CXX) $(LDFLAGS) -shared -o $@ $(go-files) + @$(SHLIBLD) $(LDFLAGS) -shared -o $@ $(go-files)