{"id":79336,"date":"2026-03-01T20:57:30","date_gmt":"2026-03-01T12:57:30","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/79336.html"},"modified":"2026-03-01T20:57:30","modified_gmt":"2026-03-01T12:57:30","slug":"c%e5%a4%9a%e6%96%87%e4%bb%b6%e7%bc%96%e7%a8%8b%e3%80%81makefile%e4%b8%8ecmake%e5%85%a8%e6%94%bb%e7%95%a5%ef%bc%9a%e4%bb%8e%e5%8e%9f%e7%90%86%e5%88%b0%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/79336.html","title":{"rendered":"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218"},"content":{"rendered":"<p>\u5728C&#043;&#043;\u5927\u578b\u9879\u76ee\u5f00\u53d1\u4e2d&#xff0c;\u591a\u6587\u4ef6\u7f16\u7a0b\u662f\u6a21\u5757\u5316\u7684\u57fa\u7840&#xff0c;\u5bf9\u4e8e\u9879\u76ee\u7684\u53ef\u7ef4\u62a4\u6027\u81f3\u5173\u91cd\u8981\u3002\u800cMakefile\u4e0eCMake\u5219\u662f\u89e3\u51b3\u9879\u76ee\u7f16\u8bd1\u3001\u94fe\u63a5\u3001\u7ba1\u7406\u96be\u9898\u7684\u6838\u5fc3\u5de5\u5177\u3002\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u56f0\u60d1&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u62c6\u5206\u6587\u4ef6&#xff1f;Makefile\u600e\u4e48\u5199&#xff1f;CMake\u4e0eMakefile\u7684\u5173\u7cfb\u548c\u533a\u522b\u662f\u4ec0\u4e48&#xff1f;\u672c\u6587\u5c06\u4ece\u539f\u7406\u5230\u5b9e\u6218&#xff0c;\u8bb2\u89e3\u8fd9\u4e09\u5927\u6838\u5fc3\u77e5\u8bc6\u70b9&#xff0c;\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1C&#043;&#043;\u9879\u76ee\u7684\u6784\u5efa\u903b\u8f91\u3002<\/p>\n<h3>\u4e00\u3001C&#043;&#043;\u591a\u6587\u4ef6\u7f16\u7a0b&#xff1a;<\/h3>\n<h4>1. \u4e3a\u4ec0\u4e48\u9700\u8981\u591a\u6587\u4ef6\u7f16\u7a0b&#xff1f;<\/h4>\n<p>\u5728\u5355\u6587\u4ef6\u7f16\u7a0b\u4e2d&#xff0c;\u6240\u6709\u4ee3\u7801\u90fd\u5199\u5728\u4e00\u4e2a .cpp \u6587\u4ef6\u91cc&#xff0c;\u8fd9\u5bf9\u4e8e\u4ee3\u7801\u91cf\u5f88\u5c0f\u7684\u8bfe\u5802\u4f5c\u4e1a\u6216\u8005\u7ade\u8d5b\u9898\u76ee\u6765\u8bf4\u6ca1\u6709\u95ee\u9898&#xff0c;\u4f46\u5728\u5927\u578b\u9879\u76ee\u4e2d&#xff0c;\u4f1a\u51fa\u73b0\u4ee3\u7801\u81c3\u80bf\u3001\u8026\u5408\u5ea6\u9ad8\u3001\u7f16\u8bd1\u6548\u7387\u4f4e\u3001\u96be\u4ee5\u591a\u4eba\u534f\u4f5c\u7b49\u95ee\u9898\u3002<\/p>\n<p>\u591a\u6587\u4ef6\u7f16\u7a0b\u7684\u6838\u5fc3\u601d\u60f3\u662f\u6a21\u5757\u5316\u62c6\u5206&#xff1a;\u5c06\u58f0\u660e&#xff08;\u51fd\u6570\u3001\u7c7b\u3001\u53d8\u91cf&#xff09;\u653e\u5728\u5934\u6587\u4ef6&#xff08;.h\/.hpp&#xff09;&#xff0c;\u5c06\u5b9e\u73b0\u653e\u5728\u6e90\u6587\u4ef6&#xff08;.cpp&#xff09;&#xff0c;\u901a\u8fc7\u7f16\u8bd1\u3001\u94fe\u63a5\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<p>\u6838\u5fc3\u4f18\u52bf&#xff1a;<\/p>\n<ul>\n<li>\u7f16\u8bd1\u9ad8\u6548&#xff1a;\u4fee\u6539\u5355\u4e2a\u6587\u4ef6\u53ea\u9700\u91cd\u65b0\u7f16\u8bd1\u8be5\u6587\u4ef6&#xff0c;\u65e0\u9700\u5168\u91cf\u7f16\u8bd1<\/li>\n<li>\u534f\u4f5c\u5f00\u53d1&#xff1a;\u53ef\u4ee5\u591a\u4eba\u8d1f\u8d23\u4e0d\u540c\u6a21\u5757&#xff0c;\u4e92\u4e0d\u5e72\u6270<\/li>\n<li>\u53ef\u7ef4\u62a4\u6027&#xff1a;\u6309\u529f\u80fd\u62c6\u5206\u6587\u4ef6&#xff0c;\u7ed3\u6784\u6e05\u6670&#xff0c;\u65b9\u4fbf\u7ef4\u62a4<\/li>\n<\/ul>\n<h4>2. \u591a\u6587\u4ef6\u7f16\u7a0b\u7684\u6838\u5fc3\u89c4\u5219<\/h4>\n<p>C&#043;&#043;\u591a\u6587\u4ef6\u7f16\u7a0b\u7684\u672c\u8d28\u662f\u5206\u79bb\u7f16\u8bd1&#043;\u94fe\u63a5&#xff0c;\u5fc5\u987b\u9075\u5b88\u4ee5\u4e0b\u89c4\u5219&#xff1a;<\/p>\n<li>\u5934\u6587\u4ef6\u653e\u58f0\u660e&#xff0c;\u6e90\u6587\u4ef6\u653e\u5b9e\u73b0<br \/>\n\u5934\u6587\u4ef6&#xff08; .h \/ .hpp &#xff09;&#xff1a;\u58f0\u660e\u51fd\u6570\u539f\u578b\u3001\u7c7b\u5b9a\u4e49\u3001\u5b8f\u5b9a\u4e49\u3001\u5168\u5c40\u53d8\u91cf\u58f0\u660e&#xff08;\u52a0 extern &#xff09;\u3002<br \/>\n\u6e90\u6587\u4ef6&#xff08; .cpp &#xff09;&#xff1a;\u5b9e\u73b0\u5934\u6587\u4ef6\u4e2d\u7684\u51fd\u6570\u3001\u7c7b\u6210\u5458\u51fd\u6570\u3002<\/li>\n<li>\u5934\u6587\u4ef6\u5fc5\u987b\u52a0\u4fdd\u62a4\u5b8f&#xff0c;\u9632\u6b62\u91cd\u590d\u5305\u542b<br \/>\n\u591a\u6b21\u5f15\u7528\u540c\u4e00\u4e2a\u5934\u6587\u4ef6\u4f1a\u5bfc\u81f4\u91cd\u590d\u5b9a\u4e49\u62a5\u9519&#xff0c;\u9700\u7528 #ifndef\/#define\/#endif \u6216 #pragma once \u4fdd\u62a4\u3002<\/li>\n<li>\u5168\u5c40\u53d8\u91cf\/\u51fd\u6570\u9700\u7528 extern \u58f0\u660e<br \/>\n\u8de8\u6587\u4ef6\u4f7f\u7528\u5168\u5c40\u53d8\u91cf\u65f6&#xff0c;\u5934\u6587\u4ef6\u7528 extern \u58f0\u660e&#xff0c;\u6e90\u6587\u4ef6\u5b9a\u4e49&#xff0c;\u907f\u514d\u91cd\u590d\u5b9a\u4e49\u3002<\/li>\n<li>\u5728\u7f16\u8bd1\u65f6&#xff0c;\u6240\u6709\u6e90\u6587\u4ef6\u9700\u8981\u5404\u81ea\u53c2\u4e0e\u7f16\u8bd1&#xff0c;\u6700\u7ec8\u94fe\u63a5\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u3002<br \/>\n\u6bcf\u4e2a .cpp \u6587\u4ef6\u4f1a\u88ab\u7f16\u8bd1\u4e3a\u72ec\u7acb\u7684\u76ee\u6807\u6587\u4ef6&#xff08; .o \/ .obj &#xff09;&#xff0c;\u7f16\u8bd1\u5668\u5904\u7406\u6bcf\u4e2a .cpp \u65f6&#xff0c;\u4f1a\u5c06 #include \u7684\u5185\u5bb9\u76f4\u63a5\u63d2\u5165\u5230\u8be5\u6587\u4ef6\u4e2d&#xff0c;\u5f62\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u7f16\u8bd1\u5355\u5143\u3002<br \/>\n\u6240\u6709\u7f16\u8bd1\u5355\u5143\u7f16\u8bd1\u540e&#xff0c;\u94fe\u63a5\u5668\u5c06\u5b83\u4eec\u5408\u5e76&#xff0c;\u89e3\u6790\u8de8\u6587\u4ef6\u7684\u7b26\u53f7\u5f15\u7528&#xff08;\u5982\u4e00\u4e2a .cpp \u8c03\u7528\u53e6\u4e00\u4e2a .cpp \u4e2d\u5b9a\u4e49\u7684\u51fd\u6570&#xff09;&#xff0c;\u6700\u7ec8\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/li>\n<h4>3. \u591a\u6587\u4ef6\u7f16\u7a0b\u5b9e\u6218\u6848\u4f8b<\/h4>\n<p>\u6211\u4eec\u4ee5\u4e00\u4e2a\u7b80\u5355\u7684\u8ba1\u7b97\u5668\u9879\u76ee\u4e3a\u4f8b&#xff0c;\u62c6\u52063\u4e2a\u6587\u4ef6&#xff1a;<\/p>\n<ul>\n<li>calc.h &#xff1a;\u5934\u6587\u4ef6&#xff0c;\u58f0\u660e\u51fd\u6570<\/li>\n<li>calc.cpp &#xff1a;\u6e90\u6587\u4ef6&#xff0c;\u5b9e\u73b0\u51fd\u6570<\/li>\n<li>main.cpp &#xff1a;\u4e3b\u51fd\u6570&#xff0c;\u8c03\u7528\u529f\u80fd<\/li>\n<\/ul>\n<p>&#xff08;1&#xff09;calc.h&#xff08;\u5934\u6587\u4ef6&#xff1a;\u58f0\u660e&#xff09;<\/p>\n<p><span class=\"token comment\">\/\/ \u5934\u6587\u4ef6\u4fdd\u62a4\u5b8f&#xff0c;\u9632\u6b62\u91cd\u590d\u5305\u542b<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">ifndef<\/span> <span class=\"token expression\">CALC_H<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">define<\/span> <span class=\"token macro-name\">CALC_H<\/span><\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u51fd\u6570\u58f0\u660e<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">sub<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">endif<\/span><\/span><\/p>\n<p>&#xff08;2&#xff09;calc.cpp&#xff08;\u6e90\u6587\u4ef6&#xff1a;\u5b9e\u73b0&#xff09;<\/p>\n<p><span class=\"token comment\">\/\/ \u5305\u542b\u5bf9\u5e94\u7684\u5934\u6587\u4ef6<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;calc.h&#034;<\/span><\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u51fd\u6570\u5b9e\u73b0<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">&#043;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">sub<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> a<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> b<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> a <span class=\"token operator\">&#8211;<\/span> b<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>&#xff08;3&#xff09;main.cpp&#xff08;\u4e3b\u51fd\u6570&#xff1a;\u8c03\u7528&#xff09;<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;iostream&gt;<\/span><\/span><br \/>\n<span class=\"token comment\">\/\/ \u5305\u542b\u81ea\u5b9a\u4e49\u5934\u6587\u4ef6<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&#034;calc.h&#034;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;10 &#043; 5 &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token function\">add<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><br \/>\n    std<span class=\"token double-colon punctuation\">::<\/span>cout <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token string\">&#034;10 &#8211; 5 &#061; &#034;<\/span> <span class=\"token operator\">&lt;&lt;<\/span> <span class=\"token function\">sub<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&lt;&lt;<\/span> std<span class=\"token double-colon punctuation\">::<\/span>endl<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>&#xff08;4&#xff09;\u624b\u52a8\u7f16\u8bd1\u4e0e\u8fd0\u884c<\/p>\n<p>\u6ca1\u6709\u6784\u5efa\u5de5\u5177\u65f6&#xff0c;\u9700\u624b\u52a8\u7f16\u8bd1\u6240\u6709\u6e90\u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u7f16\u8bd1calc.cpp\u751f\u6210calc.o<\/span><br \/>\ng&#043;&#043; <span class=\"token parameter variable\">-c<\/span> calc.cpp <span class=\"token parameter variable\">-o<\/span> calc.o<br \/>\n<span class=\"token comment\"># \u7f16\u8bd1main.cpp\u751f\u6210main.o<\/span><br \/>\ng&#043;&#043; <span class=\"token parameter variable\">-c<\/span> main.cpp <span class=\"token parameter variable\">-o<\/span> main.o<br \/>\n<span class=\"token comment\"># \u94fe\u63a5\u6240\u6709\u76ee\u6807\u6587\u4ef6\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/span><br \/>\ng&#043;&#043; calc.o main.o <span class=\"token parameter variable\">-o<\/span> calc_demo<br \/>\n<span class=\"token comment\"># \u8fd0\u884c<\/span><br \/>\n.\/calc_demo<\/p>\n<p>\u8f93\u51fa\u7ed3\u679c&#xff1a;<\/p>\n<p>10 &#043; 5 &#061; 15<br \/>\n10 &#8211; 5 &#061; 5<\/p>\n<p>\u624b\u52a8\u7f16\u8bd1\u7684\u5f0a\u7aef&#xff1a;\u6587\u4ef6\u8d8a\u591a&#xff0c;\u547d\u4ee4\u8d8a\u590d\u6742&#xff0c;\u6781\u6613\u51fa\u9519&#xff0c;\u8fd9\u65f6\u5019\u5c31\u9700\u8981Makefile\u6765\u81ea\u52a8\u5316\u6784\u5efa\u3002<\/p>\n<h3>\u4e8c\u3001Makefile&#xff1a;\u81ea\u52a8\u5316\u7f16\u8bd1\u7684\u6838\u5fc3\u5de5\u5177<\/h3>\n<h4>1. Makefile\u662f\u4ec0\u4e48&#xff1f;<\/h4>\n<p>Makefile\u662f\u4e00\u4e2a\u6784\u5efa\u811a\u672c&#xff0c;\u901a\u8fc7 make \u5de5\u5177\u89e3\u6790&#xff0c;\u5b9e\u73b0\u81ea\u52a8\u5316\u7f16\u8bd1\u3001\u94fe\u63a5\u3001\u6e05\u7406\u9879\u76ee\u3002\u5b83\u4f1a\u6839\u636e\u6587\u4ef6\u7684\u65f6\u95f4\u6233&#xff0c;\u53ea\u7f16\u8bd1\u4fee\u6539\u8fc7\u7684\u6587\u4ef6&#xff0c;\u5927\u5e45\u63d0\u5347\u7f16\u8bd1\u6548\u7387\u3002<\/p>\n<p>\u6838\u5fc3\u529f\u80fd&#xff1a;<\/p>\n<ul>\n<li>\u5b9a\u4e49\u7f16\u8bd1\u89c4\u5219&#xff1a;\u6307\u5b9a\u6e90\u6587\u4ef6\u3001\u76ee\u6807\u6587\u4ef6\u3001\u7f16\u8bd1\u53c2\u6570<\/li>\n<li>\u81ea\u52a8\u5316\u6784\u5efa&#xff1a;\u4e00\u884c\u547d\u4ee4\u5b8c\u6210\u5168\u9879\u76ee\u7f16\u8bd1<\/li>\n<li>\u589e\u91cf\u7f16\u8bd1&#xff1a;\u4ec5\u91cd\u65b0\u7f16\u8bd1\u4fee\u6539\u8fc7\u7684\u6587\u4ef6<\/li>\n<li>\u652f\u6301\u6e05\u7406\u3001\u5b89\u88c5\u7b49\u6269\u5c55\u64cd\u4f5c<\/li>\n<\/ul>\n<h4>2. Makefile\u7684\u57fa\u672c\u8bed\u6cd5<\/h4>\n<p>Makefile\u7684\u6838\u5fc3\u662f\u89c4\u5219&#xff0c;\u8bed\u6cd5\u683c\u5f0f&#xff1a;<\/p>\n<p>\u76ee\u6807\u6587\u4ef6: \u4f9d\u8d56\u6587\u4ef6<br \/>\n[Tab] \u7f16\u8bd1\u547d\u4ee4<\/p>\n<ul>\n<li>\u76ee\u6807\u6587\u4ef6&#xff1a;\u8981\u751f\u6210\u7684\u6587\u4ef6&#xff08;\u5982\u53ef\u6267\u884c\u6587\u4ef6\u3001\u76ee\u6807\u6587\u4ef6&#xff09;<\/li>\n<li>\u4f9d\u8d56\u6587\u4ef6&#xff1a;\u751f\u6210\u76ee\u6807\u6240\u9700\u7684\u6587\u4ef6&#xff08;\u5982 .cpp \u3001 .h &#xff09;<\/li>\n<li>\u7f16\u8bd1\u547d\u4ee4&#xff1a;\u5fc5\u987b\u4ee5Tab\u952e\u5f00\u5934&#xff0c;\u4e0d\u80fd\u7528\u7a7a\u683c<\/li>\n<\/ul>\n<h4>3. Makefile\u6838\u5fc3\u5173\u952e\u5b57<\/h4>\n<ul>\n<li>CC &#xff1a;\u7f16\u8bd1\u5668&#xff08;\u5982 g&#043;&#043; &#xff09;<\/li>\n<li>CFLAGS &#xff1a;\u7f16\u8bd1\u53c2\u6570&#xff08;\u5982 -Wall \u5f00\u542f\u8b66\u544a&#xff09;<\/li>\n<li>$&#064; &#xff1a;\u76ee\u6807\u6587\u4ef6<\/li>\n<li>$^ &#xff1a;\u6240\u6709\u4f9d\u8d56\u6587\u4ef6<\/li>\n<li>$&lt; &#xff1a;\u7b2c\u4e00\u4e2a\u4f9d\u8d56\u6587\u4ef6<\/li>\n<li>.PHONY &#xff1a;\u58f0\u660e\u4f2a\u76ee\u6807&#xff08;\u5982 clean &#xff0c;\u907f\u514d\u548c\u540c\u540d\u6587\u4ef6\u51b2\u7a81&#xff09;<\/li>\n<\/ul>\n<h4>4. Makefile\u5b9e\u6218&#xff1a;\u7f16\u8bd1\u4e0a\u6587\u8ba1\u7b97\u5668\u9879\u76ee<\/h4>\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u521b\u5efa Makefile \u6587\u4ef6&#xff0c;\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p># \u5b9a\u4e49\u7f16\u8bd1\u5668<br \/>\nCC &#061; g&#043;&#043;<br \/>\n# \u7f16\u8bd1\u53c2\u6570&#xff1a;\u5f00\u542f\u6240\u6709\u8b66\u544a<br \/>\nCFLAGS &#061; -Wall<br \/>\n# \u76ee\u6807\u53ef\u6267\u884c\u6587\u4ef6<br \/>\nTARGET &#061; calc_demo<br \/>\n# \u6240\u6709\u76ee\u6807\u6587\u4ef6<br \/>\nOBJS &#061; main.o calc.o<\/p>\n<p># \u6700\u7ec8\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6<br \/>\n$(TARGET): $(OBJS)<br \/>\n$(CC) $^ -o $&#064;<\/p>\n<p># \u7f16\u8bd1main.o<br \/>\nmain.o: main.cpp calc.h<br \/>\n$(CC) $(CFLAGS) -c $&lt; -o $&#064;<\/p>\n<p># \u7f16\u8bd1calc.o<br \/>\ncalc.o: calc.cpp calc.h<br \/>\n$(CC) $(CFLAGS) -c $&lt; -o $&#064;<\/p>\n<p># \u4f2a\u76ee\u6807&#xff1a;\u6e05\u7406\u751f\u6210\u7684\u6587\u4ef6<br \/>\n.PHONY: clean<br \/>\nclean:<br \/>\nrm -f $(OBJS) $(TARGET)<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5&#xff1a;<\/p>\n<li>\u7f16\u8bd1\u9879\u76ee&#xff1a;\u76f4\u63a5\u5728\u7ec8\u7aef\u6267\u884c make<\/li>\n<li>\u6e05\u7406\u6587\u4ef6&#xff1a;\u6267\u884c make clean<\/li>\n<li>\u518d\u6b21\u7f16\u8bd1&#xff1a;\u4fee\u6539\u4efb\u610f\u6587\u4ef6\u540e&#xff0c;\u91cd\u65b0\u6267\u884c make &#xff0c;\u4ec5\u7f16\u8bd1\u4fee\u6539\u7684\u6587\u4ef6<\/li>\n<h4>5. Makefile\u7684\u5c40\u9650\u6027<\/h4>\n<p>Makefile\u867d\u7136\u89e3\u51b3\u4e86\u81ea\u52a8\u5316\u7f16\u8bd1\u95ee\u9898&#xff0c;\u4f46\u5b58\u5728\u660e\u663e\u77ed\u677f&#xff1a;<\/p>\n<ul>\n<li>\u8de8\u5e73\u53f0\u6027\u5dee&#xff1a;Windows\u3001Linux\u3001Mac\u7684Make\u5de5\u5177\u4e0d\u517c\u5bb9<\/li>\n<li>\u8bed\u6cd5\u7e41\u7410&#xff1a;\u5927\u578b\u9879\u76ee\u7684Makefile\u6781\u5176\u590d\u6742&#xff0c;\u96be\u4ee5\u7ef4\u62a4<\/li>\n<li>\u4f9d\u8d56\u7ba1\u7406\u5f31&#xff1a;\u5904\u7406\u7b2c\u4e09\u65b9\u5e93\u3001\u591a\u76ee\u5f55\u9879\u76ee\u65f6\u6548\u7387\u4f4e<\/li>\n<\/ul>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898&#xff0c;CMake\u5e94\u8fd0\u800c\u751f\u3002<\/p>\n<h3>\u4e09\u3001CMake&#xff1a;\u8de8\u5e73\u53f0\u7684\u6784\u5efa\u5de5\u5177\u751f\u6210\u5668<\/h3>\n<h4>1. CMake\u662f\u4ec0\u4e48&#xff1f;<\/h4>\n<p>CMake\u4e0d\u662f\u7f16\u8bd1\u5668&#xff0c;\u4e5f\u4e0d\u662f\u76f4\u63a5\u7684\u6784\u5efa\u5de5\u5177&#xff0c;\u800c\u662f\u6784\u5efa\u5de5\u5177\u751f\u6210\u5668\u3002\u5b83\u4f1a\u6839\u636e\u9879\u76ee\u914d\u7f6e&#xff0c;\u81ea\u52a8\u751f\u6210\u5bf9\u5e94\u5e73\u53f0\u7684Makefile\u3001Visual Studio\u5de5\u7a0b\u3001Xcode\u5de5\u7a0b\u7b49&#xff0c;\u5b9e\u73b0\u4e00\u6b21\u7f16\u5199&#xff0c;\u8de8\u5e73\u53f0\u6784\u5efa\u3002<\/p>\n<p>\u6838\u5fc3\u4f18\u52bf&#xff1a;<\/p>\n<ul>\n<li>\u8de8\u5e73\u53f0&#xff1a;\u652f\u6301Windows\u3001Linux\u3001Mac\u3001Android\u7b49\u6240\u6709\u4e3b\u6d41\u5e73\u53f0<\/li>\n<li>\u8bed\u6cd5\u7b80\u6d01&#xff1a;\u6bd4Makefile\u7b80\u535510\u500d&#xff0c;\u6613\u8bfb\u6613\u5199<\/li>\n<li>\u81ea\u52a8\u7ba1\u7406\u4f9d\u8d56&#xff1a;\u8f7b\u677e\u5904\u7406\u591a\u76ee\u5f55\u3001\u7b2c\u4e09\u65b9\u5e93\u3001\u5b50\u6a21\u5757<\/li>\n<li>\u96c6\u6210\u5ea6\u9ad8&#xff1a;\u9002\u914d\u6240\u6709\u4e3b\u6d41IDE\u548c\u6784\u5efa\u5de5\u5177<\/li>\n<\/ul>\n<h4>2. CMake\u7684\u6838\u5fc3\u6d41\u7a0b<\/h4>\n<li>\u7f16\u5199 CMakeLists.txt &#xff1a;CMake\u7684\u914d\u7f6e\u6587\u4ef6&#xff0c;\u6838\u5fc3\u5165\u53e3<\/li>\n<li>\u6267\u884c cmake . &#xff1a;\u751f\u6210\u5bf9\u5e94\u5e73\u53f0\u7684\u6784\u5efa\u6587\u4ef6&#xff08;\u5982Makefile&#xff09;<\/li>\n<li>\u6267\u884c make \/\u7f16\u8bd1IDE\u5de5\u7a0b&#xff1a;\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/li>\n<h4>3. CMake\u57fa\u672c\u8bed\u6cd5<\/h4>\n<ul>\n<li>cmake_minimum_required &#xff1a;\u6307\u5b9aCMake\u6700\u4f4e\u7248\u672c<\/li>\n<li>project &#xff1a;\u5b9a\u4e49\u9879\u76ee\u540d\u79f0<\/li>\n<li>add_executable &#xff1a;\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6&#xff0c;\u6307\u5b9a\u6e90\u6587\u4ef6<\/li>\n<li>include_directories &#xff1a;\u6dfb\u52a0\u5934\u6587\u4ef6\u641c\u7d22\u8def\u5f84<\/li>\n<li>add_subdirectory &#xff1a;\u6dfb\u52a0\u5b50\u76ee\u5f55<\/li>\n<li>target_link_libraries &#xff1a;\u94fe\u63a5\u7b2c\u4e09\u65b9\u5e93<\/li>\n<\/ul>\n<h4>4. CMake\u5b9e\u6218&#xff1a;\u7f16\u8bd1\u8ba1\u7b97\u5668\u9879\u76ee<\/h4>\n<p>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u521b\u5efa CMakeLists.txt &#xff0c;\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p># \u6307\u5b9aCMake\u6700\u4f4e\u7248\u672c<br \/>\ncmake_minimum_required(VERSION 3.10)<br \/>\n# \u5b9a\u4e49\u9879\u76ee\u540d\u79f0<br \/>\nproject(CalcDemo)<br \/>\n# \u8bbe\u7f6eC&#043;&#043;\u6807\u51c6<br \/>\nset(CMAKE_CXX_STANDARD 11)<br \/>\n# \u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6&#xff1a;\u76ee\u6807\u540d &#043; \u6240\u6709\u6e90\u6587\u4ef6<br \/>\nadd_executable(calc_demo main.cpp calc.cpp)<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5&#xff1a;<\/p>\n<li>\u65b0\u5efa\u6784\u5efa\u76ee\u5f55&#xff08;\u63a8\u8350\u5916\u90e8\u6784\u5efa&#xff0c;\u907f\u514d\u6c61\u67d3\u6e90\u7801&#xff09;&#xff1a;<\/li>\n<p><span class=\"token function\">mkdir<\/span> build <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token builtin class-name\">cd<\/span> build<\/p>\n<li>\u751f\u6210Makefile&#xff1a;<\/li>\n<p>cmake <span class=\"token punctuation\">..<\/span><\/p>\n<li>\u7f16\u8bd1\u9879\u76ee&#xff1a;<\/li>\n<p><span class=\"token function\">make<\/span><\/p>\n<li>\u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6&#xff1a;<\/li>\n<p>.\/calc_demo<\/p>\n<h4>5. CMake\u8fdb\u9636&#xff1a;\u591a\u76ee\u5f55\u9879\u76ee\u652f\u6301<\/h4>\n<p>\u5b9e\u9645\u9879\u76ee\u90fd\u662f\u591a\u76ee\u5f55\u7ed3\u6784&#xff0c;CMake\u5904\u7406\u8d77\u6765\u975e\u5e38\u7b80\u5355\u3002\u4f8b\u5982\u9879\u76ee\u7ed3\u6784&#xff1a;<\/p>\n<p>CalcProject\/<br \/>\n\u251c\u2500\u2500 include\/<br \/>\n\u2502   \u2514\u2500\u2500 calc.h<br \/>\n\u251c\u2500\u2500 src\/<br \/>\n\u2502   \u251c\u2500\u2500 calc.cpp<br \/>\n\u2502   \u2514\u2500\u2500 main.cpp<br \/>\n\u2514\u2500\u2500 CMakeLists.txt<\/p>\n<p>\u4fee\u6539 CMakeLists.txt &#xff1a;<\/p>\n<p>cmake_minimum_required(VERSION 3.10)<br \/>\nproject(CalcDemo)<br \/>\nset(CMAKE_CXX_STANDARD 11)<br \/>\n# \u6dfb\u52a0\u5934\u6587\u4ef6\u8def\u5f84<br \/>\ninclude_directories(include)<br \/>\n# \u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6<br \/>\nadd_executable(calc_demo src\/main.cpp src\/calc.cpp)<\/p>\n<p>\u65e0\u9700\u4fee\u6539\u4efb\u4f55\u4ee3\u7801&#xff0c;\u4e00\u952e\u8de8\u5e73\u53f0\u7f16\u8bd1&#xff0c;\u8fd9\u5c31\u662fCMake\u7684\u5f3a\u5927\u4e4b\u5904\u3002<\/p>\n<h3>\u56db\u3001\u603b\u7ed3&#xff1a;<\/h3>\n<li>C&#043;&#043;\u591a\u6587\u4ef6\u7f16\u7a0b\u662f\u57fa\u7840&#xff1a;\u901a\u8fc7\u58f0\u660e\u4e0e\u5b9e\u73b0\u5206\u79bb\u5b9e\u73b0\u6a21\u5757\u5316&#xff0c;\u662f\u5927\u578b\u9879\u76ee\u7684\u524d\u63d0&#xff1b;<\/li>\n<li>Makefile\u662f\u81ea\u52a8\u5316\u5de5\u5177&#xff1a;\u89e3\u51b3\u624b\u52a8\u7f16\u8bd1\u7684\u7e41\u7410&#xff0c;\u5b9e\u73b0\u589e\u91cf\u7f16\u8bd1&#xff0c;\u4f46\u8de8\u5e73\u53f0\u5dee\u3001\u8bed\u6cd5\u590d\u6742&#xff1b;<\/li>\n<li>CMake\u662f\u6784\u5efa\u751f\u6210\u5668&#xff1a;\u5c4f\u853d\u5e73\u53f0\u5dee\u5f02&#xff0c;\u81ea\u52a8\u751f\u6210Makefile\/IDE\u5de5\u7a0b&#xff0c;\u662f\u73b0\u4ee3C&#043;&#043;\u9879\u76ee\u7684\u6807\u51c6\u6784\u5efa\u5de5\u5177\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u5728C\u5927\u578b\u9879\u76ee\u5f00\u53d1\u4e2d&#xff0c;\u591a\u6587\u4ef6\u7f16\u7a0b\u662f\u6a21\u5757\u5316\u7684\u57fa\u7840&#xff0c;\u5bf9\u4e8e\u9879\u76ee\u7684\u53ef\u7ef4\u62a4\u6027\u81f3\u5173\u91cd\u8981\u3002\u800cMakefile\u4e0eCMake\u5219\u662f\u89e3\u51b3\u9879\u76ee\u7f16\u8bd1\u3001\u94fe\u63a5\u3001\u7ba1\u7406\u96be\u9898\u7684\u6838\u5fc3\u5de5\u5177\u3002\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u56f0\u60d1&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u62c6\u5206\u6587\u4ef6&#xff1f;Makefile\u600e\u4e48\u5199&#xff1f;CMake\u4e0eMakefile\u7684\u5173\u7cfb\u548c\u533a\u522b\u662f\u4ec0\u4e48&#xff1f;\u672c\u6587\u5c06\u4ece\u539f\u7406\u5230\u5b9e\u6218&#xff0c;\u8bb2\u89e3\u8fd9\u4e09\u5927\u6838\u5fc3\u77e5\u8bc6\u70b9&#xff0c;\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1C\u9879\u76ee\u7684\u6784\u5efa\u903b\u8f91\u3002<br \/>\n\u4e00\u3001C\u591a\u6587\u4ef6\u7f16\u7a0b&#xff1a;<br \/>\n1.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55],"topic":[],"class_list":["post-79336","post","type-post","status-publish","format-standard","hentry","category-server","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \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\/79336.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5728C\u5927\u578b\u9879\u76ee\u5f00\u53d1\u4e2d&#xff0c;\u591a\u6587\u4ef6\u7f16\u7a0b\u662f\u6a21\u5757\u5316\u7684\u57fa\u7840&#xff0c;\u5bf9\u4e8e\u9879\u76ee\u7684\u53ef\u7ef4\u62a4\u6027\u81f3\u5173\u91cd\u8981\u3002\u800cMakefile\u4e0eCMake\u5219\u662f\u89e3\u51b3\u9879\u76ee\u7f16\u8bd1\u3001\u94fe\u63a5\u3001\u7ba1\u7406\u96be\u9898\u7684\u6838\u5fc3\u5de5\u5177\u3002\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u56f0\u60d1&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u62c6\u5206\u6587\u4ef6&#xff1f;Makefile\u600e\u4e48\u5199&#xff1f;CMake\u4e0eMakefile\u7684\u5173\u7cfb\u548c\u533a\u522b\u662f\u4ec0\u4e48&#xff1f;\u672c\u6587\u5c06\u4ece\u539f\u7406\u5230\u5b9e\u6218&#xff0c;\u8bb2\u89e3\u8fd9\u4e09\u5927\u6838\u5fc3\u77e5\u8bc6\u70b9&#xff0c;\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1C\u9879\u76ee\u7684\u6784\u5efa\u903b\u8f91\u3002 \u4e00\u3001C\u591a\u6587\u4ef6\u7f16\u7a0b&#xff1a; 1.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/79336.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-01T12:57:30+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79336.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/79336.html\",\"name\":\"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-01T12:57:30+00:00\",\"dateModified\":\"2026-03-01T12:57:30+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/79336.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/79336.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/79336.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218\"}]},{\"@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":"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \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\/79336.html","og_locale":"zh_CN","og_type":"article","og_title":"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5728C\u5927\u578b\u9879\u76ee\u5f00\u53d1\u4e2d&#xff0c;\u591a\u6587\u4ef6\u7f16\u7a0b\u662f\u6a21\u5757\u5316\u7684\u57fa\u7840&#xff0c;\u5bf9\u4e8e\u9879\u76ee\u7684\u53ef\u7ef4\u62a4\u6027\u81f3\u5173\u91cd\u8981\u3002\u800cMakefile\u4e0eCMake\u5219\u662f\u89e3\u51b3\u9879\u76ee\u7f16\u8bd1\u3001\u94fe\u63a5\u3001\u7ba1\u7406\u96be\u9898\u7684\u6838\u5fc3\u5de5\u5177\u3002\u5f88\u591a\u521d\u5b66\u8005\u4f1a\u56f0\u60d1&#xff1a;\u4e3a\u4ec0\u4e48\u8981\u62c6\u5206\u6587\u4ef6&#xff1f;Makefile\u600e\u4e48\u5199&#xff1f;CMake\u4e0eMakefile\u7684\u5173\u7cfb\u548c\u533a\u522b\u662f\u4ec0\u4e48&#xff1f;\u672c\u6587\u5c06\u4ece\u539f\u7406\u5230\u5b9e\u6218&#xff0c;\u8bb2\u89e3\u8fd9\u4e09\u5927\u6838\u5fc3\u77e5\u8bc6\u70b9&#xff0c;\u5e2e\u4f60\u5f7b\u5e95\u638c\u63e1C\u9879\u76ee\u7684\u6784\u5efa\u903b\u8f91\u3002 \u4e00\u3001C\u591a\u6587\u4ef6\u7f16\u7a0b&#xff1a; 1.","og_url":"https:\/\/www.wsisp.com\/helps\/79336.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-01T12:57:30+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/79336.html","url":"https:\/\/www.wsisp.com\/helps\/79336.html","name":"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-01T12:57:30+00:00","dateModified":"2026-03-01T12:57:30+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/79336.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/79336.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/79336.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C++\u591a\u6587\u4ef6\u7f16\u7a0b\u3001Makefile\u4e0eCMake\u5168\u653b\u7565\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218"}]},{"@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\/79336","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=79336"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/79336\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=79336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=79336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=79336"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=79336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}