{"id":25,"date":"2013-07-17T22:01:22","date_gmt":"2013-07-17T13:01:22","guid":{"rendered":"https:\/\/www.dogrow.net\/linux\/?p=25"},"modified":"2021-12-10T02:10:34","modified_gmt":"2021-12-09T17:10:34","slug":"blog6","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/linux\/blog6\/","title":{"rendered":"(6) ldconfig\u3067\u30e9\u30a4\u30d6\u30e9\u30ea\u30d1\u30b9\u3092\u66f4\u65b0"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p><span class=\"my_fc_deeppinkBBig\">ldconfig<\/span> \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u4f53\u611f\u3057\u305f\u3044\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u5b9f\u884c\u6642\u3001OS\u306f\u52d5\u7684\u306b\u30ea\u30f3\u30af\u3059\u308b\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\uff08.so\u30d5\u30a1\u30a4\u30eb\uff09\u3092\u63a2\u3059\u3002<br \/>\n\u300c\u3069\u3053\u3092\u63a2\u3059\u304b\uff1f\u300d<br \/>\n\u306e\u60c5\u5831\u3092 .conf \u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u3066\u304a\u304d\u3001\u3053\u308c\u3092 OS\u306e\u52d5\u4f5c\u306b\u53cd\u6620\u3057\u3066\u304f\u308c\u308b\u306e\u304c ldconfig \u30b3\u30de\u30f3\u30c9\u3060\u3002<\/p>\n<h1 class=\"my_h\">2. \u4ed5\u7d44\u307f<\/h1>\n<p>\u3061\u306a\u307f\u306bOS\u306f\u4ee5\u4e0b\u306e\u9806\u5e8f\u3067\u30ed\u30fc\u30c9\u3059\u308b\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u63a2\u3059\u3002<\/p>\n<p class=\"my_fs_big2 my_mgB_0\">(1) \u74b0\u5883\u5909\u6570\u3067\u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9<\/p>\n<p>LD_LIBRARY_PATH<br \/>\nLD_LIBRARY_PATH_64<\/p>\n<p class=\"my_fs_big2\">(2) <span class=\"my_fc_blue\">\/etc\/ld.so.conf<\/span> \u306b\u8a18\u8ff0\u3055\u308c\u305f\u30d1\u30b9<\/p>\n<p class=\"my_fs_big2 my_mgB_0\">(3) \u901a\u5e38\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u7f6e\u304b\u308c\u308b\u30d1\u30b9<\/p>\n<p>\/lib (\/usr\/lib \u3078\u306e symbolic link)<br \/>\n\/lib64 (\/usr\/lib64 \u3078\u306e symbolic link)<\/p>\n<p><span class=\"my_fc_deeppink\">ldconfig<\/span>\u30b3\u30de\u30f3\u30c9\u306f\u3001\u4e0a\u8a18(2) \u306e\u60c5\u5831\u3092OS\u306b\u4f1d\u3048\u308b\u305f\u3081\u306e\u30b3\u30de\u30f3\u30c9\u3060\u3002<\/p>\n<p><span class=\"my_fs_big2\">CentOS6, CentOS7<\/span> \u306e\u5834\u5408\u3001<span style=\"color: #0000ff;\">\/etc<\/span> \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b <span style=\"color: #0000ff;\">ld.so.conf<\/span> \u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ ls -l \/etc\/ld.so.conf\r\n-rw-r--r--. 1 root root 28  5\u6708  5 04:22 2010 \/etc\/ld.so.conf\r\n[user@]$\r\n<\/pre>\n<p>\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3092\u898b\u308b\u3068\u3001\u66f4\u306b\u4e0b\u4f4d\u306e <span style=\"color: #0000ff;\">ld.so.conf.d<\/span> \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3042\u308b <span style=\"color: #0000ff;\">*.conf<\/span> \u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ cat \/etc\/ld.so.conf\r\ninclude ld.so.conf.d\/*.conf\r\n[user@]$\r\n<\/pre>\n<p>\u306a\u306e\u3067\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u691c\u7d22\u30d1\u30b9\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u3001<span class=\"my_fc_blue\">\/etc\/ld.so.conf.d<\/span> \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u914d\u4e0b\u306b\u62e1\u5f35\u5b50\u304c\u300c.conf\u300d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u306b\u30e9\u30a4\u30d6\u30e9\u30ea\u691c\u7d22\u30d1\u30b9\u3092\u8a18\u8ff0\u3057\u3066\u3084\u308c\u3070\u3088\u3044\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f \u3001\/etc\/ld.so.conf.d\/my.conf \u3092\u4f5c\u6210\u3057\u3001\/home\/user\/mylib \u3078\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u691c\u7d22\u30d1\u30b9\u3092\u8ffd\u52a0\u3057\u305f\u3002<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ cd \/etc\/ld.so.conf.d\/\r\n[user@]$ su\r\n\u30d1\u30b9\u30ef\u30fc\u30c9:\r\n[root@]# echo \/home\/user\/mylib &gt;&gt; my.conf\r\n<\/pre>\n<p>\u8a2d\u5b9a\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u306f <span style=\"color: #ff00ff;\">ldconfig<\/span> \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ su\r\n\u30d1\u30b9\u30ef\u30fc\u30c9:\r\n[root@]# ldconfig\r\n<\/pre>\n<p>\u8ffd\u52a0\u767b\u9332\u3057\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u691c\u7d22\u30d1\u30b9\u3068\u3057\u3066\u6b63\u3057\u304f\u691c\u51fa\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u304b\u3092\u78ba\u8a8d\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ ldconfig -p\r\n<\/pre>\n\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-format=\"fluid\"\n     data-ad-layout-key=\"-fb+5w+4e-db+86\"\n     data-ad-client=\"ca-pub-0629873272207301\"\n     data-ad-slot=\"9529643655\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n<h1 class=\"my_h\" style=\"margin-top:2.5rem !important\">3. \u7c21\u5358\u306a\u5b9f\u9a13\u3067\u4f53\u611f\u3057\u3066\u307f\u308b<\/h1>\n<h3 class=\"my_h\">1) \u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f5c\u6210<\/h3>\n<p>Hello\u3068\u8868\u793a\u3059\u308b\u3060\u3051\u306e\u95a2\u6570 say_hello() \u306e\u307f\u3092\u5b9f\u88c5\u3057\u305f\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea libmytest.so \u3092\u4f5c\u6210\u3059\u308b\u3002<br \/>\ntest.c<\/p>\n<pre class=\"brush: cpp; class-name: &#039;my_border_1px&#039;; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\nvoid say_hello(void){\r\n    printf(&quot;Hello!\\n&quot;);\r\n}\r\n<\/pre>\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\uff06\u30ea\u30f3\u30af\u3092\u5b9f\u884c\u3057\u3001\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea libmytest.so \u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\ngcc -shared -fPIC -o libmytest.so test.c\r\n<\/pre>\n<h3 class=\"my_h\">2) \u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046EXE\u3092\u4f5c\u6210<\/h3>\n<p>main.c<\/p>\n<pre class=\"brush: cpp; class-name: &#039;my_border_1px&#039;; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\nextern void say_hello(void);\r\nint main(void){\r\n    say_hello();\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u30b3\u30f3\u30d1\u30a4\u30eb\uff06\u30ea\u30f3\u30af\u3092\u5b9f\u884c\u3057\u3001\u5b9f\u884c\u4f53 myexe \u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\ngcc -L.\/ -o myexe main.c -lmytest\r\n<\/pre>\n<h3 class=\"my_h\">3) \u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5404\u6240\u306b\u914d\u7f6e<\/h3>\n<p>\u672c\u6295\u7a3f\u306e\u6700\u521d\u306b\u8a18\u3057\u305f\u4e09\u3064\u306e\u65b9\u6cd5\u3067\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u691c\u51fa\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\nsudo cp .\/libmytest.so \/lib64\r\ncp .\/libmytest.so ~\/mylib\r\nexport LD_LIBRARY_PATH=.\/\r\n<\/pre>\n<p>\u5148\u306b\u4f5c\u6210\u3057\u305f\u5b9f\u884c\u4f53 test \u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u78ba\u304b\u306b\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u95a2\u6570\u3092\u5b9f\u884c\u3067\u304d\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"my_pre\">\r\n[user]$ .\/test\r\nHello!\r\n<\/pre>\n<h3 class=\"my_h\">4) \u5b9f\u9a13\uff1a\u3069\u308c\u304c\u30ea\u30f3\u30af\u3055\u308c\u308b\u304b\uff1f<\/h3>\n<p>\u307e\u305a\u306f\u3053\u306e\u72b6\u614b\u3067\u5b9f\u884c\u4f53 test \u306b\u3069\u3053\u306e\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u30ea\u30f3\u30af\u3055\u308c\u305f\u306e\u304b\uff1f<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ ldd test\r\n        linux-vdso.so.1 =>  (0x00007fff3f5ca000)\r\n        <span class=\"my_fc_deeppink\">libmytest.so => .\/libmytest.so (0x00007ff9997c3000)<\/span>\r\n        libc.so.6 => \/lib64\/libc.so.6 (0x00007ff9993e4000)\r\n        \/lib64\/ld-linux-x86-64.so.2 (0x000055b979479000)\r\n<\/pre>\n<p>LD_LIBRARY_PATH \u306e\u6307\u5b9a\u304c\u9069\u7528\u3055\u308c\u305f\u3002<\/p>\n<p>\u3067\u306f LD_LIBRARY_PATH \u306e\u8a2d\u5b9a\u3092\u30af\u30ea\u30a2\u3057\u3066\u307f\u305f\u3089\u3069\u3046\u304b\uff1f<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ unset LD_LIBRARY_PATH\r\n[user@]$ ldd test\r\n        linux-vdso.so.1 =>  (0x00007fff20bf8000)\r\n        <span class=\"my_fc_deeppink\">libmytest.so => \/home\/user\/mylib\/libmytest.so (0x00007f84ec54b000)<\/span>\r\n        libc.so.6 => \/lib64\/libc.so.6 (0x00007f84ec188000)\r\n        \/lib64\/ld-linux-x86-64.so.2 (0x00005591ed411000)\r\n<\/pre>\n<p>\u4eca\u5ea6\u306f <span class=\"my_fc_blue\">\/etc\/ld.so.conf<\/span> \u306e\u8a2d\u5b9a\u304c\u9069\u7528\u3055\u308c\u305f\u3002<\/p>\n<p>\u3067\u306f <span class=\"my_fc_blue\">\/etc\/ld.so.conf<\/span> \u306e\u8a2d\u5b9a\u3092\u89e3\u9664\u3057\u3066\u307f\u305f\u3089\u3069\u3046\u304b\uff1f<\/p>\n<pre class=\"my_pre\">\r\n[user@]$ sudo rm \/etc\/ld.so.conf.d\/my.conf\r\n[user@]$ sudo ldconfig\r\n[user@]$ ldd test\r\n        linux-vdso.so.1 =>  (0x00007fffba988000)\r\n        <span class=\"my_fc_deeppink\">libmytest.so => \/lib64\/libmytest.so (0x00007ff00be4b000)<\/span>\r\n        libc.so.6 => \/lib64\/libc.so.6 (0x00007ff00ba88000)\r\n        \/lib64\/ld-linux-x86-64.so.2 (0x0000564fcc6cd000)\r\n<\/pre>\n<p>\u4eca\u5ea6\u306f <span class=\"my_fc_blue\">\/lib64<\/span> \u306b\u7f6e\u304b\u308c\u305f\u3082\u306e\u304c\u63a1\u7528\u3055\u308c\u305f\u3002<\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 ldconfig \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u969b\u306b\u4f7f\u3063\u3066\u4f53\u611f\u3057\u305f\u3044\u3002 \u30d7\u30ed\u30b0\u30e9\u30e0\u5b9f\u884c\u6642\u3001OS\u306f\u52d5\u7684\u306b\u30ea\u30f3\u30af\u3059\u308b\u5171\u6709\u30e9\u30a4\u30d6\u30e9\u30ea\uff08.so\u30d5\u30a1\u30a4\u30eb\uff09\u3092\u63a2\u3059\u3002 \u300c\u3069\u3053\u3092\u63a2\u3059\u304b\uff1f\u300d \u306e\u60c5\u5831\u3092 .conf \u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u3066\u304a\u304d\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/linux\/blog6\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,95,3],"tags":[],"class_list":["post-25","post","type-post","status-publish","format-standard","hentry","category-ldconfig","category-ldd","category-command"],"views":78575,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts\/25","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/comments?post=25"}],"version-history":[{"count":77,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts\/25\/revisions"}],"predecessor-version":[{"id":3051,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/posts\/25\/revisions\/3051"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/media?parent=25"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/categories?post=25"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/linux\/wp-json\/wp\/v2\/tags?post=25"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}