pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

問題描述

限時(shí)送ChatGPT賬號..

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

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

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

我已經(jīng)仔細(xì)檢查過,文件 libohNet.so 就在這個(gè)目錄中!找不到這個(gè)文件是什么原因?

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

問候

解決方案

這是運(yùn)行時(shí)錯(cuò)誤,不是構(gòu)建錯(cuò)誤.設(shè)置 -L 標(biāo)志對運(yùn)行時(shí)鏈接器沒有任何作用.您需要做的是告訴運(yùn)行時(shí)加載程序也在/usr/local/lib 中查找?guī)?你可以通過兩種方式做到這一點(diǎn).首先是添加LD_LIBRARY_PATH環(huán)境變量的路徑:

<上一頁>導(dǎo)出 LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"

二是更新運(yùn)行時(shí)鏈接器的配置文件.這可以在/etc/ld.so.conf 文件中發(fā)生,方法是:

<上一頁>/usr/local/lib

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

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

只需:

<上一頁>/usr/local/lib

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

在/etc中修改/創(chuàng)建文件后,需要運(yùn)行:

<上一頁>配置文件

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

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

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

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

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.

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

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

相關(guān)文檔推薦

How can I make a horizontal sliding calendar in android eclipse?(如何在 android eclipse 中制作水平滑動(dòng)日歷?)
Eclipse CDT not building project on header file change(Eclipse CDT 沒有在頭文件更改時(shí)構(gòu)建項(xiàng)目)
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) 將文件導(dǎo)入項(xiàng)目 - 找不到頭文件 - 包含路徑)
How to generate JNI header file in Eclipse(如何在 Eclipse 中生成 JNI 頭文件)
Compiler flags in Eclipse(Eclipse 中的編譯器標(biāo)志)
主站蜘蛛池模板: 小型高低温循环试验箱-可程式高低温湿热交变试验箱-东莞市拓德环境测试设备有限公司 | 蜘蛛车-高空作业平台-升降机-高空作业车租赁-臂式伸缩臂叉装车-登高车出租厂家 - 普雷斯特机械设备(北京)有限公司 | 信阳网站建设专家-信阳时代网联-【信阳网站建设百度推广优质服务提供商】信阳网站建设|信阳网络公司|信阳网络营销推广 | 电缆接头-防爆电缆接头-格兰头-金属电缆接头-防爆填料函 | 提升海外网站流量,增加国外网站访客UV,定制海外IP-访客王 | 广州昊至泉水上乐园设备有限公司| 兰州UPS电源,兰州山特UPS-兰州万胜商贸 | 干粉砂浆设备_干混砂浆生产线_腻子粉加工设备_石膏抹灰砂浆生产成套设备厂家_干粉混合设备_砂子烘干机--郑州铭将机械设备有限公司 | 期货软件-专业期货分析软件下载-云智赢 | 气动隔膜泵-电动隔膜泵-循环热水泵-液下排污/螺杆/管道/化工泵「厂家」浙江绿邦 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 盐城网络公司_盐城网站优化_盐城网站建设_盐城市启晨网络科技有限公司 | 紧急泄压人孔_防爆阻火器_阻火呼吸阀[河北宏泽石化] | 手术室净化厂家-成都做医院净化工程的公司-四川华锐-15年特殊科室建设经验 | 齿辊分级破碎机,高低压压球机,立式双动力磨粉机-郑州长城冶金设备有限公司 | 皮带机_移动皮带机_大倾角皮带机_皮带机厂家 - 新乡市国盛机械设备有限公司 | 宁夏档案密集柜,智能密集柜,电动手摇密集柜-盛隆柜业宁夏档案密集柜厂家 | 自动部分收集器,进口无油隔膜真空泵,SPME固相微萃取头-上海楚定分析仪器有限公司 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-北京罗伦过滤技术集团有限公司 | 振动筛,震动筛,圆形振动筛,振动筛价格,振动筛厂家-新乡巨宝机电 蒸汽热收缩机_蒸汽发生器_塑封机_包膜机_封切收缩机_热收缩包装机_真空机_全自动打包机_捆扎机_封箱机-东莞市中堡智能科技有限公司 | 骨密度检测仪_骨密度分析仪_骨密度仪_动脉硬化检测仪专业生产厂家【品源医疗】 | 智能交通网_智能交通系统_ITS_交通监控_卫星导航_智能交通行业 | 范秘书_懂你的范文小秘书| 扒渣机厂家_扒渣机价格_矿用扒渣机_铣挖机_撬毛台车_襄阳永力通扒渣机公司 | 杜康白酒加盟_杜康酒代理_杜康酒招商加盟官网_杜康酒厂加盟总代理—杜康酒神全国运营中心 | 智慧钢琴-电钢琴-便携钢琴-数码钢琴-深圳市特伦斯乐器有限公司 | 斗式提升机,斗式提升机厂家-淄博宏建机械有限公司 | 水压力传感器_数字压力传感器|佛山一众传感仪器有限公司|首页 | 上海皓越真空设备有限公司官网-真空炉-真空热压烧结炉-sps放电等离子烧结炉 | atcc网站,sigma试剂价格,肿瘤细胞现货,人结肠癌细胞株购买-南京科佰生物 | 齿轮减速机电机一体机_齿轮减速箱加电机一体化-德国BOSERL蜗轮蜗杆减速机电机生产厂家 | 百度爱采购运营研究社社群-店铺托管-爱采购代运营-良言多米网络公司 | 二手回收公司_销毁处理公司_设备回收公司-找回收信息网 | 纯水设备_苏州皙全超纯水设备水处理设备生产厂家 | 京马网,京马建站,网站定制,营销型网站建设,东莞建站,东莞网站建设-首页-京马网 | 高速龙门架厂家_监控杆_多功能灯杆_信号灯杆_锂电池太阳能路灯-鑫世源照明 | 耐高温风管_耐高温软管_食品级软管_吸尘管_钢丝软管_卫生级软管_塑料波纹管-东莞市鑫翔宇软管有限公司 | 深圳工程师职称评定条件及流程_深圳职称评审_职称评审-职称网 | 都江堰招聘网-都江堰人才网 都江堰人事人才网 都江堰人才招聘网 邢台人才网_邢台招聘网_邢台123招聘【智达人才网】 | X光检测仪_食品金属异物检测机_X射线检测设备_微现检测 |