Can't compile C++ code

View: New views
4 Messages — Rating Filter:   Alert me  

Can't compile C++ code

by cd1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone,

I'm trying to use distcc to compile C++ code but I can't make it work. The objects are compiled, but the linking process doesn't find the standard libraries.

After looking at the logs, I found out distcc calls "cc" to compile my code, even when it's C++. and that's the reason (I think) the linking doesn't work. If I run "make CC=cc", it doesn't work (that's locally, no distcc involved). So, if distcc calls "cc" behind the scenes, I think it won't work either. Why doesn't distcc uses "cc" to C code and "c++" to C++ code (or gcc/g++)? What can I do to make this work? I've already tried using symlinks, appending the masquerade directory in the PATH, but I've got no success.

Thanks for any help!

--
Crístian Deives dos Santos Viana [aka CD1]

__
distcc mailing list            http://distcc.samba.org/
To unsubscribe or change options:
https://lists.samba.org/mailman/listinfo/distcc

Re: Can't compile C++ code

by mbp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/7/10 Crístian Viana <cristiandeives@...>:

> Hi everyone,
>
> I'm trying to use distcc to compile C++ code but I can't make it work. The
> objects are compiled, but the linking process doesn't find the standard
> libraries.
>
> After looking at the logs, I found out distcc calls "cc" to compile my code,
> even when it's C++. and that's the reason (I think) the linking doesn't
> work. If I run "make CC=cc", it doesn't work (that's locally, no distcc
> involved). So, if distcc calls "cc" behind the scenes, I think it won't work
> either.
>
> Thanks for any help!

Try using CC='distcc g++' or add -xc++ to the compiler options.

> Why doesn't distcc uses "cc" to C code and "c++" to C++ code (or
> gcc/g++)? What can I do to make this work? I've already tried using
> symlinks, appending the masquerade directory in the PATH, but I've got no
> success.

In general I think running

  gcc -c thing.cc

will compile it correctly, because the filename (and then the
explicitly given language option) have higher priority than the name
you used for the compiler.  The only exception as I recall, is if you
want a file thing.c compiled as C++ without giving an option to say
so.

If distcc is run as, say

  distcc -o prog thing.o wibble.o

how's it supposed to know you want them linked as C++, and if run as

  distcc -c thing.c

how's it supposed to know you want it compiled as C++?

--
Martin <http://launchpad.net/~mbp/>
__
distcc mailing list            http://distcc.samba.org/
To unsubscribe or change options:
https://lists.samba.org/mailman/listinfo/distcc

Re: Can't compile C++ code

by cd1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

On Fri, Jul 10, 2009 at 12:57 AM, Martin Pool <mbp@...> wrote:
Try using CC='distcc g++' or add -xc++ to the compiler options.

In general I think running

 gcc -c thing.cc

will compile it correctly, because the filename (and then the
explicitly given language option) have higher priority than the name
you used for the compiler.

Yes, with -c it always works perfectly, even if the code is C or C++.
 
The only exception as I recall, is if you
want a file thing.c compiled as C++ without giving an option to say
so.

That's not my case.
 

If distcc is run as, say

 distcc -o prog thing.o wibble.o

how's it supposed to know you want them linked as C++,

I don't know, that's why I'm asking this question :(
 
and if run as

 distcc -c thing.c

how's it supposed to know you want it compiled as C++?

That's not my case. [2]

I thought that using distcc should be as simple as changing the compiler from gcc/g++ (both of them) to distcc, in the Makefile (aside the distcc configuration, daemon, etc). But it turned out that way won't work... your solution of using 'CC=distcc CXX="distcc g++" actually works, but this is not my ideal solution. CMake, for example, won't accept "distcc g++" as the compiler command, it only accepts one binary file/command. Maybe there should be two commands, like "distcc" and "distc++", and I would specify those commands as the new compilers. If "cc" alone can't handle every compilation, "distcc" alone shouldn't too...
 
--
Crístian Deives dos Santos Viana [aka CD1]

__
distcc mailing list            http://distcc.samba.org/
To unsubscribe or change options:
https://lists.samba.org/mailman/listinfo/distcc

Re: Can't compile C++ code

by mbp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/7/10 Crístian Viana <cristiandeives@...>:

> I thought that using distcc should be as simple as changing the compiler
> from gcc/g++ (both of them) to distcc, in the Makefile (aside the distcc
> configuration, daemon, etc). But it turned out that way won't work... your
> solution of using 'CC=distcc CXX="distcc g++" actually works, but this is
> not my ideal solution. CMake, for example, won't accept "distcc g++" as the
> compiler command, it only accepts one binary file/command. Maybe there
> should be two commands, like "distcc" and "distc++", and I would specify
> those commands as the new compilers. If "cc" alone can't handle every
> compilation, "distcc" alone shouldn't too...

Why not use masquerade mode here, it handles this case?

You said previously you appended it to the path but in fact you have
to prepend it, ie put it before the real compiler.

--
Martin <http://launchpad.net/~mbp/>
__
distcc mailing list            http://distcc.samba.org/
To unsubscribe or change options:
https://lists.samba.org/mailman/listinfo/distcc