Compile C++ file as objective-c++ using makefile
- by Vikas
I'm trying to compile .cpp files as objective-c++ using makefile as few of my cpp file have objective code. I added -x objective-c++ as complier option and started getting stray /327 in program error( and lots of similar error with different numbers after /). The errors are around 200. But when I change the encoding of the file from unicode-8 to 16 the error reduces to 23. currently there is no objective-c++ code in the .cpp file but plan to add in future.
When i remove -x objective-c++ from complier option ,everything complies fine. and .out is generated. I would be helpful if someone will tell me why this is happening and even a solution for the same
Thanks in advance
example of my makefile
<code>
MACHINE= $(shell uname -s)
CFLAGS?=-w -framework CoreServices -framework ApplicationServices -framework CoreFoundation -framework CoreWLAN -framework Cocoa -framework Foundation
ifeq ($(MACHINE),Darwin)
CCLINK?= -lpthread
else
CCLINK?= -lpthread -lrt
endif
DEBUG?= -g -rdynamic -ggdb
CCOPT= $(CFLAGS) $(ARCH) $(PROF)
CC =g++ -x objective-c++
AR = ar rcs
#lib name
SLIB_NAME=myapplib
EXENAME = myapp.out
OBJDIR = build
OBJLIB := $(addprefix $(OBJDIR)/... all .o files)
SS_OBJ := $(addprefix $(OBJDIR)/,myapp.o )
vpath %.cpp path to my .cpp files
INC = include files
subsystem:
make all
$(OBJLIB) : |$(OBJDIR)
$(OBJDIR):
mkdir $(OBJDIR)
$(OBJDIR)/%.o:%.cpp
$(CC) -c $(INC) $(CCOPT) $(DEBUG) $(CCLINK) $< -o $@
all: $(OBJLIB) $(CLI_OBJ) $(SS_OBJ)
$(AR) lib$(SLIB_NAME).a $(OBJLIB)
$(CC) $(INC) $(CCOPT) $(SS_OBJ) $(DEBUG) $(CCLINK) -l$(SLIB_NAME) -L ./ -o $(OBJDIR)/$(EXENAME)
clean:
rm -rf $(OBJDIR)/*
dep:
$(CC) -MM *.cpp
</code>