Question

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.

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

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

Thank you.

Was it helpful?

Solution

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.

Two solutions.

  1. setting your LD_LIBRARY_PATH.

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

    or, if your default LD_LIBRARY_PATH is empty

    export LD_LIBRARY_PATH=/usr/local/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.

    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

OTHER TIPS

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

(change your current directory to $SYSTEMC_HOME directory):

$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.

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top