3

我有以下制作文件:

CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2 -W -Wall -Wno-unused -Wno-multichar
COMPONENTHEADER = Q_OBJECT 
CPP = gcc -E
CPPFLAGS = -I/usr/include/Inventor/annex -D_REENTRANT -I/usr/share/qt3/include  
CXX = g++
CXXCPP = g++ -E
CXXDEPMODE = depmode=gcc3
CXXFLAGS = -g -O2 -fno-exceptions -W -Wall -Wno-unused -Wno-multichar -Woverloaded-    virtual
CYGPATH_W = echo
GUI = QT
Gui = Qt
INCLUDES = 
LIBS = -lSoQt -lqt-mt -lXmu -lXi -lCoin -lGL -lXext -lSM -lICE -lX11 -ldl -lpthread -lm -lcxcore -lcv -lhighgui -lcvaux 
OBJS = MathTools.o PointCloud.o ExtractFeatures.o Tile.o Shape.o RoadDynamic.o
SRCS = MathTools.cpp PointCloud.cpp ExtractFeatures.cpp Tile.cpp Shape.cpp RoadDynamic.cpp main.cpp 
HDRS =  constants.h Shape.h MathTools.h PointCloud.h ExtractFeatures.h Tile.h RoadDynamic.h
WIDGET = QWidget *

all: main


main: main.o ${OBJS}
    ${CC} ${CFLAGS} ${INCLUDES} -o $@ main.o ${OBJS} ${LIBS}

.c.o:
    ${CC} ${CFLAGS} ${INCLUDES} -c $<

depend: 
    makedepend ${SRCS}

clean:
    rm *.o core *~

tar:
    tar cf code.tar  Makefile *.c *.h testfile1

print:
    more Makefile $(HDRS) $(SRCS) | enscript -2r -p listing.ps

我想知道为什么当我运行 make 输出是

g++ -g -O2 -fno-exceptions -W -Wall -Wno-unused -Wno-multichar -Woverloaded-virtual -I/usr/include/Inventor/annex -D_REENTRANT -I/usr/share/qt4/include    -c -o main.o main.cpp

代替:

gcc -g -O2 -W -Wall -Wno-unused -Wno-multichar ...

似乎 cxx 变量覆盖了 cc 变量。这是为什么?

在这种情况下,“include =”还有什么作用?它似乎没有设置任何东西。

谢谢

4

1 回答 1

2

因为您的目标文件显然是从 .cpp 文件构建的。您没有从 .cpp 文件构建 .o 文件的显式规则,因此 Make 使用隐式规则 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c

于 2012-07-11T00:25:55.970 回答