首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

一个简单的Makefile有关问题

2012-02-15 
一个简单的Makefile问题当前目录下有三个文件夹 common decomp comp每个文件夹下有一堆c文件和h文件 假设c

一个简单的Makefile问题
当前目录下有三个文件夹 common decomp comp

每个文件夹下有一堆c文件和h文件 假设common下有文件common1.c common1.h common2.c common2.h 其他依次类推……
文件夹内部各文件间乱七八糟的依赖


在当前目录下写一个测试程序 test.c 其中用到了上述三个文件夹中的程序

现在想在当前目录下写一个makefile 生成一个可执行文件test

怎么写?

新手,欢迎鄙视



[解决办法]

C/C++ code
C_SRCS += \    src1/common1.cpp \    src2/common2.cpp \    src3/common3.cpp \        test.c        OBJS += \    src1/common1.o   \    src2/common2.o \    src3/common3.o \        test.oall: testtest: $(OBJS)     @echo 'Building target: $@'    g++  -o test $(OBJS) -L./ $(LIBS)  -lxml2  %.o: src1/%.cpp    @echo 'Building file: $<'    g++ -c $<  -MD "-D_DEBUG" "-D__cplusplus"  -L./lib -I/usr/include/ -I/usr/include/libxml2 `    @echo 'Finished building: $<'%.o: src2/%.cpp    @echo 'Building file: $<'    g++ -c $<  -MD "-D_DEBUG" "-D__cplusplus"  -L./lib -I/usr/include/ -I/usr/include/libxml2 `    @echo 'Finished building: $<'%.o: src3/%.cpp    @echo 'Building file: $<'    g++ -c $<  -MD "-D_DEBUG" "-D__cplusplus"  -L./lib -I/usr/include/ -I/usr/include/libxml2 `    @echo 'Finished building: $<' 

热点排行