help-gnustep
[Top][All Lists]
Advanced

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

Re: c++ compilation within objc framework


From: Nicola Pero
Subject: Re: c++ compilation within objc framework
Date: Tue, 11 Sep 2001 11:45:00 +0100 (BST)

> Hi,
> 
> Working on a set of frameworks that have been until now 100% ObjC, 
> compilation has been fine on MacOSX and GNUstep.
> 
> But we've just added some c++ classes, with some bridge code to make the 
> classes available from ObjC. This works just fine in ProjectBuilder (MacOSX) 
> but I can't find any way to get the cpp files to compile on GNUstep.
> 
> I've never tried to extend the makefile system before now and don't know 
> where to start. I've got a reasonable idea of how make/gmake works... but 
> it's a pretty complex system in there.
> 
> As a stopgap measure, is there an easy way to make a rule within my 
> GNUmakefile to compile cpp files? How would I then ensure the the object 
> files created are linked in with the other ObjC files?

It shouldn't be difficult - but if you are confused, a quick and clean way
might be to compile all your cpp files in a subproject.  Your GNUmakefile
would be something like 

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = tool
tool_OBJC_FILES = tool.m
tool_SUBPROJECTS = cpp.subproj

include $(GNUSTEP_MAKEFILES)/tool.make

And then you can put in the cpp.subproj directory your C++ files, with
whatever Makefile you want to compile them, you are totally free to use
any Makefile code you want, just make sure that the result of your
subproject compilation goes into

cpp.subproj/shared_debug_obj/ix86/linux-gnu/gnu-gnu-gnu/subproject.o

because that object file will be picked up by the higher level GNUmakefile
to be merged with the other code.

Here is a trivial example of a Makefile for the subproject - 

include $(GNUSTEP_MAKEFILES)/common.make

all: $(GNUSTEP_OBJ_DIR) $(GNUSTEP_OBJ_DIR)/subproject.o

clean:
        -rm -Rf $(GNUSTEP_OBJ_DIR) *.o

OBJECTS = fileA.o fileB.o

$(GNUSTEP_OBJ_DIR):
        $(MKDIRS) $(GNUSTEP_OBJ_DIR)

$(GNUSTEP_OBJ_DIR)/subproject.o: $(OBJECTS)
        $(OBJ_MERGE_CMD)


I suppose the best general solution instead would be if the make package
would support something like

xxx_CPP_FILES 

in the same way as it supports xxx_C_FILES and xxx_OBJC_FILES, and would
compile them automatically and merge them automatically into the resulting
tool - I suppose that is what your apple tools do ?  I might easily add
that to gnustep-make, but I'm no expert of C++ so any suggestion (or
comment why we should or should not do it or if it acutally of any use) is
welcome.
 
> I have tried putting this into my GNUmakefile at various locations:
> 
> .SUFFIXES: .cpp
>  
> $(GNUSTEP_OBJ_DIR)/%${OEXT} : %.cpp
>         $(CC) $< -c $(ALL_CPPFLAGS) $(ALL_OBJCFLAGS) -o $@
> 
> But it has no effect whatsoever (still get "No rule to make target...    
> ...cpp" message).
> 
> Any help much appreciated!
> 
> Cheers,
> Stephen Brandon
> stephen@brandonitconsulting.co.uk
> 
> _______________________________________________
> Help-gnustep mailing list
> Help-gnustep@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnustep
> 




reply via email to

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