{"id":94248,"date":"2026-08-14T02:40:44","date_gmt":"2026-08-13T18:40:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/94248.html"},"modified":"2026-08-14T02:40:44","modified_gmt":"2026-08-13T18:40:44","slug":"%e3%80%90linux-%e9%a9%b1%e5%8a%a8%e5%b0%8f%e7%99%bd%e6%95%99%e7%a8%8b%e3%80%91%e4%ba%8c%e3%80%81%e9%a9%b1%e5%8a%a8makefile%e7%bc%96%e5%86%99-%e6%a8%a1%e5%9d%97%e6%93%8d%e4%bd%9c%e5%85%a8%e5%a5%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/94248.html","title":{"rendered":"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd"},"content":{"rendered":"<p>\u63a5\u4e0a\u4e00\u7bc7&#xff1a;\u4ece\u96f6\u770b\u61c2\u9a71\u52a8\u6846\u67b6 &#043; \u8bbe\u5907\u5206\u7c7b &#043; \u6700\u7b80\u6a21\u677f<br \/>\n\u4e0a\u4e00\u7bc7\u6211\u4eec\u62ff\u5230\u4e86\u6700\u7b80\u5185\u6838\u9a71\u52a8 .c \u6e90\u7801&#xff0c;\u4f46\u662f\u5185\u6838\u9a71\u52a8\u4e0d\u80fd\u7528gcc\u76f4\u63a5\u7f16\u8bd1&#xff0c;\u5fc5\u987b\u501f\u52a9\u5185\u6838\u6e90\u7801\u6811\u8fdb\u884c\u7f16\u8bd1\u3002\u672c\u7bc7\u8bb2\u89e3\u9a71\u52a8\u4e13\u7528Makefile\u8bed\u6cd5\u3001\u7f16\u8bd1\u6b65\u9aa4\u3001insmod\/rmmod\/lsmod\/modinfo\/modprobe\u5168\u5957\u547d\u4ee4&#xff0c;\u65b0\u624b\u7167\u7740\u6572\u5373\u53ef\u8dd1\u901a\u5b9e\u9a8c\u3002<\/p>\n<h3>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9a71\u52a8\u4e0d\u80fd\u76f4\u63a5 gcc xxx.c&#xff1f;<\/h3>\n<p>\u666e\u901a\u5e94\u7528\u7a0b\u5e8f&#xff1a;\u94fe\u63a5glibc\u7528\u6237\u6001\u5e93&#xff0c;gcc\u76f4\u63a5\u7f16\u8bd1\u3002<br \/>\n\u5185\u6838\u9a71\u52a8&#xff1a;\u8fd0\u884c\u5728\u5185\u6838\u7a7a\u95f4&#xff0c;\u8981\u8c03\u7528\u5185\u6838\u5bfc\u51fa\u7684\u51fd\u6570\u3001\u5934\u6587\u4ef6&#xff0c;\u5fc5\u987b\u4f7f\u7528\u5185\u6838\u672c\u8eab\u7684\u7f16\u8bd1\u4f53\u7cfb&#xff0c;\u4e0d\u80fd\u94fe\u63a5\u7528\u6237\u6001C\u5e93\u3002<\/p>\n<p>\u91cd\u70b9&#xff1a;\u7f16\u8bd1\u9a71\u52a8\u5fc5\u987b\u8981\u6709\u5bf9\u5e94\u7248\u672c\u7684\u5185\u6838\u6e90\u7801\/\u5185\u6838\u5934\u6587\u4ef6&#xff0c;\u5185\u6838\u7248\u672c\u5fc5\u987b\u548c\u8fd0\u884c\u5f00\u53d1\u677f\/\u865a\u62df\u673a\u7684\u5185\u6838\u7248\u672c\u4e25\u683c\u5339\u914d&#xff0c;\u5426\u5219\u4f1a\u51fa\u73b0\u7248\u672c\u9b54\u6570\u6821\u9a8c\u5931\u8d25&#xff0c;\u6a21\u5757\u52a0\u8f7d\u62a5\u9519\u3002<\/p>\n<h3>\u4e8c\u3001\u9a71\u52a8\u4e13\u7528Makefile\u5b8c\u6574\u6a21\u677f<\/h3>\n<p>\u65b0\u5efa\u6587\u4ef6\u540d\u5b57\u5c31\u53eb Makefile&#xff0c;\u6ce8\u610f\u5927\u5c0f\u5199M\u5927\u5199&#xff0c;\u4e0d\u8981\u540e\u7f00&#xff0c;\u548c\u9a71\u52a8c\u6587\u4ef6\u653e\u5728\u540c\u4e00\u4e2a\u76ee\u5f55\u3002<br \/>\n\u5047\u8bbe\u9a71\u52a8\u6e90\u7801\u6587\u4ef6\u540d\u53eb mydrv.c<\/p>\n<p># \u5224\u65ad\u662f\u5426\u4f20\u5165KERNELDIR&#xff0c;\u6ca1\u6709\u5c31\u4f7f\u7528\u672c\u673a\u5185\u6838\u8def\u5f84<br \/>\nKERNELDIR ?&#061; \/lib\/modules\/$(shell uname -r)\/build<br \/>\n# \u5f53\u524d\u6e90\u7801\u6240\u5728\u76ee\u5f55<br \/>\nPWD :&#061; $(shell pwd)<\/p>\n<p># \u8981\u7f16\u8bd1\u751f\u6210\u7684\u6a21\u5757\u540d&#xff0c;\u5bf9\u5e94 mydrv.c \u2192 mydrv.ko<br \/>\nobj-m &#043;&#061; mydrv.o<\/p>\n<p># make\u7684\u9ed8\u8ba4\u76ee\u6807<br \/>\nall:<br \/>\nmake -C $(KERNELDIR) M&#061;$(PWD) modules<\/p>\n<p># make clean \u6e05\u7406\u7f16\u8bd1\u4ea7\u7269<br \/>\nclean:<br \/>\nmake -C $(KERNELDIR) M&#061;$(PWD) clean<\/p>\n<h4>Makefile\u9010\u884c\u5c0f\u767d\u8bb2\u89e3<\/h4>\n<li>KERNELDIR ?&#061; \/lib\/modules\/$(shell uname -r)\/build<\/li>\n<ul>\n<li>?&#061;&#xff1a;\u5982\u679c\u53d8\u91cf\u6ca1\u6709\u88ab\u5916\u90e8\u8d4b\u503c&#xff0c;\u624d\u8d4b\u503c&#xff1b;\u4ea4\u53c9\u7f16\u8bd1\u7684\u65f6\u5019\u53ef\u4ee5\u5916\u90e8\u4f20\u5165\u6307\u5b9a\u5185\u6838\u8def\u5f84\u8986\u76d6\u3002<\/li>\n<li>$(shell uname -r)&#xff1a;shell\u547d\u4ee4&#xff0c;\u83b7\u53d6\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u5185\u6838\u7248\u672c\u53f7\u3002<\/li>\n<li>\/lib\/modules\/xxx\/build&#xff1a;Ubuntu\u865a\u62df\u673a\u672c\u5730\u7f16\u8bd1&#xff0c;\u6307\u5411\u5185\u6838\u5934\u6587\u4ef6\u8f6f\u94fe\u63a5&#xff1b;\u505a\u5f00\u53d1\u677f\u4ea4\u53c9\u7f16\u8bd1\u65f6\u8fd9\u91cc\u6539\u6210\u5f00\u53d1\u677f\u5185\u6838\u6e90\u7801\u7edd\u5bf9\u8def\u5f84\u3002<\/li>\n<\/ul>\n<li>\n<p>PWD :&#061; $(shell pwd)<br \/>\n:&#061; \u7acb\u5373\u8d4b\u503c&#xff0c;\u83b7\u53d6\u5f53\u524d\u6e90\u7801\u6587\u4ef6\u5939\u8def\u5f84\u3002<\/p>\n<\/li>\n<li>\n<p>obj-m &#043;&#061; mydrv.o<\/p>\n<\/li>\n<p>\u6838\u5fc3&#xff01;\u9a71\u52a8Makefile\u6700\u5173\u952e\u4e00\u884c<br \/>\nobj\u2011m&#xff1a;\u8868\u793a\u628a\u8fd9\u4e2a\u6587\u4ef6\u7f16\u8bd1\u6210\u53ef\u52a8\u6001\u52a0\u8f7d\u7684\u5185\u6838\u6a21\u5757&#xff08;.ko&#xff09;<br \/>\nobj\u2011y&#xff1a;\u7f16\u8bd1\u8fdb\u5185\u6838\u955c\u50cfzImage&#xff0c;\u5f00\u673a\u5c31\u5185\u7f6e&#xff0c;\u4e0d\u80fdrmmod\u5378\u8f7d\u3002<br \/>\nmydrv.o \u5bf9\u5e94\u6e90\u7801 mydrv.c&#xff0c;\u4f1a\u81ea\u52a8\u751f\u6210 mydrv.ko&#xff0c;\u4e0d\u8981\u5199ko&#xff01;<\/p>\n<li>make -C $(KERNELDIR) M&#061;$(PWD) modules<\/li>\n<ul>\n<li>-C $(KERNELDIR)&#xff1a;\u5207\u6362\u5de5\u4f5c\u76ee\u5f55\u5230\u5185\u6838\u6e90\u7801\u76ee\u5f55&#xff0c;\u6267\u884c\u5185\u6838\u9876\u5c42Makefile<\/li>\n<li>M&#061;$(PWD)&#xff1a;\u544a\u8bc9\u5185\u6838\u7f16\u8bd1\u7cfb\u7edf&#xff0c;\u5916\u90e8\u6a21\u5757\u6e90\u7801\u5728\u5f53\u524dPWD\u76ee\u5f55<\/li>\n<li>modules&#xff1a;\u5185\u6838Makefile\u76ee\u6807&#xff0c;\u4e13\u95e8\u7f16\u8bd1\u5916\u90e8\u5185\u6838\u6a21\u5757<\/li>\n<\/ul>\n<li>clean&#xff1a;\u6e05\u7406\u7f16\u8bd1\u51fa\u6765\u7684.ko\u3001.o\u3001.mod.c\u7b49\u4e2d\u95f4\u6587\u4ef6\u3002<\/li>\n<h4>\u2705\u7f16\u8bd1\u64cd\u4f5c<\/h4>\n<p>\u7ec8\u7aef\u8fdb\u5165\u6e90\u7801\u76ee\u5f55\u6267\u884c<\/p>\n<p><span class=\"token function\">make<\/span><\/p>\n<p>\u7f16\u8bd1\u6210\u529f\u540e\u76ee\u5f55\u751f\u6210&#xff1a;mydrv.ko \u5c31\u662f\u6211\u4eec\u7684\u5185\u6838\u6a21\u5757\u6587\u4ef6\u3002<\/p>\n<p>\u26a0\ufe0f\u4ea4\u53c9\u7f16\u8bd1\u5c0f\u63d0\u793a&#xff08;\u5f00\u53d1\u677f\u573a\u666f&#xff09;<\/p>\n<p><span class=\"token comment\"># \u793a\u4f8b&#xff0c;\u4f20\u5165\u4ea4\u53c9\u7f16\u8bd1\u5668&#043;\u5f00\u53d1\u677f\u5185\u6838\u8def\u5f84<\/span><br \/>\n<span class=\"token function\">make<\/span> <span class=\"token assign-left variable\">KERNELDIR<\/span><span class=\"token operator\">&#061;<\/span>\/home\/xxx\/linux-5.4 <span class=\"token assign-left variable\">ARCH<\/span><span class=\"token operator\">&#061;<\/span>arm <span class=\"token assign-left variable\">CROSS_COMPILE<\/span><span class=\"token operator\">&#061;<\/span>arm-linux-gnueabihf-<\/p>\n<p>\u7f16\u8bd1\u4ea7\u7269\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>*.ko&#xff1a;\u771f\u6b63\u5185\u6838\u6a21\u5757&#xff0c;\u62f7\u8d1d\u5230\u5f00\u53d1\u677f\u4f7f\u7528<\/li>\n<li>*.mod.c&#xff1a;\u5185\u6838\u81ea\u52a8\u751f\u6210\u4e2d\u95f4\u6587\u4ef6<\/li>\n<li>*.o&#xff1a;\u7f16\u8bd1\u76ee\u6807\u6587\u4ef6<\/li>\n<li>modules.order\u3001Module.symvers&#xff1a;\u6a21\u5757\u7b26\u53f7\u8868&#xff0c;\u591a\u4e2a\u6a21\u5757\u4f9d\u8d56\u65f6\u9700\u8981<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u5185\u6838\u6a21\u5757\u5168\u5957\u64cd\u4f5c\u547d\u4ee4&#xff08;\u5fc5\u8003\u5b9e\u64cd&#xff09;<\/h3>\n<p>\u6ce8\u610f&#xff1a;\u5927\u90e8\u5206\u6a21\u5757\u52a0\u8f7d\u5378\u8f7d\u64cd\u4f5c\u9700\u8981root\u6743\u9650&#xff0c;Ubuntu\u52a0sudo&#xff1b;\u5f00\u53d1\u677f\u4e00\u822c\u9ed8\u8ba4root\u3002<\/p>\n<h4>1. lsmod \u5217\u51fa\u5f53\u524d\u5df2\u7ecf\u52a0\u8f7d\u7684\u5185\u6838\u6a21\u5757<\/h4>\n<p>lsmod<\/p>\n<p>\u4f5c\u7528&#xff1a;\u67e5\u770b\u7cfb\u7edf\u54ea\u4e9bko\u5df2\u7ecf\u8f7d\u5165\u5185\u6838&#xff0c;\u7b2c\u4e00\u5217\u6a21\u5757\u540d&#xff0c;\u7b2c\u4e8c\u5217\u5360\u7528\u5185\u5b58&#xff0c;\u7b2c\u4e09\u5217\u88ab\u54ea\u4e9b\u5176\u4ed6\u6a21\u5757\u4f9d\u8d56\u3002<\/p>\n<h4>2. insmod \u624b\u52a8\u52a0\u8f7d\u6a21\u5757<\/h4>\n<p><span class=\"token function\">sudo<\/span> insmod mydrv.ko<\/p>\n<p>\u76f4\u63a5\u6307\u5b9ako\u6587\u4ef6\u8def\u5f84\u52a0\u8f7d\u3002<\/p>\n<p>\u7f3a\u70b9&#xff1a;\u4e0d\u4f1a\u81ea\u52a8\u89e3\u51b3\u6a21\u5757\u4f9d\u8d56&#xff0c;\u5982\u679c\u672c\u6a21\u5757\u4f9d\u8d56\u522b\u7684\u6a21\u5757&#xff0c;insmod\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u67e5\u770b\u6253\u5370\u8f93\u51fa&#xff0c;\u9a71\u52a8\u91cc\u9762printk\u6253\u5370&#xff0c;\u7528dmesg\u770b&#xff1a;<\/p>\n<p><span class=\"token function\">dmesg<\/span><br \/>\n<span class=\"token comment\"># \u5b9e\u65f6\u8ffd\u8e2a\u6253\u5370<\/span><br \/>\n<span class=\"token function\">dmesg<\/span> <span class=\"token parameter variable\">-w<\/span><\/p>\n<p>printk\u4e0d\u4f1a\u76f4\u63a5\u8f93\u51fa\u7ec8\u7aef&#xff0c;\u5b58\u5728\u5185\u6838\u73af\u5f62\u7f13\u51b2\u533a&#xff0c;\u8981\u7528dmesg\u67e5\u770b\u65e5\u5fd7\u3002<\/p>\n<h4>3. modprobe \u667a\u80fd\u52a0\u8f7d\u6a21\u5757<\/h4>\n<p><span class=\"token function\">sudo<\/span> modprobe mydrv<\/p>\n<ul>\n<li>\u4e0d\u9700\u8981\u5199.ko\u540e\u7f00&#xff0c;\u53ea\u5199\u6a21\u5757\u540d\u5b57<\/li>\n<li>\u4f1a\u81ea\u52a8\u67e5\u627e\u6a21\u5757\u8def\u5f84&#xff0c;\u81ea\u52a8\u52a0\u8f7d\u4f9d\u8d56\u7684\u5176\u4ed6\u6a21\u5757<\/li>\n<\/ul>\n<p>\u524d\u63d0\u6761\u4ef6&#xff1a;ko\u9700\u8981\u62f7\u8d1d\u5230\u7cfb\u7edf\u6a21\u5757\u76ee\u5f55 \/lib\/modules\/$(uname -r)\/&#xff0c;\u6267\u884cdepmod\u66f4\u65b0\u6a21\u5757\u4f9d\u8d56\u6570\u636e\u5e93&#xff0c;modprobe\u624d\u80fd\u8bc6\u522b\u3002<br \/>\n\u7b80\u5355\u7406\u89e3&#xff1a;insmod\u7b80\u5355\u7c97\u66b4&#xff1b;modprobe\u667a\u80fd\u5904\u7406\u4f9d\u8d56\u3002<\/p>\n<h4>4. rmmod \u5378\u8f7d\u6a21\u5757<\/h4>\n<p><span class=\"token function\">sudo<\/span> rmmod mydrv<\/p>\n<p>\u53ea\u5199\u6a21\u5757\u540d\u5b57&#xff0c;\u4e0d\u8981\u52a0.ko\u540e\u7f00&#xff0c;\u6267\u884c\u9a71\u52a8\u7684__exit\u9000\u51fa\u51fd\u6570\u3002<\/p>\n<p>\u6ce8\u610f&#xff1a;\u6a21\u5757\u6b63\u5728\u88ab\u7a0b\u5e8f\u5360\u7528\u7684\u65f6\u5019rmmod\u4f1a\u5931\u8d25\u3002<\/p>\n<h4>5. modinfo \u67e5\u770b\u6a21\u5757\u4fe1\u606f<\/h4>\n<p>modinfo mydrv.ko<\/p>\n<p>\u8bfb\u53d6ko\u5185\u90e8\u4fe1\u606f&#xff1a;\u4f5c\u8005\u3001\u534f\u8bae\u3001\u63cf\u8ff0\u3001\u6a21\u5757\u53c2\u6570\u3001\u7248\u672c&#xff0c;\u5c31\u662f\u6211\u4eec\u4ee3\u7801\u91ccMODULE_LICENSE\u3001MODULE_AUTHOR\u8fd9\u4e9b\u5b8f\u751f\u6210\u7684\u4fe1\u606f\u3002<\/p>\n<h4>6. depmod \u66f4\u65b0\u6a21\u5757\u4f9d\u8d56\u6570\u636e\u5e93&#xff08;\u914d\u5408modprobe\u4f7f\u7528&#xff09;<\/h4>\n<p><span class=\"token function\">sudo<\/span> depmod<\/p>\n<p>\u628a\u65b0\u62f7\u8d1d\u7684ko\u6ce8\u518c\u8fdb\u7cfb\u7edf\u6a21\u5757\u5217\u8868&#xff0c;modprobe\u624d\u80fd\u627e\u5230\u8fd9\u4e2a\u6a21\u5757\u3002<\/p>\n<h4>&#x1f4dd;\u5b8c\u6574\u5b9e\u64cd\u6d41\u7a0b\u793a\u4f8b&#xff08;\u865a\u62df\u673a&#xff09;<\/h4>\n<p><span class=\"token comment\">#1 \u7f16\u8bd1<\/span><br \/>\n<span class=\"token function\">make<\/span><br \/>\n<span class=\"token comment\">#2 \u52a0\u8f7d\u6a21\u5757<\/span><br \/>\n<span class=\"token function\">sudo<\/span> insmod mydrv.ko<br \/>\n<span class=\"token comment\">#3 \u770b\u5185\u6838\u6253\u5370<\/span><br \/>\n<span class=\"token function\">dmesg<\/span><br \/>\n<span class=\"token comment\">#4 \u67e5\u770b\u5df2\u52a0\u8f7d\u6a21\u5757<\/span><br \/>\nlsmod<br \/>\n<span class=\"token comment\">#5 \u67e5\u770b\u6a21\u5757\u4fe1\u606f<\/span><br \/>\nmodinfo mydrv.ko<br \/>\n<span class=\"token comment\">#6 \u5378\u8f7d\u6a21\u5757<\/span><br \/>\n<span class=\"token function\">sudo<\/span> rmmod mydrv<br \/>\n<span class=\"token comment\">#7 \u6e05\u7406\u7f16\u8bd1\u4ea7\u7269<\/span><br \/>\n<span class=\"token function\">make<\/span> clean<\/p>\n<h3>\u56db\u3001\u5e38\u89c1\u8e29\u5751\u70b9&#xff08;\u5c0f\u767d\u9ad8\u9891\u62a5\u9519&#xff09;<\/h3>\n<li>\u7248\u672c\u9b54\u6570\u4e0d\u5339\u914d<br \/>\nversion magic does not match<\/li>\n<p>\u539f\u56e0&#xff1a;\u7f16\u8bd1\u7528\u7684\u5185\u6838\u5934\u6587\u4ef6\u7248\u672c \u548c \u8fd0\u884c\u5185\u6838\u7248\u672c\u4e0d\u4e00\u81f4\u3002\u865a\u62df\u673a\u4e0d\u8981\u968f\u4fbf\u5347\u7ea7\u5185\u6838&#xff1b;\u5f00\u53d1\u677f\u7f16\u8bd1\u9a71\u52a8\u5fc5\u987b\u4f7f\u7528\u548c\u70e7\u5f55\u5185\u6838\u4e00\u6a21\u4e00\u6837\u7684\u6e90\u7801\u3002<\/p>\n<li>MODULE_LICENSE(&#034;GPL&#034;)\u5fd8\u8bb0\u5199<\/li>\n<p>dmesg\u91cc\u9762\u51fa\u73b0tainted kernel\u5185\u6838\u6c61\u67d3\u8b66\u544a&#xff0c;\u90e8\u5206\u5185\u6838\u51fd\u6570\u8c03\u7528\u76f4\u63a5\u5931\u8d25\u3002\u5fc5\u987b\u5199GPL\u3002<\/p>\n<li>make\u62a5\u9519\u627e\u4e0d\u5230\u5185\u6838\u5934\u6587\u4ef6<br \/>\nUbuntu\u5b89\u88c5\u5185\u6838\u5934\u6587\u4ef6&#xff1a;<\/li>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> linux-headers-<span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">uname<\/span> <span class=\"token parameter variable\">-r<\/span><span class=\"token variable\">)<\/span><\/span><\/p>\n<li>rmmod\u63d0\u793amodule is in use<\/li>\n<p>\u6a21\u5757\u6b63\u5728\u88ab\u4f7f\u7528&#xff0c;\u6709\u5e94\u7528\u7a0b\u5e8f\u6253\u5f00\u8bbe\u5907&#xff0c;\u8981\u5148\u5173\u95ed\u5e94\u7528\u518d\u5378\u8f7d\u3002<\/p>\n<li>modprobe\u627e\u4e0d\u5230\u6a21\u5757<\/li>\n<p>ko\u6ca1\u6709\u653e\u5230\u7cfb\u7edf\u6a21\u5757\u76ee\u5f55&#xff0c;\u6ca1\u6709\u6267\u884cdepmod&#xff0c;\u6539\u7528insmod\u6307\u5b9ako\u5b8c\u6574\u8def\u5f84\u4e34\u65f6\u6d4b\u8bd5\u3002<\/p>\n<h3>\u4e94\u3001\u672c\u7bc7\u77e5\u8bc6\u70b9\u603b\u7ed3<\/h3>\n<li>\u9a71\u52a8\u4e0d\u80fdgcc\u76f4\u63a5\u7f16\u8bd1&#xff0c;\u4f9d\u9760\u5185\u6838Makefile\u7f16\u8bd1\u4f53\u7cfb&#xff1b;obj\u2011m &#043;&#061; xxx.o\u7f16\u8bd1\u751f\u6210ko\u6a21\u5757\u3002<\/li>\n<li>Makefile\u5173\u952e\u53c2\u6570&#xff1a;\u2011C\u5207\u6362\u5185\u6838\u76ee\u5f55&#xff0c;M&#061;\u6307\u5b9a\u5916\u90e8\u6a21\u5757\u6e90\u7801\u76ee\u5f55\u3002<\/li>\n<li>\u547d\u4ee4\u901f\u8bb0&#xff1a;<br \/>\n|\u547d\u4ee4|\u529f\u80fd|<br \/>\n| &#8212;- | &#8212;- |<br \/>\n|lsmod|\u5217\u51fa\u5df2\u52a0\u8f7d\u5185\u6838\u6a21\u5757|<br \/>\n|insmod xxx.ko|\u76f4\u63a5\u52a0\u8f7dko&#xff0c;\u4e0d\u5904\u7406\u4f9d\u8d56|<br \/>\n|modprobe xxx|\u667a\u80fd\u52a0\u8f7d&#xff0c;\u81ea\u52a8\u5904\u7406\u4f9d\u8d56|<br \/>\n|rmmod xxx|\u5378\u8f7d\u6a21\u5757&#xff0c;\u4e0d\u52a0ko\u540e\u7f00|<br \/>\n|modinfo xxx.ko|\u67e5\u770b\u6a21\u5757\u5143\u4fe1\u606f|<br \/>\n|dmesg|\u67e5\u770bprintk\u5185\u6838\u6253\u5370|<br \/>\n|make clean|\u6e05\u7406\u9a71\u52a8\u7f16\u8bd1\u4ea7\u7269|<\/li>\n<p>\u672c\u7bc7\u4e3a\u4e13\u680f\u5165\u95e8\u514d\u8d39\u7ae0\u8282&#xff0c;\u5b8c\u6574\u4e13\u680f\u5305\u542b\u4e09\u5927\u57fa\u7840\u9a71\u52a8\u8bbe\u5907&#xff08;\u9762\u5411\u5165\u95e8&#xff09;\u3001\u5185\u6838\u673a\u5236\u539f\u7406\u8bb2\u89e3&#xff08;\u9762\u5411\u9762\u8bd5&#xff09;\u3001\u591a\u5957\u9a71\u52a8\u6846\u67b6\u914d\u5957\u6e90\u7801&#xff08;\u9762\u5411\u5de5\u4f5c&#xff09;\u7b49\u5185\u5bb9&#xff0c;\u540e\u7eed\u8fdb\u9636\u5185\u5bb9\u4ec5\u4e13\u680f\u8ba2\u9605\u7528\u6237\u53ef\u89c1&#xff0c;\u70b9\u51fb\u4e13\u680f\u4e3b\u9875\u8ba2\u9605\u89e3\u9501\u5168\u90e8\u6559\u7a0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a5\u4e0a\u4e00\u7bc7&#xff1a;\u4ece\u96f6\u770b\u61c2\u9a71\u52a8\u6846\u67b6  \u8bbe\u5907\u5206\u7c7b  \u6700\u7b80\u6a21\u677f<br \/>\n\u4e0a\u4e00\u7bc7\u6211\u4eec\u62ff\u5230\u4e86\u6700\u7b80\u5185\u6838\u9a71\u52a8 .c \u6e90\u7801&#xff0c;\u4f46\u662f\u5185\u6838\u9a71\u52a8\u4e0d\u80fd\u7528gcc\u76f4\u63a5\u7f16\u8bd1&#xff0c;\u5fc5\u987b\u501f\u52a9\u5185\u6838\u6e90\u7801\u6811\u8fdb\u884c\u7f16\u8bd1\u3002\u672c\u7bc7\u8bb2\u89e3\u9a71\u52a8\u4e13\u7528Makefile\u8bed\u6cd5\u3001\u7f16\u8bd1\u6b65\u9aa4\u3001insmod\/rmmod\/lsmod\/modinfo\/modprobe\u5168\u5957\u547d\u4ee4&#xff0c;\u65b0\u624b\u7167\u7740\u6572\u5373\u53ef\u8dd1\u901a\u5b9e\u9a8c\u3002\u4e00\u3001\u4e3a\u4ec0\u4e48\u9a71\u52a8\u4e0d\u80fd\u76f4\u63a5 gcc xxx.c&#xff1f;<br \/>\n\u666e\u901a\u5e94\u7528\u7a0b\u5e8f&#xff1a;\u94fe\u63a5glibc\u7528\u6237\u6001\u5e93&amp;#x<\/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":[10187,58,269,43,442,44],"topic":[],"class_list":["post-94248","post","type-post","status-publish","format-standard","hentry","category-server","tag-codingplan","tag-linux","tag-269","tag-43","tag-442","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd - \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\/94248.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u63a5\u4e0a\u4e00\u7bc7&#xff1a;\u4ece\u96f6\u770b\u61c2\u9a71\u52a8\u6846\u67b6 \u8bbe\u5907\u5206\u7c7b \u6700\u7b80\u6a21\u677f \u4e0a\u4e00\u7bc7\u6211\u4eec\u62ff\u5230\u4e86\u6700\u7b80\u5185\u6838\u9a71\u52a8 .c \u6e90\u7801&#xff0c;\u4f46\u662f\u5185\u6838\u9a71\u52a8\u4e0d\u80fd\u7528gcc\u76f4\u63a5\u7f16\u8bd1&#xff0c;\u5fc5\u987b\u501f\u52a9\u5185\u6838\u6e90\u7801\u6811\u8fdb\u884c\u7f16\u8bd1\u3002\u672c\u7bc7\u8bb2\u89e3\u9a71\u52a8\u4e13\u7528Makefile\u8bed\u6cd5\u3001\u7f16\u8bd1\u6b65\u9aa4\u3001insmod\/rmmod\/lsmod\/modinfo\/modprobe\u5168\u5957\u547d\u4ee4&#xff0c;\u65b0\u624b\u7167\u7740\u6572\u5373\u53ef\u8dd1\u901a\u5b9e\u9a8c\u3002\u4e00\u3001\u4e3a\u4ec0\u4e48\u9a71\u52a8\u4e0d\u80fd\u76f4\u63a5 gcc xxx.c&#xff1f; \u666e\u901a\u5e94\u7528\u7a0b\u5e8f&#xff1a;\u94fe\u63a5glibc\u7528\u6237\u6001\u5e93&amp;#x\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/94248.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-13T18:40:44+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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/94248.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/94248.html\",\"name\":\"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-13T18:40:44+00:00\",\"dateModified\":\"2026-08-13T18:40:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/94248.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/94248.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/94248.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd\"}]},{\"@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":"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd - \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\/94248.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u63a5\u4e0a\u4e00\u7bc7&#xff1a;\u4ece\u96f6\u770b\u61c2\u9a71\u52a8\u6846\u67b6 \u8bbe\u5907\u5206\u7c7b \u6700\u7b80\u6a21\u677f \u4e0a\u4e00\u7bc7\u6211\u4eec\u62ff\u5230\u4e86\u6700\u7b80\u5185\u6838\u9a71\u52a8 .c \u6e90\u7801&#xff0c;\u4f46\u662f\u5185\u6838\u9a71\u52a8\u4e0d\u80fd\u7528gcc\u76f4\u63a5\u7f16\u8bd1&#xff0c;\u5fc5\u987b\u501f\u52a9\u5185\u6838\u6e90\u7801\u6811\u8fdb\u884c\u7f16\u8bd1\u3002\u672c\u7bc7\u8bb2\u89e3\u9a71\u52a8\u4e13\u7528Makefile\u8bed\u6cd5\u3001\u7f16\u8bd1\u6b65\u9aa4\u3001insmod\/rmmod\/lsmod\/modinfo\/modprobe\u5168\u5957\u547d\u4ee4&#xff0c;\u65b0\u624b\u7167\u7740\u6572\u5373\u53ef\u8dd1\u901a\u5b9e\u9a8c\u3002\u4e00\u3001\u4e3a\u4ec0\u4e48\u9a71\u52a8\u4e0d\u80fd\u76f4\u63a5 gcc xxx.c&#xff1f; \u666e\u901a\u5e94\u7528\u7a0b\u5e8f&#xff1a;\u94fe\u63a5glibc\u7528\u6237\u6001\u5e93&amp;#x","og_url":"https:\/\/www.wsisp.com\/helps\/94248.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-13T18:40:44+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/94248.html","url":"https:\/\/www.wsisp.com\/helps\/94248.html","name":"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-13T18:40:44+00:00","dateModified":"2026-08-13T18:40:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/94248.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/94248.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/94248.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Linux \u9a71\u52a8\u5c0f\u767d\u6559\u7a0b\u3011\u4e8c\u3001\u9a71\u52a8Makefile\u7f16\u5199 + \u6a21\u5757\u64cd\u4f5c\u5168\u5957\u547d\u4ee4\u5b9e\u64cd"}]},{"@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\/94248","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=94248"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/94248\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=94248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=94248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=94248"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=94248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}