加载共享库时出错:libsystemc-2.3.0.so

时间:2022-05-08 13:27:50

I am a new user to Linux and I am trying to install systemc-2.3.0 library on my machine (Fedora 16). I have followed every instructions very carefully, mentioned in the INSTALL file of the library but I am getting an error when I am trying to run a simple program using ECLIPSE. I have linked all the libraries correctly in ECLIPSE but still I am getting an error.

我是Linux的新用户,我正在尝试在我的机器上安装systemc-2.3.0库(Fedora 16)。我已经非常仔细地遵循了每一个指令,在库的安装文件中提到了,但是当我试图使用ECLIPSE运行一个简单的程序时,我就犯了一个错误。我已经在ECLIPSE中正确地链接了所有库,但是我仍然得到一个错误。

The program is as follows:

程序如下:

#include <systemc.h>

using namespace std;

int sc_main(int argc, char * argv[])
{
    cout << "hello world" << endl;

    for(int i=0; i<argc; i++)
        cout << argv[i] << " ";

    cout << endl;
    return 0;
}

And the error output is:

误差输出为:

/home/vivek/workspace/TestSystemC/Debug/TestSystemC: error while loading shared libraries: libsystemc-2.3.0.so: cannot open shared object file: No such file or directory

/home/vivek/workspace/TestSystemC/Debug/TestSystemC:加载共享库时出错:libsystemc-2.3.0。无法打开共享对象文件:没有这样的文件或目录

Any help will be highly appreciated. Please explain your suggestions in an elaborative manner (step by step) as I am not an Linux expert.

非常感谢您的帮助。请详细解释您的建议(一步一步),因为我不是Linux专家。

Thank you.

谢谢你!

4 个解决方案

#1


4  

This is a environment setting issue for dynamic linking, because the shared library is installed outside of the system default library directories. When you execute the binary, the loader failed to find libsystemc-2.3.0.so.

这是动态链接的环境设置问题,因为共享库安装在系统默认库目录之外。执行二进制文件时,加载程序未能找到libsystemc-2.3.0.so。

Two solutions.

两种解决方案。

  1. setting your LD_LIBRARY_PATH.

    你LD_LIBRARY_PATH设置。

    export LD_LIBRARY_PATH=/usr/local/systemc-2.3.0/lib-linux64:$LD_LIBRARY_PATH

    出口LD_LIBRARY_PATH = / usr /地方/ systemc-2.3.0 / lib-linux64:LD_LIBRARY_PATH美元

    or, if your default LD_LIBRARY_PATH is empty

    或者,如果您的默认LD_LIBRARY_PATH是空的

    export LD_LIBRARY_PATH=/usr/local/systemc-2.3.0/lib-linux64

    出口LD_LIBRARY_PATH = / usr /地方/ systemc-2.3.0 / lib-linux64

  2. adding rpath to the executable when linking the binary. It adds an entry to the binary and hints the loader to search additional path.

    在链接二进制文件时向可执行文件添加rpath。它向二进制文件添加一个条目,并提示加载程序搜索其他路径。

    g++ -o TestSystemC ...your c++ files... -L/usr/local/systemc-2.3.0/lib-linux64 -lsystemc-2.3.0 -Wl,-rpath,/usr/local/systemc-2.3.0/lib-linux64

    g++ - o TestSystemC……你的c++文件…- l / usr /地方/ systemc-2.3.0 / lib-linux64 -lsystemc-2.3.0 - wl,rpath、/ usr /地方/ systemc-2.3.0 / lib-linux64

#2


0  

Yep! Infact, for all such errors reported, the missing thing is that the user has not or forgot to set the LD_LIBRARY_PATH

是的!事实上,对于报告的所有此类错误,缺少的是用户没有或忘记设置LD_LIBRARY_PATH

#3


0  

you can Set in eclipse linker setting-> miscellaneous -> -Wl,-rpath,your_lib_path

您可以在eclipse链接器设置中设置->杂项-> - wl、-rpath、your_lib_path

#4


0  

I append two lines at the end of ~/.profile as following:

我在~/结尾加了两行。配置文件如下:

export SYSTEMC_HOME=/usr/local/systemc-2.3.0/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/systemc-2.3.0/lib-linux64

And if this doesn't work, you can try to add two softlinks (i.e. lib->lib-linux64/ and lib-linux -> lib-linux) in the top level directory of systemc-2.3.0 as you have installed (e.g. my path is /usr/local/systemc-2.3.0/). The corresponding commands are as following

如果这不起作用,您可以尝试在systemc-2.3.0的顶层目录中添加两个软链接(即lib->lib-linux64/和lib-linux ->lib-linux)(例如,我的路径是/usr/local/systemc-2.3.0/)。相应的命令如下

(change your current directory to $SYSTEMC_HOME directory):

(将当前目录更改为$SYSTEMC_HOME目录):

$ln -s /usr/local/systemc-2.3.0 lib
$ln -s /usr/local/systemc-2.3.0  lib-linux

Maybe lib-linux64 supports to Operation System with 64bit, and lib or lib->linux supports to Operation System with 32bit.

也许lib-linux64支持64位操作系统,lib或lib->linux支持32位操作系统。

#1


4  

This is a environment setting issue for dynamic linking, because the shared library is installed outside of the system default library directories. When you execute the binary, the loader failed to find libsystemc-2.3.0.so.

这是动态链接的环境设置问题,因为共享库安装在系统默认库目录之外。执行二进制文件时,加载程序未能找到libsystemc-2.3.0.so。

Two solutions.

两种解决方案。

  1. setting your LD_LIBRARY_PATH.

    你LD_LIBRARY_PATH设置。

    export LD_LIBRARY_PATH=/usr/local/systemc-2.3.0/lib-linux64:$LD_LIBRARY_PATH

    出口LD_LIBRARY_PATH = / usr /地方/ systemc-2.3.0 / lib-linux64:LD_LIBRARY_PATH美元

    or, if your default LD_LIBRARY_PATH is empty

    或者,如果您的默认LD_LIBRARY_PATH是空的

    export LD_LIBRARY_PATH=/usr/local/systemc-2.3.0/lib-linux64

    出口LD_LIBRARY_PATH = / usr /地方/ systemc-2.3.0 / lib-linux64

  2. adding rpath to the executable when linking the binary. It adds an entry to the binary and hints the loader to search additional path.

    在链接二进制文件时向可执行文件添加rpath。它向二进制文件添加一个条目,并提示加载程序搜索其他路径。

    g++ -o TestSystemC ...your c++ files... -L/usr/local/systemc-2.3.0/lib-linux64 -lsystemc-2.3.0 -Wl,-rpath,/usr/local/systemc-2.3.0/lib-linux64

    g++ - o TestSystemC……你的c++文件…- l / usr /地方/ systemc-2.3.0 / lib-linux64 -lsystemc-2.3.0 - wl,rpath、/ usr /地方/ systemc-2.3.0 / lib-linux64

#2


0  

Yep! Infact, for all such errors reported, the missing thing is that the user has not or forgot to set the LD_LIBRARY_PATH

是的!事实上,对于报告的所有此类错误,缺少的是用户没有或忘记设置LD_LIBRARY_PATH

#3


0  

you can Set in eclipse linker setting-> miscellaneous -> -Wl,-rpath,your_lib_path

您可以在eclipse链接器设置中设置->杂项-> - wl、-rpath、your_lib_path

#4


0  

I append two lines at the end of ~/.profile as following:

我在~/结尾加了两行。配置文件如下:

export SYSTEMC_HOME=/usr/local/systemc-2.3.0/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/systemc-2.3.0/lib-linux64

And if this doesn't work, you can try to add two softlinks (i.e. lib->lib-linux64/ and lib-linux -> lib-linux) in the top level directory of systemc-2.3.0 as you have installed (e.g. my path is /usr/local/systemc-2.3.0/). The corresponding commands are as following

如果这不起作用,您可以尝试在systemc-2.3.0的顶层目录中添加两个软链接(即lib->lib-linux64/和lib-linux ->lib-linux)(例如,我的路径是/usr/local/systemc-2.3.0/)。相应的命令如下

(change your current directory to $SYSTEMC_HOME directory):

(将当前目录更改为$SYSTEMC_HOME目录):

$ln -s /usr/local/systemc-2.3.0 lib
$ln -s /usr/local/systemc-2.3.0  lib-linux

Maybe lib-linux64 supports to Operation System with 64bit, and lib or lib->linux supports to Operation System with 32bit.

也许lib-linux64支持64位操作系统,lib或lib->linux支持32位操作系统。