久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

未找到/usr/local/lib 中的庫

Libraries in /usr/local/lib not found(未找到/usr/local/lib 中的庫)
本文介紹了未找到/usr/local/lib 中的庫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在使用名為 ohNet 的框架構建應用程序.構建框架后,可以通過 make install 安裝框架.默認情況下,這些庫安裝在 /usr/local/[lib|include] 文件夾中.好的.

我正在使用 Eclipse 進行開發.為了使用這個庫,我必須設置庫的包含路徑(在本例中為 usr/local/include/ohNet),設置鏈接器搜索路徑 (-L)(/usr/local/lib/ohNet) 和特定的庫 (-l).當我在 Eclipse 中構建項目時,它工作正常,但是如果我嘗試運行該程序,我將面臨以下消息:

加載共享庫時出錯:libohNet.so:無法打開共享對象文件:沒有這樣的文件或目錄

我已經仔細檢查過,文件 libohNet.so 就在這個目錄中!找不到這個文件是什么原因?

我在google上搜索,發現一些帖子,說庫安裝到/usr/local/lib而不是/usr/lib是有問題的看這里 ...我是否必須在 eclipse 中配置一些其他設置以使 ld 識別此路徑中的庫?有什么辦法解決這個問題?

問候

解決方案

這是運行時錯誤,不是構建錯誤.設置 -L 標志對運行時鏈接器沒有任何作用.您需要做的是告訴運行時加載程序也在/usr/local/lib 中查找庫.你可以通過兩種方式做到這一點.首先是添加LD_LIBRARY_PATH環境變量的路徑:

<上一頁>導出 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"

二是更新運行時鏈接器的配置文件.這可以在/etc/ld.so.conf 文件中發生,方法是:

<上一頁>/usr/local/lib

在該文件的某個位置,或者通過在包含新路徑的/etc/ld.so.conf.d/目錄中創建一個新的 *.conf 文件.例如:

<上一頁>/etc/ld.so.conf.d/99local.conf

只需:

<上一頁>/usr/local/lib

在里面.這是這樣做的推薦方式,因為它允許您將自定義庫路徑與系統設置的路徑分開.(99"前綴是為了確保文件與那里的其他文件相比最后加載,這樣它就不會搶占可能包含相同庫的系統路徑.)

在/etc中修改/創建文件后,需要運行:

<上一頁>配置文件

以 root 身份使更改生效.(此命令更新/etc/ld.so.cache 文件,這是運行時鏈接器使用的實際文件.)

二進制文件還有另一種方法可以在運行時找到所需的庫.您實際上可以將庫路徑硬編碼到可執行文件本身中.這是通過設置所謂的rpath"來實現的.這是一個鏈接器選項,必須從 gcc(或 g++)傳遞到鏈接器,因此必須使用 -Wl 選項.鏈接器選項是 -rpath=PATH.因此,您需要將其添加到您的鏈接標志中:

<上一頁>-Wl,-rpath=/usr/local/lib

不過,我不建議您這樣做.當您將庫與可執行文件(可能帶有安裝程序)以及相對 rpath(使用 rpath $ORIGIN 功能)或絕對路徑(當您安裝在/opt,例如)然后用于在運行時查找那些捆綁的庫.

I am building an application using a framework called ohNet. After building the framework, there is the possibility to install the framework via make install. By default the libraries are installed inside the /usr/local/[lib|include] folders. ok.

I am using eclipse for development. In order to use this libraries I have to set the include path to the library (in this case usr/local/include/ohNet), set the Linker search path (-L)(/usr/local/lib/ohNet) and specific libraries (-l) (in this case i choose a library called libohNet.so which is in this folder. When I build the project in eclipse it works fine, however if i try to run the programm i am faced with the following message:

error while loading shared libraries: libohNet.so: cannot open shared object file: No such file or directory

I've double checked this, and the file libohNet.so is in this directory! What's the reason that this file cannot be found?

I searched on google and found some posts, saying that it is problematic that libraries are getting installed into /usr/local/lib instead of /usr/lib see here ... Do I have to configure some additional settings in eclipse to make ld recognize libraries in this path? What's the solution for this?

regards

解決方案

This is a runtime error, not a build error. Setting the -L flag does nothing for the runtime linker. What you need to do is to tell the runtime loader to also look in /usr/local/lib for libraries. You can do that in two ways. The first is to add the path to the LD_LIBRARY_PATH environment variable:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"

The second is to update the configuration file of the runtime linker. This can happen either in the /etc/ld.so.conf file, by putting the line:

/usr/local/lib

somewhere in that file, or by creating a new *.conf file in the /etc/ld.so.conf.d/ directory that contains the new path. For example:

/etc/ld.so.conf.d/99local.conf

with just:

/usr/local/lib

in it. This is the recommended way of doing this, as it allows you to keep your custom library paths separate from paths set by the system. (The "99" prefix is there to make sure the file is loaded last compared to other files there, so that it won't preempt system paths that could contain the same libraries.)

After you modify/create the file in /etc, you need to run:

ldconfig

as root for the change to take effect. (This command updates the /etc/ld.so.cache file, which is the actual file used by the runtime linker.)

There's also another way for a binary to find needed libraries at runtime. You can actually hard-code library paths into the executable itself. This is accomplished by setting a so called "rpath". This is a linker option and must be passed from gcc (or g++) to the linker, so the -Wl option has to be used. The linker option is -rpath=PATH. So you would need to add this to your link flags:

-Wl,-rpath=/usr/local/lib

I don't recommend this for your case though. An rpath is useful when you're shipping libraries together with your executable (maybe with an installer), and a relative rpath (using the rpath $ORIGIN feature) or absolute one (for when you install in /opt, for example) is then used to find those bundled libs at runtime.

這篇關于未找到/usr/local/lib 中的庫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I make a horizontal sliding calendar in android eclipse?(如何在 android eclipse 中制作水平滑動日歷?)
Eclipse CDT not building project on header file change(Eclipse CDT 沒有在頭文件更改時構建項目)
Eclipse C++ including header file from my source folder(Eclipse C++ 包括來自我的源文件夾的頭文件)
Eclipse C/C++ (CDT) import files into project - header file not found - include path(Eclipse C/C++ (CDT) 將文件導入項目 - 找不到頭文件 - 包含路徑)
How to generate JNI header file in Eclipse(如何在 Eclipse 中生成 JNI 頭文件)
Compiler flags in Eclipse(Eclipse 中的編譯器標志)
主站蜘蛛池模板: 特黄毛片 | 亚洲 精品 综合 精品 自拍 | 91爱啪啪 | 九九在线视频 | 91tv在线观看 | av在线免费观看网站 | 国产成人一区在线 | 精品国产99 | 久久久成人精品 | 狠狠狠色丁香婷婷综合久久五月 | 日韩中文在线视频 | 国产精品久久久久久久久久三级 | 亚洲精品一区二三区不卡 | 国产成人精品久久 | 欧美一区2区三区4区公司二百 | 欧美成年网站 | 天堂成人国产精品一区 | 日韩一二区 | 中文字幕欧美一区 | 久久久久久久国产精品影院 | 91短视频网址 | 国产成人综合在线 | 日韩有码一区 | 中文字幕一区二区三区乱码图片 | 涩涩导航 | 成人久草 | 成人欧美一区二区三区在线观看 | 亚洲精品一区二区在线观看 | 狠狠入ady亚洲精品经典电影 | 免费高潮视频95在线观看网站 | 一级一级一级毛片 | 在线免费观看a级片 | 日韩毛片免费视频 | 国产精品一级在线观看 | 久久综合一区二区三区 | 国产精品成人一区二区三区 | 欧美日韩成人影院 | 国产精品日韩 | 大象视频一区二区 | 亚洲国产精品成人无久久精品 | 亚洲在线免费 |