2

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.

Toribio
  • 3,963
  • 3
  • 34
  • 48
SilverSurfer
  • 656
  • 1
  • 6
  • 23
  • Is "libsystemc-2.3.0.so" present in /usr/lib ? – Pavel Ognev Sep 13 '12 at 14:49
  • No. "libsystemc-2.3.0.so" is at /usr/local/systemc-2.3.0/lib-linux64 – SilverSurfer Sep 13 '12 at 15:03
  • So, is this path contained in $PATH environment variable? If not, try to make link to this library in /usr/lib: `ln -s /usr/local/systemc-2.3.0/lib-linux64/libsystemc-2.3.0.so /usr/lib/libsystemc-2.3.0.so` – Pavel Ognev Sep 13 '12 at 15:37
  • I am sorry but I don't know what is PATH variable. Well, I pasted the command in terminal but still I am unable to run the program. I forgot to mention that I am able to build the program however I am unable to run it. – SilverSurfer Sep 13 '12 at 17:07
  • 1) Environment variables are the same as in MS Windows. Type `echo $PATH` in terminal to see the PATH's content. 2) You cannot link this library without root privileges. – Pavel Ognev Sep 13 '12 at 18:32

5 Answers5

7

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

jclin
  • 2,449
  • 1
  • 21
  • 27
1

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.

Devolus
  • 21,661
  • 13
  • 66
  • 113
Jeremy Gu
  • 11
  • 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

Pvs
  • 11
  • 1
0

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

Chintan Patel
  • 173
  • 3
  • 14
0

Try to move libsystemc-2.3.0.so to the default library directory by accessing to directory where libsystemc-2.3.1.so exists, open the terminal and run: sudo cp libsystemc-2.3.0.so /lib This worked well in my case

Liza bb8
  • 3
  • 5