help-gplusplus
[Top][All Lists]
Advanced

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

newbie g++ / gcc makefile???


From: Martin Jørgensen
Subject: newbie g++ / gcc makefile???
Date: Sun, 29 Oct 2006 02:26:22 +0100
User-agent: Mozilla Thunderbird 1.0.6 (Macintosh/20050716)

Hi,

I don't know if I found the right group. If not, please redirect me to the right group.

I just made my first C++/C combined project and it works on windows. Now I want it to work on linux. So I have changed main.c to main.cpp and also have a new C++-function in the file: output_energy.cpp. The rest are C-functions.

How should the make-file be modified? I know that main must be processed by a C++-compiler so I changed CC = gcc to CC = g++ in the makefile below (it used to work, when my project was pure C)...

---
.c.o:
        $(RM) $@
        @ #
        $(CC) -c $(CFLAGS) $(SRC)/$*.c

PGM = simulate

OBJ = \
        main.o \
        array_functions.o \
        band_solve.o \
        check_errors.o \
        import_data.o \
        memory_functions.o \
        mesh_functions.o \
        polymesh.o \
        porosities.o \
        read_materials.o \
        result_output.o

    CC = g++
    MV = mv -f
    CP = cp
    RM = rm -f


    PROTO_DEFINES = -DFUNCPROTO=15 -DNARROWPROTO
STD_DEFINES = -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE CFLAGS = $(PROTO_DEFINES) $(STD_DEFINES) -g -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings -Wno-conversion -ffloat-store -O2

     PWD = /bin/pwd
     CD = cd

        VPATH = ./
        SRC   = ./

     SYS_LIBRARIES = -lm


simulate:  $(OBJ)
        $(RM) $@
$(CC) -o $@ -g -W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings -Wno-conversion -ffloat-store -O2 $(OBJ) $(LIBPATH) $(SYS_LIBRARIES) Solverlib.a

        etags `find -iname "*.c"` `find -iname "*.h"`

.c.i:
        $(RM) $@
        $(CC) -E $(CFLAGS) $(_NOOP_) $(SRC)/$*.c > $@

clean::
$(RM) simulate *.CKP *.ln *.BAK *.bak *.o *.u a.out core errs ,* *~ .emacs_* tags TAGS make.log MakeOut "#"*
---

Make returns with Error 1 in one of my files. It says:

...
...
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-Wmissing-declarations" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-Wnested-externs" is valid for C/ObjC but not for C++ .//porosities.c: In function 'void p_factor_cell_results(double**, int, int, double*, double*, double*, double*, double**, unsigned int)':
.//porosities.c:65: error: invalid conversion from 'void*' to 'tablevalues*'
make: *** [porosities.o] Error 1


What do I do? I think I need to tell my makefile that most of the files should be compiled by a C-compiler (gcc?) and main.cpp and the other .cpp files should be compiled with g++?

TIA...


Best regards
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk


reply via email to

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