automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C programs using C++ libraries


From: Billy Biggs
Subject: Re: C programs using C++ libraries
Date: Tue, 9 Dec 2003 14:18:39 -0600
User-agent: Mutt/1.5.4i

  Hi Bob, thanks for your reply.

Bob Friesenhahn (address@hidden):

> On Tue, 9 Dec 2003, Billy Biggs wrote:
> 
> > I have a C program that uses a library which internally uses C++,
> > [...]
> >
> >   1. Why does my program need to be linked with a C++ compiler in
> >   some cases and not in others?  Shared libraries should bring in
> >   their own dependencies, or libtool should find them, no?  Is
> >   something broken with how the library is built?
> 
> Operating system support varies regarding embedded dependency
> information in shared libraries, so depending on that feature is not
> portable.  Libtool would help handle library dependencies if the
> problem library was linked using libtool, since then there would be a
> .la file associated with the library which includes the known library
> dependencies.
> 
> Besides library dependencies, C++ code may also have different program
> intialization requirements (e.g. to support static construction,
> destruction, and exceptions) so a different startup module (the code
> that eventually invokes main()) may be supplied by the compiler.

  OK, this makes sense, so this establishes that I should use a C++
compiler to link my program, now it's just a question of how.

> >   2. I use libtool (but I do not understand why I use it).  Is the
> >   following correct for my program_LINK command if I use libtool:
> >
> >      program_LINK = $(LIBTOOL) --mode=link $(CXX) $(AM_CFLAGS)
> >         $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
> 
> This seems to be from an Automake generated Makefile.  Are you using
> Automake?  Passing the C++ compiler as the tool to use for linking
> seems reasonable.

  I am using automake (hence why I posted to the automake list).  I want
to make sure that this is the 'correct' way to do this though, I find it
scary to redefine the full link command like this when all I want to do
is change the linker from using CCLD to CXX.

> >   3. Who defines CXXLD and how?  I have seen this variable
> >   referenced, it looks like I should use it above (to match CCLD),
> >   but nothing seems to define it.  Is it obsolete?
> 
> I believe that this is a definition generated by the AC_PROG_LIBTOOL
> autoconf macro.  If you are not including libtool with your package,
> then this macro won't be defined.  If you are embedding libtool in
> your package, then you should definitely include AC_PROG_LIBTOOL in
> configure.ac.

  I included AC_PROG_LIBTOOL in my configure.ac, along with AC_PROG_CXX
and AC_LANG([C++]) yet none of this seems to get me CXXLD.

  $ libtool --version
  ltmain.sh (GNU libtool) 1.5.0a (1.1220.2.25 2003/08/01 19:08:35)
  Debian: 49 $

  $ autoconf --version
  autoconf (GNU Autoconf) 2.57

  Thanks again,
  -Billy





reply via email to

[Prev in Thread] Current Thread [Next in Thread]