[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: compiling c++ source files
From: |
Nicola Pero |
Subject: |
Re: compiling c++ source files |
Date: |
Sun, 7 Dec 2003 14:34:23 +0000 (GMT) |
> hi,
>
> i have to interface to c++ code and haven't found a way to properly
> compile the sources from my GNUmakefile. adding them to
> <toolname>_C_FILES doesn't work, because there is no rule to make the
> object file.
>
> my current workaround is including the .cpp in a .c file and setting
> CC=c++, but i'm sure there is a way to handle this correctly, e.g. by
> writing custom rules.
>
> any help would be greatly appreciated, tia,
There are already rules to build C++ stuff ... not sure how much tested
though. :-)
You should add your .cc files to xxx_CC_FILES. That definitely compiles
them. Unfortunately, linking doesn't work as g++ has to be used while gcc
is used by default; it seems libstdc++ is not linked in if gcc is used.
Adding libstdc++ seems to work for me -
====
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = Program
Program_CC_FILES = main.cc
Program_TOOL_LIBS += -lstdc++
include $(GNUSTEP_MAKEFILES)/tool.make
====
This looks reasonably clean and simple to me. I'm not sure how much
portable / correct -lstdc++ is though.
An alternative which also works is the following:
====
include $(GNUSTEP_MAKEFILES)/common.make
CC=g++
TOOL_NAME = Program
Program_CC_FILES = main.cc
include $(GNUSTEP_MAKEFILES)/tool.make
====
Again, this seems reasonably clean and simple; if you think this is better
than the other one, you might use this one.
Let me know if it works or not.