{"id":65600,"date":"2026-01-25T12:24:33","date_gmt":"2026-01-25T04:24:33","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/65600.html"},"modified":"2026-01-25T12:24:33","modified_gmt":"2026-01-25T04:24:33","slug":"linux%e5%ae%9e%e6%88%98%ef%bc%88%e4%b8%89%ef%bc%89%ef%bc%9amakefile%e7%9a%84%e7%bc%96%e5%86%99","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/65600.html","title":{"rendered":"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199"},"content":{"rendered":"<h2><\/h2>\n<h2>\u00a0Makefile\u7684\u7f16\u5199<\/h2>\n<h4>1. Makefile \u7684\u6838\u5fc3\u89c4\u5219<\/h4>\n<p>Makefile \u7684\u8bed\u6cd5\u975e\u5e38\u56fa\u5b9a&#xff0c;\u7531\u4e09\u90e8\u5206\u7ec4\u6210&#xff1a;<\/p>\n<p>\u00a0\u76ee\u6807(Target): \u4f9d\u8d56(Dependencies)<br \/>\n\u00a0&lt;Tab\u952e&gt; \u547d\u4ee4(Command)<\/p>\n<p>\u6ce8\u610f&#xff1a;\u547d\u4ee4\u524d\u9762\u5fc5\u987b\u662f\u4e00\u4e2a Tab \u952e&#xff0c;\u4e0d\u80fd\u662f\u7a7a\u683c&#xff0c;\u5426\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n<hr \/>\n<h4>2. Makefile \u7684\u5206\u6b65\u7f16\u5199<\/h4>\n<p>\u6211\u4eec\u53ef\u4ee5\u628a Makefile \u770b\u4f5c\u662f\u4e00\u4efd\u7ed9 make \u5de5\u5177\u9605\u8bfb\u7684\u201c\u914d\u65b9\u8bf4\u660e\u4e66\u201d &#x1f4dd;\u3002\u5b83\u544a\u8bc9\u5de5\u5177&#xff1a;\u6700\u7ec8\u4ea7\u54c1\u662f\u4ec0\u4e48&#xff0c;\u9700\u8981\u54ea\u4e9b\u539f\u6750\u6599&#xff0c;\u4ee5\u53ca\u52a0\u5de5\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u901a\u8fc7\u4e0b\u9762\u4e09\u4e2a\u7ef4\u5ea6\u6765\u62c6\u89e3 Makefile&#xff1a;<\/p>\n<p>1. \u53d8\u91cf\u5b9a\u4e49 (Variables) &#x1f4e6;<\/p>\n<p>Makefile \u7684\u5f00\u5934\u901a\u5e38\u4f1a\u5b9a\u4e49\u53d8\u91cf\u3002\u8fd9\u5c31\u50cf\u662f\u5728\u7a0b\u5e8f\u91cc\u5b9a\u4e49\u5e38\u91cf&#xff0c;\u65b9\u4fbf\u7edf\u4e00\u4fee\u6539\u3002<\/p>\n<table>\n<tr>\u53d8\u91cf\u540d\u542b\u4e49\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td style=\"width:76px\">CXX<\/td>\n<td style=\"width:108px\">C&#043;&#043; eXecutable<\/td>\n<td>\u6307\u5b9a\u7f16\u8bd1\u5668\u3002\u8fd9\u91cc\u662f g&#043;&#043;\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"width:76px\">CXXFLAGS<\/td>\n<td style=\"width:108px\">CXX FLAGS<\/td>\n<td>\u7f16\u8bd1\u53c2\u6570\u3002-fPIC \u751f\u6210\u4f4d\u7f6e\u65e0\u5173\u4ee3\u7801&#xff0c;-Iheader \u544a\u8bc9\u7f16\u8bd1\u5668\u53bb\u54ea\u91cc\u627e\u5934\u6587\u4ef6\u3002<\/td>\n<\/tr>\n<tr>\n<td style=\"width:76px\">LDFLAGS<\/td>\n<td style=\"width:108px\">Link Der FLAGS<\/td>\n<td>\u94fe\u63a5\u53c2\u6570\u3002-Llib \u5bfb\u627e\u5e93\u8def\u5f84&#xff0c;-lMymath \u94fe\u63a5\u5177\u4f53\u5e93&#xff0c;-Wl,-rpath \u8bb0\u5f55\u8fd0\u884c\u65f6\u641c\u7d22\u8def\u5f84\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p>2. \u6838\u5fc3\u89c4\u5219\u7ed3\u6784 (The Rules) &#x1f3d7;\ufe0f<\/p>\n<p>\u6bcf\u4e00\u6761\u89c4\u5219\u90fd\u9075\u5faa\u8fd9\u4e2a\u903b\u8f91&#xff1a;<\/p>\n<p>\u00a0\u76ee\u6807\u6587\u4ef6: \u4f9d\u8d56\u6587\u4ef6<br \/>\n\u00a0    \u6267\u884c\u547d\u4ee4<\/p>\n<ul>\n<li>\n<p>\u4f9d\u8d56\u68c0\u67e5&#xff1a;make \u4f1a\u68c0\u67e5\u201c\u4f9d\u8d56\u6587\u4ef6\u201d\u7684\u4fee\u6539\u65f6\u95f4\u3002\u5982\u679c\u4f9d\u8d56\u6587\u4ef6\u6bd4\u201c\u76ee\u6807\u6587\u4ef6\u201d\u65b0&#xff0c;\u5b83\u624d\u4f1a\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u3002\u8fd9\u5c31\u662f\u589e\u91cf\u7f16\u8bd1\u7684\u6838\u5fc3\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<p>3. \u9010\u884c\u903b\u8f91\u62c6\u89e3 &#x1f50d;<\/p>\n<p>\u6211\u4eec\u5c06 Makefile \u5206\u6210\u56db\u4e2a\u201c\u52a0\u5de5\u73af\u8282\u201d\u6765\u770b&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u73af\u8282\u4e00&#xff1a;\u6700\u7ec8\u4ea7\u7269 (math)<\/p>\n<p>math: src\/main.o lib\/libMymath.so<br \/>\n    $(CXX) src\/main.o $(LDFLAGS) -o math<\/p>\n<p>\u5b83\u8bf4&#xff1a;\u8981\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6 math&#xff0c;\u5fc5\u987b\u5148\u6709 main.o \u548c\u52a8\u6001\u5e93 .so\u3002<\/p>\n<\/li>\n<li>\n<p>\u73af\u8282\u4e8c&#xff1a;\u4e2d\u95f4\u96f6\u4ef6 (main.o)<\/p>\n<p>src\/main.o: src\/main.cpp<br \/>\n    $(CXX) $(CXXFLAGS) -c src\/main.cpp -o src\/main.o<\/p>\n<p>\u5b83\u8bf4&#xff1a;\u8981\u628a\u6e90\u7801\u53d8\u6210\u4e8c\u8fdb\u5236\u76ee\u6807\u6587\u4ef6\u3002\u6ce8\u610f -c \u53c2\u6570\u8868\u793a\u53ea\u7f16\u8bd1&#xff0c;\u4e0d\u94fe\u63a5\u3002<\/p>\n<\/li>\n<li>\n<p>\u73af\u8282\u4e09&#xff1a;\u5171\u4eab\u4ed3\u5e93\/\u52a8\u6001\u5e93 (libMymath.so)<\/p>\n<p>lib\/libMymath.so: src\/Mymath.o<br \/>\n    $(CXX) -shared src\/Mymath.o -o lib\/libMymath.so<\/p>\n<p>\u5b83\u8bf4&#xff1a;\u7528 -shared \u53c2\u6570\u628a .o \u5305\u88c5\u6210\u52a8\u6001\u5e93\u3002<\/p>\n<\/li>\n<li>\n<p>\u73af\u8282\u56db&#xff1a;\u5927\u626b\u9664 (clean)<\/p>\n<p>clean:<br \/>\n    rm -f math src\/*.o lib\/*.so<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u201c\u4f2a\u76ee\u6807\u201d&#xff0c;\u7528\u6765\u5feb\u901f\u5220\u9664\u6240\u6709\u751f\u6210\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6&#xff0c;\u8fd8\u539f\u7eaf\u51c0\u4ee3\u7801\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h4>3. Makefile \u4e3a\u4ec0\u4e48\u201c\u667a\u80fd\u201d&#xff1f;<\/h4>\n<p>\u5f53\u4f60\u8fd0\u884c make \u547d\u4ee4\u65f6&#xff0c;\u5b83\u4f1a\u68c0\u67e5&#xff1a;<\/p>\n<li>\n<p>\u662f\u5426\u5b58\u5728\u76ee\u6807\u6587\u4ef6&#xff1f; \u5982\u679c\u6ca1\u6709 math&#xff0c;\u5c31\u6267\u884c\u547d\u4ee4\u751f\u6210\u5b83\u3002<\/p>\n<\/li>\n<li>\n<p>\u6587\u4ef6\u7684\u4fee\u6539\u65f6\u95f4&#xff1a;\u5982\u679c src\/main.cpp \u7684\u4fee\u6539\u65f6\u95f4\u665a\u4e8e src\/main.o&#xff0c;\u5b83\u4f1a\u91cd\u65b0\u7f16\u8bd1\u8fd9\u4e2a .o&#xff1b;\u5982\u679c\u65f6\u95f4\u6ca1\u53d8&#xff0c;\u5b83\u5c31\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u6b65\u3002<\/p>\n<\/li>\n<p>\u8fd9\u5c31\u662f\u6240\u8c13\u7684\u589e\u91cf\u7f16\u8bd1\u3002<\/p>\n<hr \/>\n<h4>4. \u81ea\u52a8\u5316\u53d8\u91cf&#xff08;\u8ba9\u4ee3\u7801\u66f4\u7b80\u6d01&#xff09;<\/h4>\n<p>\u4e0a\u9762\u7684 Makefile \u8fd8\u662f\u6709\u70b9\u5570\u55e6&#xff0c;\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u201c\u9ed1\u8bdd\u201d\u6765\u7b80\u5316\u5b83&#xff1a;<\/p>\n<ul>\n<li>\n<p>$&#064;&#xff1a;\u4ee3\u8868\u201c\u76ee\u6807\u6587\u4ef6\u201d<\/p>\n<\/li>\n<li>\n<p>$^&#xff1a;\u4ee3\u8868\u201c\u6240\u6709\u7684\u4f9d\u8d56\u6587\u4ef6\u201d<\/p>\n<\/li>\n<li>\n<p>$&lt;&#xff1a;\u4ee3\u8868\u201c\u7b2c\u4e00\u4e2a\u4f9d\u8d56\u6587\u4ef6\u201d<\/p>\n<\/li>\n<\/ul>\n<p>\u7b80\u5316\u540e\u7684\u7248\u672c&#xff1a;<\/p>\n<p>\u00a0math: src\/main.o lib\/libMymath.so<br \/>\n\u00a0    $(CXX) $&lt; $(LDFLAGS) -o $&#064;<br \/>\n\u00a0\u200b<br \/>\n\u00a0src\/main.o: src\/main.cpp<br \/>\n\u00a0    $(CXX) $(CXXFLAGS) -c $&lt; -o $&#064;<\/p>\n<hr \/>\n<h4>5. \u5e38\u89c1\u6307\u4ee4<\/h4>\n<ul>\n<li>\n<p>make&#xff1a;\u6267\u884c all \u76ee\u6807&#xff0c;\u5f00\u59cb\u667a\u80fd\u7f16\u8bd1\u3002<\/p>\n<\/li>\n<li>\n<p>make clean&#xff1a;\u6267\u884c\u6e05\u7406\u5de5\u4f5c&#xff0c;\u628a\u751f\u6210\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u5168\u5220\u6389\u3002<\/p>\n<\/li>\n<li>\n<p>make -j 4&#xff1a;\u5229\u7528\u591a\u6838\u5e76\u884c\u7f16\u8bd1&#xff08;\u5982\u679c\u4f60\u6709 4 \u6838&#xff0c;\u901f\u5ea6\u98de\u5feb&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<p>\u4e3a\u4e86\u786e\u4fdd\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86 Makefile \u7684\u903b\u8f91&#xff0c;\u6211\u6709\u4e00\u4e2a\u5c0f\u95ee\u9898\u8003\u8003\u4f60&#xff1a;<\/p>\n<p>\u5982\u679c\u5728\u6211\u7684 Makefile \u4e2d&#xff0c;math \u76ee\u6807\u540e\u9762\u5199\u7684\u4f9d\u8d56\u53ea\u6709 src\/main.o&#xff0c;\u800c\u6ca1\u5199 lib\/libMymath.so\u3002\u5f53\u6211\u4fee\u6539\u4e86\u52a8\u6001\u5e93\u7684\u6e90\u7801 Mymath.cpp \u5e76\u91cd\u65b0\u8fd0\u884c make \u65f6&#xff0c;\u4f60\u89c9\u5f97 math \u8fd9\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u4f1a\u53d1\u751f\u4ec0\u4e48\u53d8\u5316&#xff1f;<\/p>\n<li>\n<p>make \u4f1a\u81ea\u52a8\u53d1\u73b0 Mymath.cpp \u53d8\u4e86&#xff0c;\u4ece\u800c\u91cd\u65b0\u751f\u6210\u52a8\u6001\u5e93\u5e76\u91cd\u65b0\u94fe\u63a5 math\u3002<\/p>\n<\/li>\n<li>\n<p>make \u53ea\u4f1a\u66f4\u65b0\u52a8\u6001\u5e93&#xff0c;\u4f46\u4e0d\u4f1a\u91cd\u65b0\u94fe\u63a5 math&#xff0c;\u56e0\u4e3a math \u89c9\u5f97\u81ea\u5df1\u7684\u4f9d\u8d56\u9879&#xff08;main.o&#xff09;\u6ca1\u53d8\u3002<\/p>\n<\/li>\n<p>\u4f60\u76f4\u89c9\u9009\u54ea\u4e00\u4e2a&#xff1f;&#x1f914;<\/p>\n<hr \/>\n<h2>Makefile\u8fdb\u9636<\/h2>\n<p>\u4f60\u7684\u76f4\u89c9\u975e\u5e38\u654f\u9510&#xff0c;\u800c\u4e14\u5728\u5927\u591a\u6570\u521d\u5b66\u8005\u7f16\u5199\u7684 Makefile \u4e2d&#xff0c;\u8fd9\u786e\u5b9e\u662f\u6700\u5bb9\u6613\u53d1\u751f\u7684\u9519\u8bef&#xff01;&#x1f3af;<\/p>\n<p>\u4f60\u7684\u5224\u65ad\u662f\u6b63\u786e\u7684&#xff1a;\u5982\u679c math \u7684\u4f9d\u8d56\u5217\u8868\u53ea\u5199\u4e86 src\/main.o&#xff0c;\u90a3\u4e48 make \u786e\u5b9e\u53ea\u4f1a\u68c0\u67e5 main.o \u7684\u65f6\u95f4\u3002\u5373\u4f7f\u4f60\u4fee\u6539\u4e86\u5e93\u7684\u4ee3\u7801\u5e76\u751f\u6210\u4e86\u65b0\u7684 libMymath.so&#xff0c;math \u7a0b\u5e8f\u4e5f\u4e0d\u4f1a\u610f\u8bc6\u5230\u9700\u8981\u91cd\u65b0\u94fe\u63a5<\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u8fd9\u79cd\u201c\u611f\u77e5\u8fdf\u949d\u201d&#xff0c;\u6211\u4eec\u9700\u8981\u5728 Makefile \u7684\u89c4\u5219\u4e2d\u663e\u5f0f\u5730\u628a .so \u6587\u4ef6\u4e5f\u5217\u4e3a math \u7684\u4f9d\u8d56\u9879<\/p>\n<hr \/>\n<p>&#x1f50d; \u89c2\u5bdf\u4f9d\u8d56\u5173\u7cfb<\/p>\n<p>\u8ba9\u6211\u4eec\u770b\u770b\u4fee\u6b63\u540e\u7684\u903b\u8f91&#xff1a;<\/p>\n<p># \u8fd9\u6837\u5199&#xff0c;math \u5c31\u4f1a\u65f6\u523b\u76ef\u7740\u8fd9\u4e24\u4e2a\u6587\u4ef6<br \/>\nmath: src\/main.o lib\/libMymath.so<br \/>\n$(CXX) src\/main.o $(LDFLAGS) -o math<\/p>\n<p>\u8fd9\u6837&#xff0c;\u4e00\u65e6 lib\/libMymath.so \u7684\u65f6\u95f4\u6233\u66f4\u65b0&#xff08;\u56e0\u4e3a\u5b83\u88ab\u91cd\u65b0\u7f16\u8bd1\u4e86&#xff09;&#xff0c;make \u5c31\u4f1a\u53d1\u73b0 math \u7684\u5176\u4e2d\u4e00\u4e2a\u4f9d\u8d56\u53d8\u65b0\u4e86&#xff0c;\u4ece\u800c\u89e6\u53d1\u91cd\u65b0\u94fe\u63a5\u547d\u4ee4\u3002<\/p>\n<hr \/>\n<h4>\u6a21\u5f0f\u89c4\u5219&#xff08;Pattern Rules&#xff09;<\/h4>\n<p>\u65e2\u7136\u6211\u4eec\u5df2\u7ecf\u804a\u5230\u4e86\u4f9d\u8d56&#xff0c;\u4f60\u4e4b\u524d\u95ee\u8fc7\u5982\u679c\u6709\u5f88\u591a\u6587\u4ef6\u600e\u4e48\u529e\u3002\u5728 Makefile \u4e2d&#xff0c;\u6211\u4eec\u4e0d\u9700\u8981\u4e3a\u6bcf\u4e2a .cpp \u624b\u5199\u89c4\u5219&#xff0c;\u53ef\u4ee5\u4f7f\u7528 % \u7edf\u914d\u7b26\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u6a21\u5f0f\u89c4\u5219&#xff1a;<\/p>\n<p># \u8fd9\u662f\u4e00\u6761\u901a\u7528\u7684\u201c\u751f\u4ea7\u7ebf\u201d<br \/>\n# \u5b83\u8bf4&#xff1a;\u4efb\u4f55 .o \u6587\u4ef6\u90fd\u4f9d\u8d56\u4e8e\u540c\u540d\u7684 .cpp \u6587\u4ef6<br \/>\n%.o: %.cpp<br \/>\n$(CXX) $(CXXFLAGS) -c $&lt; -o $&#064;<\/p>\n<ul>\n<li>\n<p>%&#xff1a;\u5339\u914d\u4efb\u4f55\u5b57\u7b26\u4e32&#xff08;\u6bd4\u5982 main \u6216 Mymath&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>$&lt;&#xff1a;\u81ea\u52a8\u5316\u53d8\u91cf&#xff0c;\u6307\u4ee3\u7b2c\u4e00\u4e2a\u4f9d\u8d56\u6587\u4ef6&#xff08;\u5373 .cpp&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>$&#064;&#xff1a;\u81ea\u52a8\u5316\u53d8\u91cf&#xff0c;\u6307\u4ee3\u76ee\u6807\u6587\u4ef6&#xff08;\u5373 .o&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<p>\u2753 \u4e00\u4e2a\u5173\u4e8e\u201c\u5934\u6587\u4ef6\u201d\u7684\u5c0f\u8c1c\u9898<\/p>\n<p>\u73b0\u5728\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u5982\u679c\u4f60\u4fee\u6539\u4e86 header\/Mymath.h \u91cc\u7684\u4e00\u4e2a\u51fd\u6570\u58f0\u660e&#xff0c;\u4f46\u6ca1\u6709\u52a8\u4efb\u4f55 .cpp \u6587\u4ef6\u3002<\/p>\n<p>\u6839\u636e\u6211\u4eec\u73b0\u5728\u7684 Makefile \u89c4\u5219&#xff1a;<\/p>\n<li>\n<p>src\/main.o \u4f9d\u8d56\u4e8e src\/main.cpp<\/p>\n<\/li>\n<li>\n<p>src\/Mymath.o \u4f9d\u8d56\u4e8e src\/Mymath.cpp<\/p>\n<\/li>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u4f60\u89c9\u5f97\u8fd0\u884c make \u4f1a\u53d1\u751f\u4ec0\u4e48&#xff1f;<\/p>\n<ul>\n<li>\n<p>A) make \u4f1a\u53d1\u73b0\u5934\u6587\u4ef6\u53d8\u4e86&#xff0c;\u81ea\u52a8\u91cd\u65b0\u7f16\u8bd1\u76f8\u5173\u7684 .o \u6587\u4ef6\u3002<\/p>\n<\/li>\n<li>\n<p>B) make \u4ec0\u4e48\u90fd\u4e0d\u4f1a\u505a&#xff0c;\u56e0\u4e3a\u5b83\u6ca1\u770b\u5230 .cpp \u6587\u4ef6\u53d1\u751f\u53d8\u5316\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u8fd9\u4e2a\u95ee\u9898\u7684\u7b54\u6848&#xff0c;\u804a\u804a Makefile \u4e2d\u6700\u8fdb\u9636\u7684\u201c\u81ea\u52a8\u751f\u6210\u4f9d\u8d56\u201d\u6280\u672f\u3002\u4f60\u9009\u54ea\u4e00\u4e2a&#xff1f;&#x1f914;<\/p>\n<hr \/>\n<p>\u4f60\u7684\u5224\u65ad\u5b8c\u5168\u6b63\u786e&#xff01;&#x1f3af;<\/p>\n<p>\u5982\u679c\u4e0d\u505a\u7279\u6b8a\u5904\u7406&#xff0c;make \u786e\u5b9e\u4f1a\u8868\u73b0\u5f97\u975e\u5e38\u201c\u8fdf\u949d\u201d\u3002\u8fd9\u662f\u56e0\u4e3a\u5728 Makefile \u7684\u89c4\u5219\u91cc&#xff0c;\u6211\u4eec\u53ea\u544a\u8bc9\u4e86\u5b83 .o \u6587\u4ef6\u4f9d\u8d56\u4e8e .cpp \u6587\u4ef6\u3002make \u5e76\u4e0d\u5177\u5907\u201c\u900f\u89c6\u773c\u201d&#xff0c;\u5b83\u4e0d\u4f1a\u81ea\u52a8\u94bb\u8fdb\u6e90\u4ee3\u7801\u91cc\u53bb\u67e5\u770b #include \u4e86\u54ea\u4e9b\u5934\u6587\u4ef6\u3002<\/p>\n<p>\u8fd9\u5c31\u5bfc\u81f4\u4e86\u4e00\u4e2a\u7ecf\u5178\u7684\u5f00\u53d1\u75db\u70b9&#xff1a;\u4f60\u4fee\u6539\u4e86\u5934\u6587\u4ef6\u91cc\u7684\u7c7b\u5b9a\u4e49\u6216\u51fd\u6570\u58f0\u660e&#xff0c;\u8fd0\u884c make&#xff0c;\u5b83\u5374\u544a\u8bc9\u4f60 up to date\u3002\u7ed3\u679c\u4f60\u8fd0\u884c\u7a0b\u5e8f\u65f6&#xff0c;\u53ef\u80fd\u4f1a\u56e0\u4e3a\u4e8c\u8fdb\u5236\u4e0d\u517c\u5bb9\u800c\u83ab\u540d\u5176\u5999\u5730\u5d29\u6e83\u3002&#x1f4a5;<\/p>\n<hr \/>\n<h4>\u8ba9\u4f9d\u8d56\u5173\u7cfb\u201c\u900f\u660e\u5316\u201d<\/h4>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898&#xff0c;\u7a0b\u5e8f\u5458\u4eec\u901a\u5e38\u6709\u4e09\u79cd\u8fdb\u5316\u65b9\u6848&#xff1a;<\/p>\n<p>1. \u624b\u52a8\u6dfb\u52a0\u6cd5&#xff08;\u6700\u539f\u59cb&#xff09;<\/p>\n<p>\u5728\u89c4\u5219\u91cc\u624b\u52a8\u628a\u5934\u6587\u4ef6\u52a0\u4e0a\u53bb&#xff1a;<\/p>\n<p>src\/main.o: src\/main.cpp header\/Mymath.h<br \/>\n$(CXX) $(CXXFLAGS) -c $&lt; -o $&#064;<\/p>\n<ul>\n<li>\n<p>\u7f3a\u70b9&#xff1a;\u5982\u679c\u6709 100 \u4e2a\u5934\u6587\u4ef6&#xff0c;\u624b\u52a8\u7ef4\u62a4\u7b80\u76f4\u662f\u5669\u68a6\u3002<\/p>\n<\/li>\n<\/ul>\n<p>2. \u5229\u7528\u7f16\u8bd1\u5668\u81ea\u52a8\u751f\u6210&#xff08;\u6700\u4e13\u4e1a&#xff09;<\/p>\n<p>\u5b9e\u9645\u4e0a&#xff0c;g&#043;&#043; \u672c\u8eab\u5c31\u6709\u4e00\u9879\u9ed1\u79d1\u6280\u53c2\u6570&#xff1a;-MMD\u3002<\/p>\n<p>\u5f53\u4f60\u7f16\u8bd1\u65f6\u52a0\u4e0a\u8fd9\u4e2a\u53c2\u6570&#xff0c;g&#043;&#043; \u4f1a\u5728\u751f\u6210 .o \u7684\u540c\u65f6&#xff0c;\u987a\u4fbf\u751f\u6210\u4e00\u4e2a .d \u6587\u4ef6&#xff08;\u4f9d\u8d56\u6587\u4ef6&#xff09;&#xff0c;\u91cc\u9762\u8bb0\u5f55\u4e86\u8be5 .cpp \u7528\u5230\u7684\u6240\u6709\u5934\u6587\u4ef6\u3002<\/p>\n<p>3. \u7ec8\u6781\u7248 Makefile \u6a21\u677f<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728 Makefile \u4e2d\u5305\u542b&#xff08;include&#xff09;\u8fd9\u4e9b .d \u6587\u4ef6&#xff0c;\u8ba9 make \u81ea\u52a8\u611f\u77e5\u5934\u6587\u4ef6\u7684\u53d8\u5316&#xff1a;<\/p>\n<p># 1. \u53d8\u91cf\u5b9a\u4e49&#xff1a;\u914d\u7f6e\u7f16\u8bd1\u5668\u548c\u8def\u5f84<br \/>\nCXX      &#061; g&#043;&#043;<br \/>\nCXXFLAGS &#061; -fPIC -Iheader -MMD  # -MMD \u4f1a\u81ea\u52a8\u751f\u6210 .d \u4f9d\u8d56\u6587\u4ef6<br \/>\nLDFLAGS  &#061; -Llib -lMymath -Wl,-rpath,.\/lib<\/p>\n<p># 2. \u786e\u5b9a\u6240\u6709\u7684\u76ee\u6807\u6587\u4ef6 (.o) \u548c\u5bf9\u5e94\u7684\u4f9d\u8d56\u6587\u4ef6 (.d)<br \/>\nOBJS &#061; src\/main.o src\/Mymath.o<br \/>\nDEPS &#061; $(OBJS:.o&#061;.d)<\/p>\n<p># 3. \u9ed8\u8ba4\u76ee\u6807&#xff1a;\u6267\u884c &#039;make&#039; \u65f6\u8fd0\u884c\u7684\u4efb\u52a1<br \/>\nall: math<\/p>\n<p># 4. \u94fe\u63a5\u89c4\u5219&#xff1a;\u5c06 .o \u6587\u4ef6\u94fe\u63a5\u6210\u53ef\u6267\u884c\u7a0b\u5e8f<br \/>\nmath: src\/main.o lib\/libMymath.so<br \/>\n$(CXX) src\/main.o $(LDFLAGS) -o $&#064;<\/p>\n<p># 5. \u52a8\u6001\u5e93\u89c4\u5219&#xff1a;\u5c06 Mymath.o \u5305\u88c5\u6210 .so \u6587\u4ef6<br \/>\nlib\/libMymath.so: src\/Mymath.o<br \/>\n&#064;mkdir -p lib  # \u786e\u4fdd lib \u76ee\u5f55\u5b58\u5728<br \/>\n$(CXX) -shared $&lt; -o $&#064;<\/p>\n<p># 6. \u901a\u7528\u7684\u7f16\u8bd1\u89c4\u5219&#xff1a;\u5c06\u6240\u6709\u7684 .cpp \u7f16\u8bd1\u4e3a .o<br \/>\n%.o: %.cpp<br \/>\n$(CXX) $(CXXFLAGS) -c $&lt; -o $&#064;<\/p>\n<p># 7. \u5f15\u5165\u9690\u85cf\u7684\u4f9d\u8d56\u89c4\u5219&#xff1a;\u8ba9 make \u77e5\u9053\u5934\u6587\u4ef6\u7684\u53d8\u5316<br \/>\n-include $(DEPS)<\/p>\n<p># 8. \u6e05\u7406\u4efb\u52a1<br \/>\n.PHONY: clean<br \/>\nclean:<br \/>\nrm -f math src\/*.o src\/*.d lib\/*.so<\/p>\n<p>\u8fd9\u4e00\u5757\u7684\u5185\u5bb9\u786e\u5b9e\u662f Makefile \u8fdb\u9636\u7684\u96be\u70b9&#xff0c;\u56e0\u4e3a\u6d89\u53ca\u5230 make \u7684\u81ea\u52a8\u5316\u201c\u9ed1\u79d1\u6280\u201d\u3002\u6211\u6765\u9010\u4e00\u4e3a\u4f60\u62c6\u89e3&#xff0c;\u5e26\u4f60\u770b\u770b\u8fd9\u4e9b\u4ee3\u7801\u80cc\u540e\u53d1\u751f\u4e86\u4ec0\u4e48\u3002<\/p>\n<p>1. \u53d8\u91cf\u8f6c\u6362\u7684\u9b54\u6cd5 &#x1fa84;<\/p>\n<p>OBJS &#061; src\/main.o src\/Mymath.o<br \/>\nDEPS &#061; $(OBJS:.o&#061;.d)<\/p>\n<p>\u8fd9\u4e24\u884c\u7684\u4f5c\u7528\u662f\u81ea\u52a8\u751f\u6210\u6587\u4ef6\u540d\u5217\u8868&#xff1a;<\/p>\n<ul>\n<li>\n<p>OBJS&#xff1a;\u4f60\u624b\u52a8\u5b9a\u4e49\u7684\u4e24\u4e2a .o \u76ee\u6807\u6587\u4ef6\u3002<\/p>\n<\/li>\n<li>\n<p>DEPS &#061; $(OBJS:.o&#061;.d)&#xff1a;\u8fd9\u662f\u4e00\u79cd\u540e\u7f00\u66ff\u6362\u8bed\u6cd5\u3002\u5b83\u7684\u610f\u601d\u662f&#xff1a;\u628a OBJS \u53d8\u91cf\u4e2d\u6240\u6709\u4ee5 .o \u7ed3\u5c3e\u7684\u90e8\u5206\u90fd\u6362\u6210 .d\u3002<\/p>\n<\/li>\n<li>\n<p>\u7ed3\u679c&#xff1a;\u73b0\u5728 DEPS \u53d8\u91cf\u7684\u5185\u5bb9\u5c31\u53d8\u6210\u4e86 src\/main.d src\/Mymath.d\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<p>2. \u8fd9\u91cc\u7684 include \u662f\u4ec0\u4e48\u610f\u601d&#xff1f; &#x1f4c2;<\/p>\n<p>\u5728 C&#043;&#043; \u4ee3\u7801\u91cc&#xff0c;#include \u662f\u5305\u542b\u5934\u6587\u4ef6&#xff1b;\u800c\u5728 Makefile \u91cc&#xff0c;include \u662f\u5305\u542b\u53e6\u4e00\u4e2a Makefile \u7247\u6bb5\u3002<\/p>\n<ul>\n<li>\n<p>\u8fd8\u8bb0\u5f97\u6211\u4eec\u7ed9 CXXFLAGS \u52a0\u4e0a\u4e86 MMD \u5417&#xff1f;<\/p>\n<\/li>\n<li>\n<p>\u5f53\u7f16\u8bd1\u5668\u6267\u884c g&#043;&#043; -c main.cpp -MMD \u65f6&#xff0c;\u5b83\u4f1a\u4ea7\u751f\u4e24\u4e2a\u6587\u4ef6&#xff1a;main.o \u548c\u4e00\u4e2a\u7eaf\u6587\u672c\u7684 main.d\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd9\u4e2a main.d \u91cc\u7684\u5185\u5bb9\u5927\u6982\u957f\u8fd9\u6837&#xff1a;src\/main.o: src\/main.cpp header\/Mymath.h\u3002<\/p>\n<\/li>\n<li>\n<p>include $(DEPS) \u7684\u4f5c\u7528\u5c31\u662f\u628a\u8fd9\u4e9b\u751f\u6210\u7684 .d \u6587\u4ef6\u50cf\u201c\u62fc\u56fe\u201d\u4e00\u6837\u62fc\u8fdb\u5f53\u524d\u7684 Makefile \u91cc\u3002\u8fd9\u6837 make \u5c31\u77e5\u9053&#xff1a;\u539f\u6765 main.o \u4e0d\u4ec5\u4f9d\u8d56 .cpp&#xff0c;\u8fd8\u4f9d\u8d56 Mymath.h&#xff01;<\/p>\n<\/li>\n<\/ul>\n<p>\u4e3a\u4ec0\u4e48\u7528 -include \u800c\u4e0d\u662f include&#xff1f;<\/p>\n<p>\u52a0\u4e2a\u6a2a\u6760 &#8211; \u662f\u4e3a\u4e86\u544a\u8bc9 make&#xff1a;\u201c\u5982\u679c\u8fd9\u4e9b .d \u6587\u4ef6\u8fd8\u6ca1\u751f\u6210&#xff08;\u6bd4\u5982\u7b2c\u4e00\u6b21\u7f16\u8bd1\u65f6&#xff09;&#xff0c;\u8bf7\u5ffd\u7565\u9519\u8bef\u7ee7\u7eed\u8dd1&#xff0c;\u522b\u7f62\u5de5\u3002\u201d<\/p>\n<hr \/>\n<p>3. .PHONY&#xff1a;\u9632\u6b62\u540c\u540d\u201c\u649e\u8f66\u201d &#x1f3f7;\ufe0f<\/p>\n<p>.PHONY: clean<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u9632\u5fa1\u6027\u6307\u4ee4\u3002<\/p>\n<p>\u5728 Makefile \u4e2d&#xff0c;\u89c4\u5219\u7684\u5de6\u8fb9\u901a\u5e38\u662f\u4e00\u4e2a\u771f\u5b9e\u7684\u6587\u4ef6\u540d\u3002\u5982\u679c\u4f60\u5728\u6587\u4ef6\u5939\u91cc\u771f\u7684\u521b\u5efa\u4e86\u4e00\u4e2a\u53eb clean \u7684\u7a7a\u6587\u4ef6&#xff0c;make \u5c31\u4f1a\u9677\u5165\u56f0\u60d1\u3002<\/p>\n<p>\u7531\u4e8e make \u7684\u6838\u5fc3\u903b\u8f91\u662f\u5bf9\u6bd4\u201c\u76ee\u6807\u6587\u4ef6\u201d\u548c\u201c\u4f9d\u8d56\u6587\u4ef6\u201d\u7684\u65f6\u95f4\u6233&#xff0c;\u5982\u679c\u76ee\u5f55\u4e0b\u771f\u7684\u6709\u4e00\u4e2a\u53eb clean \u7684\u6587\u4ef6&#xff0c;\u800c\u4f60\u5728 Makefile \u91cc\u5199\u7684 clean: \u540e\u9762\u6ca1\u6709\u4efb\u4f55\u4f9d\u8d56\u9879&#xff0c;make \u5c31\u4f1a\u8ba4\u4e3a&#xff1a;<\/p>\n<li>\n<p>clean \u8fd9\u4e2a\u6587\u4ef6\u5df2\u7ecf\u5b58\u5728\u4e86\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b83\u6ca1\u6709\u4efb\u4f55\u4f9d\u8d56\u9879&#xff0c;\u6240\u4ee5\u5b83\u6c38\u8fdc\u4e0d\u4f1a\u201c\u8fc7\u671f\u201d\u3002<\/p>\n<\/li>\n<li>\n<p>\u7ed3\u8bba&#xff1a;\u4e0d\u9700\u8981\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\u3002<\/p>\n<\/li>\n<p style=\"text-align:center\">\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u6211\u4eec\u8981\u4f7f\u7528 .PHONY&#xff08;\u610f\u4e3a\u201c\u4f2a\u9020\u7684\u201d\u6216\u201c\u865a\u540d\u7684\u201d&#xff09;\u3002\u5b83\u544a\u8bc9 make&#xff1a;\u201c\u4e0d\u8981\u628a clean \u5f53\u6210\u4e00\u4e2a\u6587\u4ef6&#xff0c;\u5b83\u53ea\u662f\u4e00\u4e2a\u547d\u4ee4\u7684\u540d\u5b57&#xff0c;\u6bcf\u6b21\u6211\u8f93\u5165 make clean \u65f6&#xff0c;\u4f60\u5c3d\u7ba1\u6267\u884c\u5c31\u5bf9\u4e86&#xff01;\u201d &#x1f3f7;\ufe0f<img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260125042432-69759b000f47c.png\" \/><\/p>\n<hr \/>\n<p>\u611f\u8c22\u4f60\u80fd\u770b\u5230\u8fd9\u91cc \u5982\u679c\u672c\u6587\u5bf9\u4f60\u7f16\u5199makefile\u6709\u4e00\u70b9\u70b9\u5e2e\u52a9 \u90a3\u5c31\u662f\u6211\u6700\u5927\u7684\u5fc3\u613f \u4e0b\u7bc7\u518d\u89c1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Makefile\u7684\u7f16\u51991. Makefile \u7684\u6838\u5fc3\u89c4\u5219Makefile \u7684\u8bed\u6cd5\u975e\u5e38\u56fa\u5b9a&#xff0c;\u7531\u4e09\u90e8\u5206\u7ec4\u6210&#xff1a;\u76ee\u6807(Target): \u4f9d\u8d56(Dependencies) \u547d\u4ee4(Command)\u6ce8\u610f&#xff1a;\u547d\u4ee4\u524d\u9762\u5fc5\u987b\u662f\u4e00\u4e2a Tab \u952e&#xff0c;\u4e0d\u80fd\u662f\u7a7a\u683c&#xff0c;\u5426\u5219\u4f1a\u62a5\u9519\u30022. Makefile \u7684\u5206\u6b65\u7f16\u5199\u6211\u4eec\u53ef\u4ee5\u628a Makefile \u770b\u4f5c\u662f\u4e00\u4efd\u7ed9 make \u5de5\u5177\u9605\u8bfb\u7684\u201c\u914d\u65b9\u8bf4\u660e\u4e66\u201d &#x1f4dd;\u3002\u5b83\u544a\u8bc9\u5de5\u5177&amp;#xf<\/p>\n","protected":false},"author":2,"featured_media":65599,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[352,55,58,103,43,44],"topic":[],"class_list":["post-65600","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-bash","tag-c","tag-linux","tag-ubuntu","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/65600.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Makefile\u7684\u7f16\u51991. Makefile \u7684\u6838\u5fc3\u89c4\u5219Makefile \u7684\u8bed\u6cd5\u975e\u5e38\u56fa\u5b9a&#xff0c;\u7531\u4e09\u90e8\u5206\u7ec4\u6210&#xff1a;\u76ee\u6807(Target): \u4f9d\u8d56(Dependencies) \u547d\u4ee4(Command)\u6ce8\u610f&#xff1a;\u547d\u4ee4\u524d\u9762\u5fc5\u987b\u662f\u4e00\u4e2a Tab \u952e&#xff0c;\u4e0d\u80fd\u662f\u7a7a\u683c&#xff0c;\u5426\u5219\u4f1a\u62a5\u9519\u30022. Makefile \u7684\u5206\u6b65\u7f16\u5199\u6211\u4eec\u53ef\u4ee5\u628a Makefile \u770b\u4f5c\u662f\u4e00\u4efd\u7ed9 make \u5de5\u5177\u9605\u8bfb\u7684\u201c\u914d\u65b9\u8bf4\u660e\u4e66\u201d &#x1f4dd;\u3002\u5b83\u544a\u8bc9\u5de5\u5177&amp;#xf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/65600.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-25T04:24:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260125042432-69759b000f47c.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/65600.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/65600.html\",\"name\":\"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-25T04:24:33+00:00\",\"dateModified\":\"2026-01-25T04:24:33+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/65600.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/65600.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/65600.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/65600.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Makefile\u7684\u7f16\u51991. Makefile \u7684\u6838\u5fc3\u89c4\u5219Makefile \u7684\u8bed\u6cd5\u975e\u5e38\u56fa\u5b9a&#xff0c;\u7531\u4e09\u90e8\u5206\u7ec4\u6210&#xff1a;\u76ee\u6807(Target): \u4f9d\u8d56(Dependencies) \u547d\u4ee4(Command)\u6ce8\u610f&#xff1a;\u547d\u4ee4\u524d\u9762\u5fc5\u987b\u662f\u4e00\u4e2a Tab \u952e&#xff0c;\u4e0d\u80fd\u662f\u7a7a\u683c&#xff0c;\u5426\u5219\u4f1a\u62a5\u9519\u30022. Makefile \u7684\u5206\u6b65\u7f16\u5199\u6211\u4eec\u53ef\u4ee5\u628a Makefile \u770b\u4f5c\u662f\u4e00\u4efd\u7ed9 make \u5de5\u5177\u9605\u8bfb\u7684\u201c\u914d\u65b9\u8bf4\u660e\u4e66\u201d &#x1f4dd;\u3002\u5b83\u544a\u8bc9\u5de5\u5177&amp;#xf","og_url":"https:\/\/www.wsisp.com\/helps\/65600.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-25T04:24:33+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260125042432-69759b000f47c.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/65600.html","url":"https:\/\/www.wsisp.com\/helps\/65600.html","name":"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-25T04:24:33+00:00","dateModified":"2026-01-25T04:24:33+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/65600.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/65600.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/65600.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u5b9e\u6218\uff08\u4e09\uff09\uff1amakefile\u7684\u7f16\u5199"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/65600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=65600"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/65600\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/65599"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=65600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=65600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=65600"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=65600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}