• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 51, 文章 - 1, 評論 - 41, 引用 - 0
            數(shù)據(jù)加載中……

            帶依賴關(guān)系的makefile簡易例子

            # makefile 開始

            # 編譯相關(guān)的選項(xiàng)
            CC = g++
            CPPFLAG =

            # 所有的cpp源文件或者手動(dòng)添加文件
            SOURCES = $(wildcard *.cpp)
            #SOURCES = main.cpp \
            #          test_func.cpp    \
            #          test_class.cpp

            # 與源文件對應(yīng)的目標(biāo)文件和依賴文件
            OBJECTS = $(SOURCES:.cpp=.o)
            DEPENDS = $(SOURCES:.cpp=.d)

            # 第一個(gè)編譯模板
            all: test.exe


            # 添加依賴文件
            sinclude $(DEPENDS)


            test.exe: $(OBJECTS)
                $(CC) $(OBJECTS) -o test.exe


            $(OBJECTS): %.o: %.cpp
                $(CC) -c $(CPPFLAG) $< -o $@


            # 生成依賴文件,由于依賴文件也依賴源文件,因此需要增加xxx.d,如:
            # main.o: main.cpp test_func.hpp test_class.hpp
            # main.d main.o: main.cpp test_func.hpp test_class.hpp
            # 一般的例子會(huì)使用sed實(shí)現(xiàn)這個(gè)功能,在這里我編寫了print.exe實(shí)現(xiàn)該功能。
            %.d: %.cpp print.exe
                print.exe $@ > $@
                $(CC) -MM $< >> $@

             

            # 輔助生成依賴文件的程序
            print.exe: print.c
                $(CC) print.c -o print.exe

             

            #清除所有文件
            clean:
                del test.exe print.exe $(OBJECTS) $(DEPENDS)

             

            #makefile 結(jié)束

             

            // print.c 開始

            #include <cstdio>
            int main(int argc, const char* argv[]) {
                if (argc > 1) {
                    printf("%s ", argv[1]);
                }
                return 0;
            }

            // print.c 結(jié)束

             

            // main.cpp 開始

            #include "test_func.hpp"
            #include "test_class.hpp"

            int main() {
                TestClass::Print();
                Print();
            }

            // main.cpp 結(jié)束

             

            // test_class.hpp 開始

            #ifndef TEST_CLASS_HPP
            #define TEST_CLASS_HPP
            class TestClass {
            public:
                static void Print();
            };

            #endif // TEST_CLASS_HPP

            // test_class.hpp 結(jié)束

             

            // test_class.cpp 開始

            #include <cstdio>
            #include "test_class.hpp"

            void TestClass::Print() {
                printf("TestClass\n");
            }

            // test_class.cpp 結(jié)束

             

            // test_func.hpp 開始

            #ifndef TEST_FUNC_HPP
            #define TEST_FUNC_HPP

            void Print();

            #endif // TEST_FUNC_HPP

            // test_func.hpp 結(jié)束

             

            // test_func.cpp 開始

            #include <cstdio>
            #include "test_func.hpp"

            void Print() {
                printf("TestFunc\n");
            }

            // test_func.cpp 結(jié)束

            posted on 2014-05-14 22:34 lemene 閱讀(722) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久精品人人做人人爽电影| 精品久久亚洲中文无码| 精品999久久久久久中文字幕| 99久久夜色精品国产网站| 91久久九九无码成人网站| 亚洲AV成人无码久久精品老人| 久久婷婷国产麻豆91天堂| 日本欧美久久久久免费播放网| 国产精品99久久精品爆乳| 99久久99久久精品免费看蜜桃| 久久精品国产亚洲av麻豆蜜芽| 久久久久国产精品熟女影院| 国产A三级久久精品| 国产精品亚洲综合专区片高清久久久| 久久国产一片免费观看| 国产亚洲精久久久久久无码AV| 成人免费网站久久久| 亚洲人AV永久一区二区三区久久| 久久97久久97精品免视看| 麻豆成人久久精品二区三区免费| 精品免费久久久久国产一区| 东京热TOKYO综合久久精品| 精品久久久久久国产潘金莲| 人人狠狠综合久久亚洲| 亚洲国产视频久久| 热99RE久久精品这里都是精品免费| 亚洲精品97久久中文字幕无码| 99久久精品午夜一区二区| 久久综合亚洲色HEZYO社区| 久久国产高清一区二区三区| 久久99国产精一区二区三区| 久久精品国产亚洲AV香蕉| 久久精品国产色蜜蜜麻豆| 亚洲国产成人精品女人久久久| 亚洲国产精品热久久| Xx性欧美肥妇精品久久久久久 | 欧美国产成人久久精品| 婷婷久久综合九色综合绿巨人| 色综合久久天天综合| 国内精品久久国产大陆| 久久中文字幕一区二区|