如何在linux中设置环境变量LD 您所在的位置:网站首页 path环境变量配置 如何在linux中设置环境变量LD

如何在linux中设置环境变量LD

2023-05-20 00:15| 来源: 网络整理| 查看: 265

In Ubuntu 20.04Linux就是不明显,也不像它应该的那样直接。

我将试图让那些像我一样正在拉扯头发的人简单地了解一下我的情况。Ubuntu 20.04.3 Linux.

首先要确定你的库文件的文件夹所在的路径。在我的例子中,*.so我正在处理的文件位于一个名为libs而这个文件夹在我的Ubuntu盒子里的路径是/usr/lib

所以现在我想添加路径/usr/lib to ld_library_path这样,当我运行echo $ld_library_path在我的Ubuntu终端,我将能够看到路径/usr/lib如下图所示,有回音。

joseph$ echo $LD_LIBRARY_PATH :/usr/lib

以下是我使用的步骤

Open terminal in Ubuntu 20.04 Linux box Change path to /etc/ld.so.conf.d/ by running cd /etc/ld.so.conf.d/ Create a file with a *.conf extension at the end with a text editor like e.g. vim or gedit in my case I created it as follows sudo gedit my_project_libs.conf Inside the .conf file that I created named my_project_libs.conf I added the path to my libs by adding this line export ld_library_path=$ld_library_path:/usr/lib Thereafter, I then run gedit ~/.bash_profile to open the ~/.bash_profile file so that I can add inside it this line export ld_library_path=$ld_library_path:/usr/lib which includes the path to the folder with my libraries /usr/lib that I want included in ld_library_path I also ran gedit ~/.bashrc to open the ~/.bashrc file so that I can add inside it this line export ld_library_path=$ld_library_path:/usr/lib which includes the path to the folder with my libraries /usr/lib that I want included in ld_library_path When you are done adding the line in step 5, save and close. In your terminal, type the following sudo ldconfig and press enter on your keyboard. Close all your open terminals that you were using then open a new terminal session and run echo $ld_library_path If you see the path you added is echoed back, you did it right.

在我的案例中,我看到的情况是这样的:/usr/lib when I run echo $ld_library_path在我新打开的Ubuntu终端会话中

joseph$ echo $LD_LIBRARY_PATH :/usr/lib

这就是我如何让它在我的工作中发挥作用的原因。Ubuntu 20.04.3 Linux box.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有