我想一次编译两个.cpp文件。 gstapp.cpp正在编译,gnew.cpp被忽略。我在俯瞰什么?
生成文件:
# generated from pkg-config --cflags gstreamer-0.10
CFLAGS=-pthread -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2
# generated from pkg-config --libs gstreamer-0.10
LDFLAGS=-lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -pthread -lgthread-2.0 -pthread -lglib-2.0 -lxml2 -lgstapp-0.10
CFLAGS+=-I/usr/include/opencv2
# there are more, but not needed form now: -lopencv_calib3d -lopencv_contrib -lopencv_flann -lopencv_obj
LDFLAGS+=-lstdc++ -lopencv_core -lopencv_features2d -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_video
gstapp: gstapp.o
gcc $(LDFLAGS) -o $@ $<
gstapp.o: gstapp.cpp
gcc -c $(CFLAGS) -o $@ $<
gnew: gnew.o
gcc $(LDFLAGS) -o $@ $<
gnew.o: gnew.cpp
gcc -c $(CFLAGS) -o $@ $<
答案 0 :(得分:2)
您可能希望all
规则触发两者的编译。只需运行make
不带参数,它就会运行它遇到的第一个规则(例如gstapp:
),然后退出。
所以在LDFLAGS和gstapp行之间放
all: gstapp gnew
然后,第一个(也称为默认)规则将您的文件作为依赖项,并在运行make
或make all
时进行编译。