[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using a different C++ Standard Library
From: |
Liviu Nicoara |
Subject: |
Re: Using a different C++ Standard Library |
Date: |
Thu, 15 Dec 2005 12:32:23 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.7 (X11/20050923) |
Hi Ralf,
Thanks for the reply.
Since I posted the message I took the time to dig into the libtool
script and the generated Makefiles looking for clues. I am afraid I do
not have my exact original setup available for a cut&paste here but only
an approximation:
configure.ac:
-------------
AC_INIT([tools],[0.0.1],[])
AC_CONFIG_HEADERS(include/rw/tools/imp/_config.h)
AC_CONFIG_MACRO_DIR([etc/config/macros])
AM_INIT_AUTOMAKE(tools, 0.0.1)
########################################################################
AC_PROG_CXX(aCC,CC,g++)
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET(gmake)
AM_PROG_AS
########################################################################
## C++ Standard Library related configuration
AC_ARG_WITH([stdcxx],
AC_HELP_STRING([--with-stdcxx=directory],
[My other C++ Standard Library]),
[
if test x"${withval}" = x""; then
echo "Directory required for non-native stdlib"
exit
fi
## Use gcc for compilation
CXX=${CC}
MY_CXX_EXTRA_CPPFLAGS="-I${withval}/include
-I${withval}/include/ansi"
MY_CXX_EXTRA_LDFLAGS="-L${withval}/lib"
MY_CXX_EXTRA_LIBS="-lstdcxx -lsupc++"
],[])
AC_SUBST([MY_CXX_EXTRA_CPPFLAGS],[${MY_CXX_EXTRA_CPPFLAGS};])
AC_SUBST([MY_CXX_EXTRA_LDFLAGS], [${MY_CXX_EXTRA_LDFLAGS};])
AC_SUBST([MY_CXX_EXTRA_LIBS], [${MY_CXX_EXTRA_LIBS};])
........
source/Makefile.am:
-------------------
lib_LTLIBRARIES = libtools.la
libtools_la_SOURCES = lib.cpp
## Library flags
libtools_la_CXXFLAGS = -I. -I$(top_srcdir)/include @RW_CXX_EXTRA_CPPFLAGS@
libtools_la_LDFLAGS = @MY_CXX_EXTRA_LDFLAGS@
libtools_la_LIBADD = @MY_CXX_EXTRA_LIBS@
With this setup and invoking configure with the directory where stdlib
is installed (--with-stdcxx=dir) I get what I posted previously.
Please notice in my previous posting that the invocations of g++ had
-nostdlib on the link line followed by a set of explicit link paths (-L)
and the GNU C++ libraries.
I have a workaround - which along with the explicit change of CXX to gcc
can probably be qualified as an 'orrible 'ack: in order to link using
gcc I place this line in my source/Makefile.am:
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS)
$(AM_LDFLAGS) $(LDFLAGS) -o $@
Please notice the missing --tag=CXX which accomplishes the goal.
In response to your suggestions for a fix, more valuable to me as a user
would probably be an option to indicate I only want minimal C++ language
support. How about no C++ support at all and allowing me to indicate all
libraries I need?
Thanks,
Liviu
Ralf Wildenhues wrote:
> Hi Liviu,
>
> * Liviu Nicoara wrote on Tue, Dec 13, 2005 at 08:17:38PM CET:
>
>>I have problems in trying to get libtool to use the C++ standard library
>>I want.
>>
>>I have my own C++ stdlib created with gcc on Linux. This library is
>>compiled using gcc and linked with gcc; the only C++ library it links is
>>libsupc++ which provides the language support. This C++ standard library
>>is built using its own infrastructure, not autotools based.
>>
>>I want to use this library further in building another library - this
>>library has an autotools based infrastructure. I indicate the include
>>paths and the link paths and libraries (my stdlib and libsupc++) via
>>CXXFLAGS, LDFLAGS, etc. in configure.ac and I see all the flags and
>>options PRESENT in the Makefiles. Also, I set CXX to gcc in configure.ac
>>in order to prevent the usage of g++. This results in the compilation of
>>the library sources going as (trimmed for clarity):
>
>
>
> Please post exactly how you configured. If you did not have -nostdlib
> in CXXFLAGS nor LDFLAGSE, please try again configuring, and put it in
> CXXFLAGS, or even like this
> CXX='g++ -nostdlib'
>
> (This hopefully can serve as a workaround until this libtool limitation
> is fixed.) Untested, please post any issues that arise with this; you
> may have to adjust LIBS to make $CXX link successfully in configure
> tests.
>
>
>>But the linking goes like this:
>>
>>../libtool --tag=CXX --mode=link gcc -g
>>-L/build/nicoara/11d-mystdlib/lib -lmystdlib -o libtools.la -rpath
>>/usr/local/lib lib.lo
>>
>>g++ -shared -nostdlib
>>/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../crti.o
>>/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/crtbeginS.o .libs/lib.o
>>-Wl,--rpath -Wl,/usr/lib/. -Wl,--rpath -Wl,/usr/lib/.
>>-L/usr/lib/gcc-lib/i486-slackware-linux/../..
>>-L/usr/lib/gcc-lib/i486-slackware-linux/../../../i486-slackware-linux/lib
>>-L/usr/i486-slackware-linux/lib -L/usr/i486-slackware-linux/bin
>>-L/build/nicoara/11d-mystdlib/lib -lmystdlib
>>-L/usr/lib/gcc-lib/i486-slackware-linux/3.3.4
>>-L/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/lib
>>-L/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../..
>>/usr/lib/./libstdc++.so -lm -lc -lgcc_s
>>/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/crtendS.o
>>/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../crtn.o -Wl,-soname
>>-Wl,libtools.so.0 -o .libs/libtools.so.0.0.0
>>
>>My stdlib is buried deep within the list of lib paths and the linking
>>process uses g++ although please notice that both compilation and
>>linking phase use --tag=CXX and only the link uses g++. The end result
>>is that I end up with symbols linked in from both gnu's stdc++ and my
>>stdlib.
>
>
> Yep. :-/
>
>
>>My approach is probably fundamentally flawed as a consequence of my
>>limited understanding of libtool's inner workings.
>
>
> Nope, your understanding is not flawed. We need to implement a way to
> specify:
> - I want the C++ stdlib linked in
> - I want (possibly) only minimal runtime lib linked in
> - none of the above.
>
> I think I wrote about this before, but can't find the mail quickly ATM,
> and I don't have time to work on thie
>
> Maybe we also need a way to just detect your C++ standard library.
>
>
>>Any suggestion in how to implement this building process is welcome.
>>Specifically I am interested in how to instruct the building process to
>>use the C compiler instead of the C++ one when using my stdlib and/or
>>how to instruct (force?) libtool in not bringing in the compiler's C++
>>stdlib (GNU) in the link phase.
>
>
> Hope that helps a bit. Please post your results, thank you.
>
> Cheers,
> Ralf
>