{"id":109459,"date":"2026-09-24T07:48:46","date_gmt":"2026-09-23T23:48:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/109459.html"},"modified":"2026-09-24T07:48:46","modified_gmt":"2026-09-23T23:48:46","slug":"linux-%e7%bc%96%e7%a8%8b%e4%b8%ad%e7%9a%84%e9%9d%99%e6%80%81%e5%ba%93%e4%b8%8e%e5%8a%a8%e6%80%81%e5%ba%93%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\/109459.html","title":{"rendered":"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218"},"content":{"rendered":"<h3>1. \u4ec0\u4e48\u662f\u5e93<\/h3>\n<p>\u5728 Linux \u7f16\u7a0b\u4e2d&#xff0c;\u5e93&#xff08;Library&#xff09;\u662f\u4e00\u7ec4\u9884\u5148\u7f16\u8bd1\u597d\u7684\u76ee\u6807\u4ee3\u7801&#xff08;Object Code&#xff09;\u7684\u96c6\u5408&#xff0c;\u5b83\u628a\u5e38\u7528\u7684\u51fd\u6570\u5c01\u88c5\u5728\u4e00\u8d77&#xff0c;\u4f9b\u5176\u4ed6\u7a0b\u5e8f\u5728\u7f16\u8bd1\u6216\u8fd0\u884c\u65f6\u8c03\u7528\u3002\u5e93\u7684\u672c\u8d28\u662f\u4ee3\u7801\u590d\u7528\u7684\u4e00\u79cd\u624b\u6bb5&#xff0c;\u5b83\u8ba9\u5f00\u53d1\u8005\u4e0d\u5fc5\u91cd\u590d\u7f16\u5199\u5e95\u5c42\u529f\u80fd&#xff0c;\u53ea\u9700\u94fe\u63a5\u5bf9\u5e94\u7684\u5e93\u5373\u53ef\u4f7f\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002<\/p>\n<p>\u5e93\u7684\u51fa\u73b0\u89e3\u51b3\u4e86\u4e24\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u4e00\u662f\u907f\u514d\u91cd\u590d\u7f16\u8bd1\u76f8\u540c\u4ee3\u7801&#xff0c;\u63d0\u9ad8\u5f00\u53d1\u6548\u7387&#xff1b;\u4e8c\u662f\u5c06\u529f\u80fd\u6a21\u5757\u5316&#xff0c;\u4fbf\u4e8e\u7ef4\u62a4\u548c\u5206\u53d1\u3002\u4f8b\u5982&#xff0c;C \u6807\u51c6\u5e93\u4e2d\u7684 printf\u3001malloc \u7b49\u51fd\u6570&#xff0c;\u5c31\u662f\u7531\u7cfb\u7edf\u9884\u7f16\u8bd1\u597d\u5e76\u5c01\u88c5\u5728\u5e93\u4e2d&#xff0c;\u5f00\u53d1\u8005\u76f4\u63a5\u8c03\u7528\u5373\u53ef\u3002<\/p>\n<p>\u4ece\u4f7f\u7528\u65b9\u5f0f\u4e0a\u770b&#xff0c;\u5e93\u4e0e\u666e\u901a\u6e90\u7801\u6587\u4ef6\u6700\u5927\u7684\u533a\u522b\u5728\u4e8e&#xff1a;\u6e90\u7801\u9700\u8981\u53c2\u4e0e\u7f16\u8bd1\u8fc7\u7a0b&#xff0c;\u800c\u5e93\u5df2\u7ecf\u662f\u7f16\u8bd1\u4ea7\u7269&#xff0c;\u53ea\u9700\u5728\u94fe\u63a5\u9636\u6bb5\u88ab\u5f15\u7528\u3002\u7406\u89e3\u8fd9\u4e00\u70b9&#xff0c;\u662f\u638c\u63e1\u5e93\u7684\u751f\u6210\u4e0e\u4f7f\u7528\u7684\u57fa\u7840\u3002<\/p>\n<h3>2. \u5e93\u7684\u5206\u7c7b<\/h3>\n<p>Linux \u4e0b\u7684\u5e93\u4e3b\u8981\u5206\u4e3a\u4e24\u5927\u7c7b&#xff1a;\u9759\u6001\u5e93&#xff08;Static Library&#xff09;\u548c\u52a8\u6001\u5e93&#xff08;Dynamic Library&#xff09;&#xff0c;\u4e5f\u53eb\u5171\u4eab\u5e93&#xff08;Shared Library&#xff09;\u3002\u4e24\u8005\u7684\u6838\u5fc3\u533a\u522b\u5728\u4e8e\u94fe\u63a5\u65f6\u673a\u548c\u4ee3\u7801\u7684\u52a0\u8f7d\u65b9\u5f0f\u3002<\/p>\n<h4>2.1 \u9759\u6001\u5e93<\/h4>\n<p>\u9759\u6001\u5e93\u5728\u7a0b\u5e8f\u7f16\u8bd1\u94fe\u63a5\u9636\u6bb5\u88ab\u5b8c\u6574\u590d\u5236\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u3002\u94fe\u63a5\u5b8c\u6210\u540e&#xff0c;\u53ef\u6267\u884c\u6587\u4ef6\u4e0d\u518d\u4f9d\u8d56\u8be5\u5e93&#xff0c;\u8fd0\u884c\u65f6\u65e0\u9700\u989d\u5916\u52a0\u8f7d\u3002\u9759\u6001\u5e93\u7684\u6587\u4ef6\u540d\u901a\u5e38\u4ee5 lib \u5f00\u5934&#xff0c;\u4ee5 .a \u7ed3\u5c3e&#xff0c;\u4f8b\u5982 libmylib.a\u3002<\/p>\n<p>\u9759\u6001\u5e93\u7684\u4f18\u70b9\u662f\u53ef\u6267\u884c\u6587\u4ef6\u72ec\u7acb\u6027\u5f3a&#xff0c;\u90e8\u7f72\u7b80\u5355&#xff0c;\u4e0d\u4f9d\u8d56\u76ee\u6807\u673a\u5668\u4e0a\u662f\u5426\u5b89\u88c5\u4e86\u5bf9\u5e94\u5e93&#xff1b;\u7f3a\u70b9\u662f\u591a\u4e2a\u7a0b\u5e8f\u4f7f\u7528\u540c\u4e00\u9759\u6001\u5e93\u65f6&#xff0c;\u6bcf\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u90fd\u4f1a\u5305\u542b\u4e00\u4efd\u5e93\u4ee3\u7801&#xff0c;\u9020\u6210\u78c1\u76d8\u548c\u5185\u5b58\u7a7a\u95f4\u7684\u6d6a\u8d39&#xff0c;\u4e14\u5e93\u66f4\u65b0\u540e\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\u6240\u6709\u4f9d\u8d56\u5b83\u7684\u7a0b\u5e8f\u3002<\/p>\n<h4>2.2 \u52a8\u6001\u5e93<\/h4>\n<p>\u52a8\u6001\u5e93\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u624d\u88ab\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d&#xff0c;\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u53ea\u4fdd\u5b58\u5bf9\u5e93\u7684\u5f15\u7528\u4fe1\u606f\u3002\u52a8\u6001\u5e93\u7684\u6587\u4ef6\u540d\u901a\u5e38\u4ee5 lib \u5f00\u5934&#xff0c;\u4ee5 .so \u7ed3\u5c3e&#xff0c;\u5e76\u5e26\u6709\u7248\u672c\u53f7&#xff0c;\u4f8b\u5982 libmylib.so.1.0\u3002<\/p>\n<p>\u52a8\u6001\u5e93\u7684\u4f18\u70b9\u662f\u53ef\u4ee5\u88ab\u591a\u4e2a\u8fdb\u7a0b\u5171\u4eab&#xff0c;\u8282\u7701\u5185\u5b58\u548c\u78c1\u76d8\u7a7a\u95f4&#xff1b;\u5e93\u66f4\u65b0\u65f6\u65e0\u9700\u91cd\u65b0\u7f16\u8bd1\u8c03\u7528\u7a0b\u5e8f&#xff0c;\u53ea\u9700\u66ff\u6362\u5e93\u6587\u4ef6\u5373\u53ef\u3002\u7f3a\u70b9\u662f\u7a0b\u5e8f\u8fd0\u884c\u65f6\u4f9d\u8d56\u76ee\u6807\u673a\u5668\u4e0a\u5b58\u5728\u5bf9\u5e94\u7248\u672c\u7684\u5e93&#xff0c;\u5982\u679c\u7f3a\u5931\u6216\u7248\u672c\u4e0d\u5339\u914d&#xff0c;\u7a0b\u5e8f\u5c06\u65e0\u6cd5\u542f\u52a8&#xff0c;\u8fd9\u4e5f\u662f\u5e38\u89c1\u7684\u201c\u5e93\u627e\u4e0d\u5230\u201d\u95ee\u9898\u7684\u6839\u6e90\u3002<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u9879\u9759\u6001\u5e93&#xff08;.a&#xff09;\u52a8\u6001\u5e93&#xff08;.so&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u94fe\u63a5\u65f6\u673a<\/td>\n<td>\u7f16\u8bd1\u94fe\u63a5\u9636\u6bb5<\/td>\n<td>\u7a0b\u5e8f\u8fd0\u884c\u9636\u6bb5<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u4ef6\u547d\u540d<\/td>\n<td>libxxx.a<\/td>\n<td>libxxx.so<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u6267\u884c\u6587\u4ef6\u4f53\u79ef<\/td>\n<td>\u8f83\u5927<\/td>\n<td>\u8f83\u5c0f<\/td>\n<\/tr>\n<tr>\n<td>\u8fd0\u884c\u65f6\u4f9d\u8d56<\/td>\n<td>\u4e0d\u4f9d\u8d56\u5e93\u6587\u4ef6<\/td>\n<td>\u4f9d\u8d56\u5e93\u6587\u4ef6\u5b58\u5728<\/td>\n<\/tr>\n<tr>\n<td>\u66f4\u65b0\u7ef4\u62a4<\/td>\n<td>\u9700\u91cd\u65b0\u7f16\u8bd1\u7a0b\u5e8f<\/td>\n<td>\u66ff\u6362\u5e93\u6587\u4ef6\u5373\u53ef<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3. \u5982\u4f55\u751f\u6210\u5e93<\/h3>\n<p>\u4e0b\u9762\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b&#xff0c;\u6f14\u793a\u5982\u4f55\u7528 C \u8bed\u8a00\u5206\u522b\u751f\u6210\u9759\u6001\u5e93\u548c\u52a8\u6001\u5e93\u3002\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u5de5\u5177\u51fd\u6570\u6587\u4ef6 mytool.c&#xff0c;\u5185\u5bb9\u5982\u4e0b&#xff1a;<\/p>\n<p>int add(int a, int b) {<br \/>\n    return a &#043; b;<br \/>\n}<br \/>\nint multiply(int a, int b) {<br \/>\nreturn a * b;<br \/>\n}<\/p>\n<p>\u5bf9\u5e94\u7684\u5934\u6587\u4ef6 mytool.h \u58f0\u660e\u8fd9\u4e9b\u51fd\u6570&#xff1a;<\/p>\n<p>#ifndef MYTOOL_H<br \/>\n#define MYTOOL_H<br \/>\nint add(int a, int b);<br \/>\nint multiply(int a, int b);<br \/>\n#endif<\/p>\n<h4>3.1 \u751f\u6210\u9759\u6001\u5e93<\/h4>\n<p>\u751f\u6210\u9759\u6001\u5e93\u9700\u8981\u4e24\u6b65&#xff1a;\u5148\u5c06\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3a\u76ee\u6807\u6587\u4ef6&#xff0c;\u518d\u7528 ar \u5de5\u5177\u6253\u5305\u6210\u5e93\u3002<\/p>\n<p># \u7b2c\u4e00\u6b65&#xff1a;\u7f16\u8bd1\u4e3a\u76ee\u6807\u6587\u4ef6<br \/>\ngcc -c mytool.c -o mytool.o<br \/>\n# \u7b2c\u4e8c\u6b65&#xff1a;\u7528 ar \u6253\u5305\u6210\u9759\u6001\u5e93<br \/>\nar rcs libmytool.a mytool.o<\/p>\n<p>\u5176\u4e2d ar \u7684\u53c2\u6570\u542b\u4e49\u4e3a&#xff1a;r \u8868\u793a\u63d2\u5165\u6216\u66ff\u6362\u6587\u4ef6&#xff0c;c \u8868\u793a\u521b\u5efa\u5e93&#xff0c;s \u8868\u793a\u751f\u6210\u7d22\u5f15\u3002\u751f\u6210\u540e\u53ef\u7528 ar -t libmytool.a \u67e5\u770b\u5e93\u4e2d\u5305\u542b\u7684\u76ee\u6807\u6587\u4ef6\u3002<\/p>\n<h4>3.2 \u751f\u6210\u52a8\u6001\u5e93<\/h4>\n<p>\u751f\u6210\u52a8\u6001\u5e93\u4f7f\u7528 gcc -shared \u9009\u9879&#xff0c;\u5e76\u5efa\u8bae\u52a0\u4e0a -fPIC \u751f\u6210\u4f4d\u7f6e\u65e0\u5173\u4ee3\u7801&#xff0c;\u4ee5\u4fbf\u5e93\u88ab\u591a\u4e2a\u8fdb\u7a0b\u5171\u4eab\u52a0\u8f7d\u3002<\/p>\n<p># \u7f16\u8bd1\u5e76\u751f\u6210\u52a8\u6001\u5e93<br \/>\ngcc -fPIC -shared mytool.c -o libmytool.so<\/p>\n<p>\u5982\u679c\u9700\u8981\u5e26\u7248\u672c\u53f7&#xff0c;\u53ef\u4ee5\u8fd9\u6837\u547d\u540d&#xff1a;<\/p>\n<p>gcc -fPIC -shared mytool.c -o libmytool.so.1.0<\/p>\n<h4>3.3 \u4f7f\u7528\u5e93\u7f16\u8bd1\u7a0b\u5e8f<\/h4>\n<p>\u7f16\u5199\u4e3b\u7a0b\u5e8f main.c \u8c03\u7528\u5e93\u4e2d\u7684\u51fd\u6570&#xff1a;<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &#034;mytool.h&#034;<br \/>\nint main() {<br \/>\n    printf(&#034;3 &#043; 5 &#061; %d\\\\n&#034;, add(3, 5));<br \/>\n    printf(&#034;3 * 5 &#061; %d\\\\n&#034;, multiply(3, 5));<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u94fe\u63a5\u9759\u6001\u5e93\u7f16\u8bd1&#xff1a;<\/p>\n<p>gcc main.c -L. -lmytool -o app_static<\/p>\n<p>\u94fe\u63a5\u52a8\u6001\u5e93\u7f16\u8bd1&#xff1a;<\/p>\n<p>gcc main.c -L. -lmytool -o app_dynamic<\/p>\n<p>\u5176\u4e2d -L. \u6307\u5b9a\u5e93\u641c\u7d22\u8def\u5f84\u4e3a\u5f53\u524d\u76ee\u5f55&#xff0c;-lmytool \u8868\u793a\u94fe\u63a5\u540d\u4e3a libmytool \u7684\u5e93\u3002\u6ce8\u610f&#xff0c;\u94fe\u63a5\u52a8\u6001\u5e93\u65f6&#xff0c;\u5982\u679c\u7cfb\u7edf\u627e\u4e0d\u5230\u5e93\u6587\u4ef6&#xff0c;\u9700\u8981\u5148\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf LD_LIBRARY_PATH \u6216\u66f4\u65b0 ldconfig \u914d\u7f6e\u3002<\/p>\n<h3>4. \u6613\u9519\u70b9<\/h3>\n<p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u9759\u6001\u5e93\u548c\u52a8\u6001\u5e93\u7684\u4f7f\u7528\u7ecf\u5e38\u9047\u5230\u5404\u79cd\u95ee\u9898&#xff0c;\u4e0b\u9762\u603b\u7ed3\u51e0\u4e2a\u6700\u5e38\u89c1\u7684\u5751\u3002<\/p>\n<h4>4.1 \u94fe\u63a5\u65f6\u627e\u4e0d\u5230\u5e93<\/h4>\n<p>\u7f16\u8bd1\u65f6\u63d0\u793a cannot find -lmytool&#xff0c;\u901a\u5e38\u662f\u56e0\u4e3a\u5e93\u6587\u4ef6\u4e0d\u5728\u9ed8\u8ba4\u641c\u7d22\u8def\u5f84\u4e2d&#xff0c;\u4e14\u6ca1\u6709\u7528 -L \u6307\u5b9a\u8def\u5f84\u3002\u89e3\u51b3\u529e\u6cd5\u662f\u786e\u8ba4\u5e93\u6587\u4ef6\u786e\u5b9e\u5b58\u5728&#xff0c;\u5e76\u5728\u7f16\u8bd1\u547d\u4ee4\u4e2d\u52a0\u4e0a -L \u6307\u5b9a\u5e93\u6240\u5728\u76ee\u5f55\u3002<\/p>\n<h4>4.2 \u8fd0\u884c\u65f6\u627e\u4e0d\u5230\u52a8\u6001\u5e93<\/h4>\n<p>\u7a0b\u5e8f\u7f16\u8bd1\u6210\u529f&#xff0c;\u4f46\u8fd0\u884c\u65f6\u63d0\u793a error while loading shared libraries: libmytool.so: cannot open shared object file\u3002\u8fd9\u662f\u56e0\u4e3a\u52a8\u6001\u5e93\u5728\u8fd0\u884c\u65f6\u9700\u8981\u88ab\u7cfb\u7edf\u627e\u5230&#xff0c;\u800c\u9ed8\u8ba4\u641c\u7d22\u8def\u5f84\u4e0d\u5305\u542b\u5f53\u524d\u76ee\u5f55\u3002\u89e3\u51b3\u529e\u6cd5\u6709\u4e24\u79cd&#xff1a;<\/p>\n<p># \u65b9\u6cd5\u4e00&#xff1a;\u4e34\u65f6\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<br \/>\nexport LD_LIBRARY_PATH&#061;.:$LD_LIBRARY_PATH<br \/>\n.\/app_dynamic<br \/>\n\u65b9\u6cd5\u4e8c&#xff1a;\u5c06\u5e93\u8def\u5f84\u5199\u5165\u7cfb\u7edf\u914d\u7f6e<br \/>\nsudo ldconfig \/path\/to\/lib<\/p>\n<h4>4.3 \u5fd8\u8bb0\u52a0 -fPIC<\/h4>\n<p>\u751f\u6210\u52a8\u6001\u5e93\u65f6\u5982\u679c\u5fd8\u8bb0\u52a0 -fPIC&#xff0c;\u5728 64 \u4f4d\u7cfb\u7edf\u4e0a\u94fe\u63a5\u65f6\u53ef\u80fd\u62a5\u9519 relocation R_X86_64_32 against &#8230; can not be used when making a shared object\u3002\u89e3\u51b3\u529e\u6cd5\u662f\u7f16\u8bd1\u52a8\u6001\u5e93\u65f6\u59cb\u7ec8\u52a0\u4e0a -fPIC \u9009\u9879\u3002<\/p>\n<h4>4.4 \u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\u540c\u540d\u51b2\u7a81<\/h4>\n<p>\u5f53\u76ee\u5f55\u4e0b\u540c\u65f6\u5b58\u5728 libmytool.a \u548c libmytool.so \u65f6&#xff0c;\u7f16\u8bd1\u5668\u9ed8\u8ba4\u4f18\u5148\u94fe\u63a5\u52a8\u6001\u5e93\u3002\u5982\u679c\u5e0c\u671b\u5f3a\u5236\u4f7f\u7528\u9759\u6001\u5e93&#xff0c;\u53ef\u4ee5\u52a0\u4e0a -static \u9009\u9879&#xff0c;\u6216\u76f4\u63a5\u6307\u5b9a\u5e93\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84\u3002<\/p>\n<p># \u5f3a\u5236\u4f7f\u7528\u9759\u6001\u5e93<br \/>\ngcc main.c -L. -static -lmytool -o app_static_force<\/p>\n<h4>4.5 \u5934\u6587\u4ef6\u4e0e\u5e93\u7248\u672c\u4e0d\u5339\u914d<\/h4>\n<p>\u5934\u6587\u4ef6\u58f0\u660e\u7684\u51fd\u6570\u7b7e\u540d\u4e0e\u5e93\u4e2d\u5b9e\u9645\u5b9e\u73b0\u4e0d\u4e00\u81f4&#xff0c;\u4f1a\u5bfc\u81f4\u7f16\u8bd1\u901a\u8fc7\u4f46\u94fe\u63a5\u5931\u8d25&#xff0c;\u6216\u8fd0\u884c\u65f6\u51fa\u73b0\u6bb5\u9519\u8bef\u3002\u89e3\u51b3\u529e\u6cd5\u662f\u786e\u4fdd\u5934\u6587\u4ef6\u4e0e\u5e93\u6587\u4ef6\u6765\u81ea\u540c\u4e00\u7248\u672c&#xff0c;\u4fee\u6539\u63a5\u53e3\u540e\u8981\u540c\u6b65\u91cd\u65b0\u7f16\u8bd1\u5e93\u548c\u8c03\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u638c\u63e1\u4ee5\u4e0a\u8981\u70b9&#xff0c;\u5c31\u80fd\u5728 Linux \u4e0b\u719f\u7ec3\u5730\u521b\u5efa\u548c\u4f7f\u7528\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93&#xff0c;\u907f\u514d\u5e38\u89c1\u7684\u94fe\u63a5\u548c\u8fd0\u884c\u9519\u8bef\u3002<\/p>\n<h3>5. \u603b\u7ed3<\/h3>\n<p>\u672c\u6587\u56f4\u7ed5 Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\u5c55\u5f00&#xff0c;\u5148\u4ecb\u7ecd\u4e86\u5e93\u7684\u6982\u5ff5\u4e0e\u4f5c\u7528&#xff0c;\u518d\u5bf9\u6bd4\u4e86\u4e24\u7c7b\u5e93\u5728\u94fe\u63a5\u65f6\u673a\u3001\u6587\u4ef6\u547d\u540d\u3001\u4f53\u79ef\u3001\u8fd0\u884c\u65f6\u4f9d\u8d56\u548c\u66f4\u65b0\u7ef4\u62a4\u4e0a\u7684\u5dee\u5f02&#xff0c;\u968f\u540e\u901a\u8fc7\u5177\u4f53\u547d\u4ee4\u6f14\u793a\u4e86\u5982\u4f55\u7528 gcc \u548c ar \u751f\u6210\u5e76\u94fe\u63a5\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93&#xff0c;\u6700\u540e\u603b\u7ed3\u4e86\u94fe\u63a5\u5931\u8d25\u3001\u8fd0\u884c\u65f6\u627e\u4e0d\u5230\u5e93\u3001\u5fd8\u8bb0 -fPIC\u3001\u540c\u540d\u51b2\u7a81\u4ee5\u53ca\u5934\u6587\u4ef6\u4e0e\u5e93\u7248\u672c\u4e0d\u5339\u914d\u7b49\u5e38\u89c1\u95ee\u9898\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u5efa\u8bae\u4f18\u5148\u6839\u636e\u90e8\u7f72\u73af\u5883\u548c\u66f4\u65b0\u9891\u7387\u9009\u62e9\u5408\u9002\u7684\u5e93\u7c7b\u578b&#xff1a;\u8ffd\u6c42\u72ec\u7acb\u90e8\u7f72\u53ef\u9009\u9759\u6001\u5e93&#xff0c;\u8ffd\u6c42\u8282\u7701\u7a7a\u95f4\u548c\u7075\u6d3b\u66f4\u65b0\u53ef\u9009\u52a8\u6001\u5e93\u3002\u540c\u65f6&#xff0c;\u751f\u6210\u52a8\u6001\u5e93\u65f6\u52a1\u5fc5\u52a0\u4e0a -fPIC&#xff0c;\u8fd0\u884c\u65f6\u6ce8\u610f\u901a\u8fc7 LD_LIBRARY_PATH \u6216 ldconfig \u914d\u7f6e\u5e93\u641c\u7d22\u8def\u5f84&#xff0c;\u5e76\u4fdd\u6301\u5934\u6587\u4ef6\u4e0e\u5e93\u7248\u672c\u4e00\u81f4&#xff0c;\u8fd9\u6837\u624d\u80fd\u51cf\u5c11\u94fe\u63a5\u548c\u8fd0\u884c\u9636\u6bb5\u7684\u5404\u7c7b\u9519\u8bef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u4ec0\u4e48\u662f\u5e93\u5728 Linux \u7f16\u7a0b\u4e2d&#xff0c;\u5e93&#xff08;Library&#xff09;\u662f\u4e00\u7ec4\u9884\u5148\u7f16\u8bd1\u597d\u7684\u76ee\u6807\u4ee3\u7801&#xff08;Object Code&#xff09;\u7684\u96c6\u5408&#xff0c;\u5b83\u628a\u5e38\u7528\u7684\u51fd\u6570\u5c01\u88c5\u5728\u4e00\u8d77&#xff0c;\u4f9b\u5176\u4ed6\u7a0b\u5e8f\u5728\u7f16\u8bd1\u6216\u8fd0\u884c\u65f6\u8c03\u7528\u3002\u5e93\u7684\u672c\u8d28\u662f\u4ee3\u7801\u590d\u7528\u7684\u4e00\u79cd\u624b\u6bb5&#xff0c;\u5b83\u8ba9\u5f00\u53d1\u8005\u4e0d\u5fc5\u91cd\u590d\u7f16\u5199\u5e95\u5c42\u529f\u80fd&#xff0c;\u53ea\u9700\u94fe\u63a5\u5bf9\u5e94\u7684\u5e93\u5373\u53ef\u4f7f\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002\u5e93\u7684\u51fa\u73b0\u89e3\u51b3\u4e86\u4e24\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u4e00\u662f\u907f\u514d\u91cd\u590d\u7f16\u8bd1\u76f8\u540c\u4ee3\u7801&#xff0c;<\/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":[58],"topic":[],"class_list":["post-109459","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\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\/109459.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1. \u4ec0\u4e48\u662f\u5e93\u5728 Linux \u7f16\u7a0b\u4e2d&#xff0c;\u5e93&#xff08;Library&#xff09;\u662f\u4e00\u7ec4\u9884\u5148\u7f16\u8bd1\u597d\u7684\u76ee\u6807\u4ee3\u7801&#xff08;Object Code&#xff09;\u7684\u96c6\u5408&#xff0c;\u5b83\u628a\u5e38\u7528\u7684\u51fd\u6570\u5c01\u88c5\u5728\u4e00\u8d77&#xff0c;\u4f9b\u5176\u4ed6\u7a0b\u5e8f\u5728\u7f16\u8bd1\u6216\u8fd0\u884c\u65f6\u8c03\u7528\u3002\u5e93\u7684\u672c\u8d28\u662f\u4ee3\u7801\u590d\u7528\u7684\u4e00\u79cd\u624b\u6bb5&#xff0c;\u5b83\u8ba9\u5f00\u53d1\u8005\u4e0d\u5fc5\u91cd\u590d\u7f16\u5199\u5e95\u5c42\u529f\u80fd&#xff0c;\u53ea\u9700\u94fe\u63a5\u5bf9\u5e94\u7684\u5e93\u5373\u53ef\u4f7f\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002\u5e93\u7684\u51fa\u73b0\u89e3\u51b3\u4e86\u4e24\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u4e00\u662f\u907f\u514d\u91cd\u590d\u7f16\u8bd1\u76f8\u540c\u4ee3\u7801&#xff0c;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/109459.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-23T23:48:46+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\/109459.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/109459.html\",\"name\":\"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\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-09-23T23:48:46+00:00\",\"dateModified\":\"2026-09-23T23:48:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/109459.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/109459.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/109459.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\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":"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\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\/109459.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\uff1a\u4ece\u539f\u7406\u5230\u5b9e\u6218 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1. \u4ec0\u4e48\u662f\u5e93\u5728 Linux \u7f16\u7a0b\u4e2d&#xff0c;\u5e93&#xff08;Library&#xff09;\u662f\u4e00\u7ec4\u9884\u5148\u7f16\u8bd1\u597d\u7684\u76ee\u6807\u4ee3\u7801&#xff08;Object Code&#xff09;\u7684\u96c6\u5408&#xff0c;\u5b83\u628a\u5e38\u7528\u7684\u51fd\u6570\u5c01\u88c5\u5728\u4e00\u8d77&#xff0c;\u4f9b\u5176\u4ed6\u7a0b\u5e8f\u5728\u7f16\u8bd1\u6216\u8fd0\u884c\u65f6\u8c03\u7528\u3002\u5e93\u7684\u672c\u8d28\u662f\u4ee3\u7801\u590d\u7528\u7684\u4e00\u79cd\u624b\u6bb5&#xff0c;\u5b83\u8ba9\u5f00\u53d1\u8005\u4e0d\u5fc5\u91cd\u590d\u7f16\u5199\u5e95\u5c42\u529f\u80fd&#xff0c;\u53ea\u9700\u94fe\u63a5\u5bf9\u5e94\u7684\u5e93\u5373\u53ef\u4f7f\u7528\u5176\u4e2d\u7684\u51fd\u6570\u3002\u5e93\u7684\u51fa\u73b0\u89e3\u51b3\u4e86\u4e24\u4e2a\u6838\u5fc3\u95ee\u9898&#xff1a;\u4e00\u662f\u907f\u514d\u91cd\u590d\u7f16\u8bd1\u76f8\u540c\u4ee3\u7801&#xff0c;","og_url":"https:\/\/www.wsisp.com\/helps\/109459.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-23T23:48:46+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\/109459.html","url":"https:\/\/www.wsisp.com\/helps\/109459.html","name":"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\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-09-23T23:48:46+00:00","dateModified":"2026-09-23T23:48:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/109459.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/109459.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/109459.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u7f16\u7a0b\u4e2d\u7684\u9759\u6001\u5e93\u4e0e\u52a8\u6001\u5e93\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\/109459","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=109459"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/109459\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=109459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=109459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=109459"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=109459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}