Re: linking C++ object files

Bram Moolenaar <[email protected]> Fri, 26 Nov 2004 11:43:37 +0100
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Luc Hermitte wrote:

> > That seems to avoid the problem for me.  It's still a problem though,
> > telling Aap to use gcc should still result in g++ used for linking.
> > This patch appears to fix that:
> 
> That's much better. Thanks!
> 
> However, that's not perfect yet.
> 
> With a build from scratch, that's fine: g++ is correctly called during
> the link phase.
> However, if I only need to (re)link (because I forget a library in the
> first place, or I decide to use another library), aap calls gcc and not
> g++.
> 
> I guess we should keep in mind (/on the disk) the object files have been
> produced with g++ and not gcc.

This is a known problem that is only partly fixed.  When using build
rules you can use the ">always" command block to add an attribute to the
object file even when it's not build.  That doesn't work for actions
though, and the gcc tool uses actions.

Simplest solution is to force the linker with:

	C_BUILD_ACTION = build_gxx

> Anyway, as it is quite rare we only need to just link, this is not
> critical.

But I want it to work...

> BTW, I notice that the error message says I have a problem into
> test_realpath.cpp and not tests/test_realpath.cpp. However, I do not
> know if it is an issue that'd better be fixed with aap, or if it must
> must done in a compiler-plugin, that should try to detect in which
> directory the file is.

There should be "change directory" messages in the log file.

> > > BTW, is there an AAP compiler-plugin for vim somewhere ?
> > No, you can simply do:
> > 	:set makeprg=aap
> 
> Actually, I was thinking to correctly detect some AAP error messages as
> error messages.
> For instance, I have defined compiler/aap.vim with:
>     ....
>     " %+A is used to accept "Do not know" in the error message
>     set efm+=%+EAap:\ Do\ not\ know\ %m
>     " GCC link errors (undefined reference to..)
>     set efm+=%[%^)]%#):%f:%m
>     ....
> but I was wondering if a more complete solution already exist.

It could be useful, I suppose.  If you can write a first version of an
Aap compiler plugin I can include it with Vim.

-- 
Q: Why does /dev/null accept only integers?
A: You can't sink a float.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/