我有一个makefile,对于一个带有2个子C文件的C项目,我可以创建两个exe,一个静态和一个动态。
但是静态空间比动态更轻! 程序可以启动,似乎是相同的
这是正常的吗?
非常感谢,我在2天内参加考试,希望能解决这个问题:)
西蒙
CC = gcc
CFLAGS = -Wall
CFLAGS2 = -shared
CFLAGS3 = -fPIC
LIB_U_CAM_TTL = -l_projet_vision_u_cam_ttl
LIB_SERIAL_LINUX = -l_projet_vision_serial_linux
CHEMIN = -L/usr/local/lib
lib_projet_vision_serial_linux.so: serial_linux.o
$(CC) $(CFLAGS2) $^ -o $@
lib_projet_vision_u_cam_ttl.so: u_cam_ttl.o
$(CC) $(CFLAGS2) $^ -o $@
lib_projet_vision_serial_linux.a : serial_linux.o
ar -rv $@ $^
lib_projet_vision_u_cam_ttl.a : u_cam_ttl.o
ar -rv $@ $^
projet_vision_dynamic: main_vision.c install
$(CC) $(CFLAGS3) $^ $(CHEMIN) $(LIB_SERIAL_LINUX) $(LIB_U_CAM_TTL) -o $@
projet_vision_static: main_vision.c install
$(CC) $^ $(CHEMIN) $(LIB_SERIAL_LINUX) $(LIB_U_CAM_TTL) -o $@
%.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
install: lib_projet_vision_serial_linux.so lib_projet_vision_serial_linux.a lib_projet_vision_u_cam_ttl.so lib_projet_vision_u_cam_ttl.a
sudo cp -f *.h /usr/local/include/
sudo cp -f *.so /usr/local/lib/
sudo cp -f *.a /usr/local/lib/
sudo cp projet_vision_dynamic /usr/bin/
sudo cp projet_vision_static /usr/bin/
sudo ldconfig
uninstall: clean
sudo rm -f /usr/local/include/serial_linux.h
sudo rm -f /usr/local/include/u_cam_ttl.h
sudo rm -f /usr/local/lib/lib_projet_vision_serial_linux.so
sudo rm -f /usr/local/lib/lib_projet_vision_u_cam_ttl.so
sudo rm -f /usr/local/lib/lib_projet_vision_u_cam_ttl.a
sudo rm -f /usr/local/lib/lib_projet_vison_serial_linux.a
sudo ldconfig
clean:
rm -f *.o *~ *.so *.a
rm -f projet_vision_static projet_vision_dynamic