{"id":290,"date":"2021-06-18T00:26:25","date_gmt":"2021-06-17T16:26:25","guid":{"rendered":"https:\/\/www.iotot.com\/?p=290"},"modified":"2022-05-22T11:23:47","modified_gmt":"2022-05-22T03:23:47","slug":"%e5%9c%a8linux%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%ba%afc%e7%bc%96%e5%86%99%e5%a4%9a%e6%96%87%e4%bb%b6%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/blog.iotot.com\/?p=290","title":{"rendered":"\u5728Linux\u4e2d\u4f7f\u7528\u7eafC\u7f16\u5199\u591a\u6587\u4ef6\u7a0b\u5e8f"},"content":{"rendered":"\n<h1>1.\u5173\u4e8e\u7f16\u8bd1\u548c\u94fe\u63a5<\/h1>\n\n\n\n<p>&nbsp; &nbsp; \u4e00\u822c\u6765\u8bf4\uff0c\u65e0\u8bba\u662fC\u3001C++\uff0c\u9996\u5148\u8981\u628a\u6e90\u6587\u4ef6\u7f16\u8bd1\u6210\u4e2d\u95f4\u4ee3\u7801\u6587\u4ef6\uff0c\u5728Windows\u4e0b\u4e5f\u5c31\u662f.obj\u6587\u4ef6\uff0cUNIX\u4e0b\u662f.o\u6587\u4ef6\uff0c\u5373Object File\uff0c\u8fd9\u4e2a\u52a8\u4f5c\u53eb\u505a\u7f16\u8bd1\uff08compile\uff09\u3002\u7136\u540e\u518d\u628a\u5927\u91cf\u7684Object File\u5408\u6210\u6267\u884c\u6587\u4ef6\uff0c\u8fd9\u4e2a\u52a8\u4f5c\u53eb\u4f5c\u94fe\u63a5\uff08link\uff09\u3002&nbsp; &nbsp;<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp;\u4e5f\u5c31\u662f\u6e90\u6587\u4ef6\uff08.c \u6587\u4ef6\u6216\u8005.cpp\u6587\u4ef6\uff09\u9996\u5148\u4f1a\u751f\u6210\u4e2d\u95f4\u76ee\u6807\u6587\u4ef6\uff0c\u518d\u7531\u4e2d\u95f4\u76ee\u6807\u6587\u4ef6\u751f\u6210\u6267\u884c\u6587\u4ef6\u3002\u5728\u7f16\u8bd1\u65f6\uff0c\u7f16\u8bd1\u5668\u53ea\u68c0\u6d4b\u7a0b\u5e8f\u8bed\u6cd5\uff0c\u548c\u51fd\u6570\u3001\u53d8\u91cf\u662f\u5426\u88ab\u58f0\u660e\u3002\u5982\u679c\u51fd\u6570\u672a\u88ab\u58f0\u660e\uff0c\u7f16\u8bd1\u5668\u4f1a\u7ed9\u51fa\u4e00\u4e2a\u8b66\u544a\uff0c\u4f46\u53ef\u4ee5\u751f\u6210Object File\u3002\u800c\u5728\u94fe\u63a5\u7a0b\u5e8f\u65f6\uff0c\u94fe\u63a5\u5668\u4f1a\u5728\u6240\u6709\u7684Object File\u4e2d\u627e\u5bfb\u51fd\u6570\u7684\u5b9e\u73b0\uff0c\u5982\u679c\u627e\u4e0d\u5230\uff0c\u90a3\u5230\u5c31\u4f1a\u62a5\u94fe\u63a5\u9519\u8bef\u7801\uff08Linker Error\uff09\u3002<br><\/p>\n\n\n\n<h1>2.\u4f7f\u7528\u547d\u4ee4\u7f16\u8bd1\u94fe\u63a5<\/h1>\n\n\n\n<p>\u3000\u3000\u5982\u679c\u4f7f\u7528\u547d\u4ee4\u7f16\u8bd1\uff0c\u8fc7\u7a0b\u6bd4\u8f83\u9ebb\u70e6\u3002\u5047\u5982\u6211\u6709\u4e09\u4e2a.h\u7684\u5934\u6587\u4ef6\u548c\u56db\u4e2a.c\u7684\u4ee3\u7801\u6587\u4ef6\u3002\u9996\u5148\u5c06\u8fd9\u4e03\u4e2a\u6587\u4ef6\u653e\u5230\u4e00\u4e2a\u6587\u4ef6\u5939\u91cc\uff08\u8fd9\u91cc\u53ea\u4ecb\u7ecd\u7b80\u5355\u5e94\u7528\uff0c\u6240\u4ee5\u653e\u5728\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u4ee5\u540e\u6162\u6162\u586b\u5751\uff09\u5982\u4e0b\u56fe\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"659\" height=\"348\" src=\"https:\/\/www.iotot.com\/wp-content\/uploads\/2021\/06\/image-17.png\" alt=\"\" class=\"wp-image-291\" srcset=\"https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-17.png 659w, https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-17-300x158.png 300w, https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-17-624x330.png 624w\" sizes=\"(max-width: 659px) 100vw, 659px\" \/><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6253\u5f00\u7ec8\u7aef\uff0c\u5e76\u8f6c\u5230\u8fd9\u4e2a\u6587\u4ef6\u5939\u3002\u7136\u540e\u5728\u7ec8\u7aef\u8f93\u5165<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$CC -c main.c\r\n$CC -c AAA.c\r\n$CC -c BBB.c\r\n$CC -c CCC.c<\/pre>\n\n\n\n<p>\u8fd9\u6837\u5c31\u628a\u56db\u4e2a\u6587\u4ef6\u7f16\u8bd1\u5b8c\u6210\uff0c\u67e5\u770b\u6587\u4ef6\u4f1a\u51fa\u73b0\u56db\u4e2a.o\u6587\u4ef6\uff08\u4e0b\u56fe\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"700\" height=\"346\" src=\"https:\/\/www.iotot.com\/wp-content\/uploads\/2021\/06\/image-18.png\" alt=\"\" class=\"wp-image-292\" srcset=\"https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-18.png 700w, https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-18-300x148.png 300w, https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-18-624x308.png 624w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p>\u63a5\u4e0b\u6765\u94fe\u63a5\u5373\u53ef\u3002\u5728\u7ec8\u7aef\u8f93\u5165<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">$CC  main.o AAA.o BBB.o CCC.o -o main<\/pre>\n\n\n\n<p>\u5c31\u53ef\u4ee5\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6 main<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"688\" height=\"341\" src=\"https:\/\/www.iotot.com\/wp-content\/uploads\/2021\/06\/image-19.png\" alt=\"\" class=\"wp-image-293\" srcset=\"https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-19.png 688w, https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-19-300x149.png 300w, https:\/\/blog.iotot.com\/wp-content\/uploads\/2021\/06\/image-19-624x309.png 624w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u6837\u6267\u884c .\/main\u5373\u53ef\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5e38\u7528makefile<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">objects = main.o AAA.o BBB.o CCC.o \r\ncc = gcc\r\nedit : $(objects)\r\n    cc -o edit $(objects)\r\n\r\nmain.o : main.c  \r\nAAA.o : AAA.h\r\nBBB.o : BBB.h\r\nCCC.o : CCC.h\r\n\r\n.PHONY : clean\r\nclean :\r\n    rm edit main.o AAA.o BBB.o CCC.o<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5173\u4e8e\u7f16\u8bd1\u548c\u94fe\u63a5 &nbsp; &nbsp; \u4e00\u822c\u6765\u8bf4\uff0c\u65e0\u8bba\u662fC\u3001C++\uff0c\u9996\u5148\u8981\u628a\u6e90\u6587\u4ef6\u7f16\u8bd1\u6210\u4e2d\u95f4\u4ee3\u7801\u6587\u4ef6\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":291,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[53,37],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts\/290"}],"collection":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=290"}],"version-history":[{"count":3,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts\/290\/revisions"}],"predecessor-version":[{"id":296,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/posts\/290\/revisions\/296"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=\/wp\/v2\/media\/291"}],"wp:attachment":[{"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iotot.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}