日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

Linux 下编译安装软件,找不到共享库 xx.so 的解决办法

發(fā)布時(shí)間:2025/5/22 linux 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux 下编译安装软件,找不到共享库 xx.so 的解决办法 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

編譯memcached時(shí),報(bào)錯(cuò)沒(méi)有l(wèi)ibevent,于是下載libevent,configure , make && make install ,然后在重新安裝memcache成功之后。memcached默認(rèn)安裝在/usr/local/bin/目錄下。

執(zhí)行命令 ./memcache -help 報(bào)錯(cuò):

[root@localhost bin]# ./memcached ./memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

但是上面明明已經(jīng)安裝了 libevent 的,應(yīng)該是memcached沒(méi)有尋找到。

查找 libevent 安裝的路徑:

[root@localhost bin]# whereis libevent libevent: /usr/local/lib/libevent.la /usr/local/lib/libevent.a /usr/local/lib/libevent.so

我們看到被安裝到了:/usr/local/lib/libevent.so

我們查看 memcached 的依賴(lài):

[root@localhost bin]# ldd /usr/local/bin/memcachedlinux-gate.so.1 => (0x00c8d000)libevent-2.0.so.5 => not foundlibrt.so.1 => /lib/librt.so.1 (0x00720000)libpthread.so.0 => /lib/libpthread.so.0 (0x006fc000)libc.so.6 => /lib/libc.so.6 (0x00564000)/lib/ld-linux.so.2 (0x0053e000)

發(fā)現(xiàn)依賴(lài)的 libevent-2.0.so.5 => not found 沒(méi)有找到。

查看 libevent 如何尋找依賴(lài):

[root@localhost bin]# LD_DEBUG=libs ./memcached -v10071: find library=libevent-2.0.so.5 [0]; searching10071: search cache=/etc/ld.so.cache10071: search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib (system search path)10071: trying file=/lib/tls/i686/sse2/libevent-2.0.so.510071: trying file=/lib/tls/i686/libevent-2.0.so.510071: trying file=/lib/tls/sse2/libevent-2.0.so.510071: trying file=/lib/tls/libevent-2.0.so.510071: trying file=/lib/i686/sse2/libevent-2.0.so.510071: trying file=/lib/i686/libevent-2.0.so.510071: trying file=/lib/sse2/libevent-2.0.so.510071: trying file=/lib/libevent-2.0.so.510071: trying file=/usr/lib/tls/i686/sse2/libevent-2.0.so.510071: trying file=/usr/lib/tls/i686/libevent-2.0.so.510071: trying file=/usr/lib/tls/sse2/libevent-2.0.so.510071: trying file=/usr/lib/tls/libevent-2.0.so.510071: trying file=/usr/lib/i686/sse2/libevent-2.0.so.510071: trying file=/usr/lib/i686/libevent-2.0.so.510071: trying file=/usr/lib/sse2/libevent-2.0.so.510071: trying file=/usr/lib/libevent-2.0.so.5

我們看到:

search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:
/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:
/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib (system search path)

系統(tǒng)尋找 lib 的路徑,中沒(méi)有包含:/usr/local/lib/

所以找到了原因,解決方法就很簡(jiǎn)單了。也有多種方法。

1) 做一個(gè)軟連接到上面的隨便一個(gè) search path 中的目錄都是可以的:

[root@localhost bin]# ln -s /usr/local/lib/libevent.so /usr/lib/libevent-2.0.so.5

驗(yàn)證是否已經(jīng)解決:

[root@localhost bin]# memcached -help memcached 1.4.24 -p <num> TCP port number to listen on (default: 11211) -U <num> UDP port number to listen on (default: 11211, 0 is off) -s <file> UNIX socket path to listen on (disables network support) -A enable ascii "shutdown" command -a <mask> access mask for UNIX socket, in octal (default: 0700) -l <addr> interface to listen on (default: INADDR_ANY, all addresses)<addr> may be specified as host:port. If you don't specifya port number, the value you specified with -p or -U isused. You may specify multiple addresses separated by commaor by using -l multiple times -d run as a daemon -r maximize core file limit -u <username> assume identity of <username> (only when run as root) -m <num> max memory to use for items in megabytes (default: 64 MB) -M return error on memory exhausted (rather than removing items) -c <num> max simultaneous connections (default: 1024) -k lock down all paged memory. Note that there is alimit on how much memory you may lock. Trying toallocate more than that would fail, so be sure youset the limit correctly for the user you startedthe daemon with (not for -u <username> user;under sh this is done with 'ulimit -S -l NUM_KB'). -v verbose (print errors/warnings while in event loop) -vv very verbose (also print client commands/reponses) -vvv extremely verbose (also print internal state transitions) -h print this help and exit -i print memcached and libevent license -V print version and exit -P <file> save PID in <file>, only used with -d option -f <factor> chunk size growth factor (default: 1.25) -n <bytes> minimum space allocated for key+value+flags (default: 48) -L Try to use large memory pages (if available). Increasingthe memory page size could reduce the number of TLB missesand improve the performance. In order to get large pagesfrom the OS, memcached will allocate the total item-cachein one large chunk. -D <char> Use <char> as the delimiter between key prefixes and IDs.This is used for per-prefix stats reporting. The default is":" (colon). If this option is specified, stats collectionis turned on automatically; if not, then it may be turned onby sending the "stats detail on" command to the server. -t <num> number of threads to use (default: 4) -R Maximum number of requests per event, limits the number ofrequests process for a given connection to prevent starvation (default: 20) -C Disable use of CAS -b Set the backlog queue limit (default: 1024) -B Binding protocol - one of ascii, binary, or auto (default) -I Override the size of each slab page. Adjusts max item size(default: 1mb, min: 1k, max: 128m) -F Disable flush_all command -o Comma separated list of extended or experimental options- (EXPERIMENTAL) maxconns_fast: immediately close newconnections if over maxconns limit- hashpower: An integer multiplier for how large the hashtable should be. Can be grown at runtime if not big enough.Set this based on "STAT hash_power_level" before a restart.- tail_repair_time: Time in seconds that indicates how long to wait beforeforcefully taking over the LRU tail item whose refcount has leaked.Disabled by default; dangerous option.- hash_algorithm: The hash table algorithmdefault is jenkins hash. options: jenkins, murmur3- lru_crawler: Enable LRU Crawler background thread- lru_crawler_sleep: Microseconds to sleep between itemsdefault is 100.- lru_crawler_tocrawl: Max items to crawl per slab per rundefault is 0 (unlimited)- lru_maintainer: Enable new LRU system + background thread- hot_lru_pct: Pct of slab memory to reserve for hot lru.(requires lru_maintainer)- warm_lru_pct: Pct of slab memory to reserve for warm lru.(requires lru_maintainer)- expirezero_does_not_evict: Items set to not expire, will not evict.(requires lru_maintainer)

我們看到?jīng)]有報(bào)錯(cuò)了。

2) 在編譯libevent的時(shí)候,指定相關(guān)目錄:

[root@localhost libevent]# ./configure --help `configure' configures this package to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:-h, --help display this help and exit--help=short display options specific to this package--help=recursive display the short help of all the included packages-V, --version display version information and exit-q, --quiet, --silent do not print `checking ...' messages--cache-file=FILE cache test results in FILE [disabled]-C, --config-cache alias for `--cache-file=config.cache' -n, --no-create do not create output files--srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories:--prefix=PREFIX install architecture-independent files in PREFIX[/usr/local]--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX[PREFIX]By default, `make install' will install all the files in `/usr/local/bin', `/usr/local/lib' etc. You can specify an installation prefix other than `/usr/local' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below.Fine tuning of the installation directories:--bindir=DIR user executables [EPREFIX/bin]--sbindir=DIR system admin executables [EPREFIX/sbin]--libexecdir=DIR program executables [EPREFIX/libexec]--sysconfdir=DIR read-only single-machine data [PREFIX/etc]--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]--localstatedir=DIR modifiable single-machine data [PREFIX/var]--libdir=DIR object code libraries [EPREFIX/lib]--includedir=DIR C header files [PREFIX/include]--oldincludedir=DIR C header files for non-gcc [/usr/include]--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]--datadir=DIR read-only architecture-independent data [DATAROOTDIR]--infodir=DIR info documentation [DATAROOTDIR/info]--localedir=DIR locale-dependent data [DATAROOTDIR/locale]--mandir=DIR man documentation [DATAROOTDIR/man]--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]--htmldir=DIR html documentation [DOCDIR]--dvidir=DIR dvi documentation [DOCDIR]--pdfdir=DIR pdf documentation [DOCDIR]--psdir=DIR ps documentation [DOCDIR]Program names:--program-prefix=PREFIX prepend PREFIX to installed program names--program-suffix=SUFFIX append SUFFIX to installed program names--program-transform-name=PROGRAM run sed PROGRAM on installed program namesSystem types:--build=BUILD configure for building on BUILD [guessed]--host=HOST cross-compile to build programs to run on HOST [BUILD]Optional Features:--disable-option-checking ignore unrecognized --enable/--with options--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)--enable-FEATURE[=ARG] include FEATURE [ARG=yes]--enable-dependency-trackingdo not reject slow dependency extractors--disable-dependency-trackingspeeds up one-time build--enable-gcc-warnings enable verbose warnings with GCC--disable-thread-supportdisable support for threading--disable-malloc-replacementdisable support for replacing the memory mgtfunctions--disable-openssl disable support for openssl encryption--disable-debug-mode disable support for running in debug mode--disable-libevent-install, disable installation of libevent--disable-libevent-regress, skip regress in make check--enable-function-sections, make static library allow smaller binaries with --gc-sections--enable-shared[=PKGS] build shared libraries [default=yes]--enable-static[=PKGS] build static libraries [default=yes]--enable-fast-install[=PKGS]optimize for fast installation [default=yes]--disable-libtool-lock avoid locking (might break parallel builds)Optional Packages:--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=useboth]--with-gnu-ld assume the C compiler uses GNU ld [default=no]--with-sysroot=DIR Search for dependent libraries within DIR(or the compiler's sysroot if not specified). Some influential environment variables:CC C compiler commandCFLAGS C compiler flagsLDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in anonstandard directory <lib dir>LIBS libraries to pass to the linker, e.g. -l<library>CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> ifyou have headers in a nonstandard directory <include dir>CPP C preprocessorUse these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations.Report bugs to the package provider. Installation directories:--prefix=PREFIX install architecture-independent files in PREFIX[/usr/local]--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, `make install' will install all the files in `/usr/local/bin', `/usr/local/lib' etc. You can specify an installation prefix other than `/usr/local' using `--prefix', for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include]

所以我們可以如此的在configure時(shí)指定路徑:
[root@localhost libevent]# ./configure --libdir=/usr/lib

3) 修改環(huán)境變量 LD_LIBRARY_PATH,將/usr/local/lib 包含進(jìn)去。但是該方法一般不推薦這樣做(但是有一種變通的做法,具體參見(jiàn)總結(jié)中的 3>)。

---------------------------------------------------------------------------------------------------------

總結(jié):

1. 和共享庫(kù)相關(guān)的一些錯(cuò)誤如何處理:

1> LD_DEBUG 命令:

LD_DEBUG 是 glibc 中的 loader 為了方便自身調(diào)試而設(shè)置的一個(gè)環(huán)境變量。通過(guò)設(shè)置這個(gè)環(huán)境變量,可以方便的看到 loader 的加載過(guò)程。

[root@localhost libevent]# LD_DEBUG=help ls Valid options for the LD_DEBUG environment variable are:libs display library search pathsreloc display relocation processingfiles display progress for input filesymbols display symbol table processingbindings display information about symbol bindingversions display version dependenciesall all previous options combinedstatistics display relocation statisticsunused determined unused DSOshelp display this help message and exitTo direct the debugging output into a file instead of standard output a filename can be specified using the LD_DEBUG_OUTPUT environment variable.

上面列出了 LD_DEBUG 所有的選項(xiàng),上面我們就使用了 LD_DEBUG=libs 。使用該命令可以獲取很多有用的信息。

2> ldd - print shared library dependencies 打印輸出依賴(lài)庫(kù)

3> LD_LIBRARY_PATH, /etc/ld.so.conf.d,ldconfig

???? 因?yàn)檫B接器會(huì)到目錄 /etc/ld.so.conf.d 下面去尋找 配置了 共享庫(kù) 的目錄,所以根據(jù)這個(gè)原理,我們可以為 /usr/local/lib 專(zhuān)門(mén)建立一個(gè)配置文件

???? 加入到連接器尋找 共享庫(kù) 的目錄列表中:

[root@localhost ld.so.conf.d]# pwd /etc/ld.so.conf.d [root@localhost ld.so.conf.d]# ls kernel-2.6.32-504.el6.i686.conf mysql-i386.conf qt-i386.conf xulrunner-32.conf [root@localhost ld.so.conf.d]# echo "/usr/local/lib" > usr_local_lib.conf [root@localhost ld.so.conf.d]# ll total 20 -r--r--r--. 1 root root 324 Oct 15 2014 kernel-2.6.32-504.el6.i686.conf -rw-r--r--. 1 root root 15 Feb 13 2014 mysql-i386.conf -rw-r--r--. 1 root root 20 Sep 24 2011 qt-i386.conf -rw-r--r--. 1 root root 15 Sep 13 08:51 usr_local_lib.conf -rw-r--r--. 1 root root 19 Oct 30 2013 xulrunner-32.conf [root@localhost ld.so.conf.d]# cat usr_local_lib.conf /usr/local/lib [root@localhost ld.so.conf.d]# ldconfig

這樣以后 /usr/local/lib 中的共享庫(kù)就會(huì)被連接器尋找到,注意修改連接器相關(guān)的配置之后,一定要用 ldconfig 命令更新一下,不然還是找不到。???

4>?ln -s /usr/local/lib/libevent.so /usr/lib/libevent-2.0.so.5 建立一個(gè)軟連接

推薦方法:4 和 3。

2. 如何尋找文件,庫(kù)等:

whereis - locate the binary, source, and manual page files for a command

updatedb - update a database for locate

locate - find files by name

find 命令 find - search for files in a directory hierarchy

示例: whereis libevent, updatedb, locate libevent,

find / -name libevent.*

[root@localhost bin]# find /usr/local -name libevent.* /usr/local/redis-3.0.3/deps/hiredis/adapters/libevent.h /usr/local/src/libevent/libevent.pc.in /usr/local/src/libevent/libevent.pc /usr/local/lib/libevent.la /usr/local/lib/libevent.a /usr/local/lib/pkgconfig/libevent.pc /usr/local/lib/libevent.so

[root@localhost bin]# find / -name libevent.so
/usr/local/lib/libevent.so
[root@localhost bin]# find / -name libevent.so*
/usr/local/lib/libevent.so

find 命令 第一個(gè)參數(shù)是查找的路徑 /usr/local 第二個(gè)參數(shù)是要查找的文件名的表達(dá)式,可以使用正則表達(dá)式來(lái)表示查找的文件名。

find 還有一個(gè)常見(jiàn)的用法:對(duì)找到的文件執(zhí)行某個(gè)命令:

find . -name \*.lo -o -name \*.o | xargs rm -f??? (xargs - build and execute command lines from standard input)

3. configure 之前一定要 configure --help 查看配置選項(xiàng)。

轉(zhuǎn)載于:https://www.cnblogs.com/digdeep/p/4801467.html

總結(jié)

以上是生活随笔為你收集整理的Linux 下编译安装软件,找不到共享库 xx.so 的解决办法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 一本大道av | 色www情| 少妇高潮惨叫久久久久 | 国产视频在线观看免费 | 91人人视频 | 亚洲激情黄色 | 亚州福利 | 亚洲av乱码一区二区 | 大地资源中文在线观看免费版 | 久久久久久无码午夜精品直播 | 99国产精品久久久久久久 | 中文在线日韩 | 欧美视频日韩 | 免费看毛片网站 | 成人拍拍视频 | 污视频在线网站 | 亚洲第一自拍 | 成年人在线视频网站 | 欧美成人国产 | 影音先锋国产资源 | 极品美妇后花庭翘臀娇吟小说 | 青娱乐超碰在线 | 久久久久久久无码 | 日韩欧美一区二区三区免费观看 | 国语对白做受69按摩 | 丁香激情小说 | 漂亮人妻被黑人久久精品 | 成年人视频网址 | 九热精品视频 | 先锋影音av在线资源 | 亚洲天堂手机在线 | 成人黄色免费观看 | 夫妻淫语绿帽对白 | 国产精品人人爽 | 免费精品一区二区 | 亚洲91精品 | 日韩一级黄色 | 色吧av| 午夜精品久久久久久99热 | 91宅男| wwww欧美| 免费播放毛片精品视频 | 欧美日韩第一页 | 欧美做受69| 中文字幕免费一区二区 | 天堂在线免费观看 | 青青草免费在线视频 | 成av在线| 色一情一乱一乱一区91av | 超碰在线91 | 欧美激情亚洲色图 | av番号网| 深爱开心激情 | 黄瓜视频在线免费观看 | 亚洲国产日韩在线 | 午夜少妇视频 | 性av在线| 欧美肥妇bwbwbwbxx | 青青草伊人网 | 欧美三级电影在线观看 | 欧美第二页 | 久久精品在线 | 国产男女猛烈无遮挡a片漫画 | 色综合中文网 | 亚洲大尺度在线观看 | 国产精品日韩精品 | 波多野吉衣在线观看视频 | 日韩中文字幕 | yjizz国产| 国产三区av| 一二三av | 欧美人妻精品一区二区免费看 | 精品一二三 | 日本啪啪啪一区二区 | 看个毛片 | 秋霞成人午夜鲁丝一区二区三区 | 插插插操操操 | 中国女人av | 欧美性色网站 | 玩偶游戏在线观看免费 | 北条麻妃99精品青青久久 | 又黄又爽视频在线观看 | 徐锦江一级淫片免费看 | 国产精品96 | 福利一区在线观看 | wwwjavhd| 黄色精品一区二区 | 亚洲精品视频在线观看免费 | 国产视频二区 | 亚洲4438 | 中文字幕一区三区 | 手机看片在线观看 | 国产天堂久久 | 日本中文字幕网 | 精品人妻一区二区三区麻豆91 | wwwav视频 | 中文国语毛片高清视频 | 欧美粗大猛烈老熟妇 | 日韩a视频 |