You are not logged in.

#1 2014-08-04 02:11:37

kamz
Member
Registered: 2008-06-04
Posts: 9

[SOLVED] GCC multilib: cannot find shared library

Hi,

I'm trying to compile a systemc program to a 32-bit executable on arch x86_64.  I'm using GCC multilib.  Program compiles fine, but I get the following error when trying to run.

/home/[myusername]/workspace/systemc_test/Debug/systemc_test: error while loading shared libraries: libsystemc-2.3.1.so: cannot open shared object file: No such file or directory

Compiler:

g++ -std=c++0x -DSC_INCLUDE_DYNAMIC_PROCESSES -I/usr/local/systemc/include -O0 -g3 -Wall -c -fmessage-length=0 -m32 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"

Linker:

g++ -L/usr/local/systemc/lib-linux -m32 -o "systemc_test"  ./main.o   -lsystemc

ls /usr/local/systemc/lib-linux/

libsystemc-2.3.1.so  libsystemc.a  libsystemc.la  libsystemc.so  pkgconfig

What am I doing wrong?  For the record, this works fine on Ubuntu (64-bit with multilib) using the same version of the systemc library, compiled and installed in exactly the same manner.

Thanks!

Last edited by kamz (2014-08-04 02:38:02)

Offline

#2 2014-08-04 02:18:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: [SOLVED] GCC multilib: cannot find shared library

I'm not sure ldd/ld.so will find libs under /usr/local/lib-linux by default.  Have you added that path to LD_LIBRARY_PATH?

What does `ldd systemc_test` return?

Last edited by Trilby (2014-08-04 02:19:52)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2014-08-04 02:35:33

kamz
Member
Registered: 2008-06-04
Posts: 9

Re: [SOLVED] GCC multilib: cannot find shared library

You're correct -- doesn't find that path.

ldd systemc_test

linux-gate.so.1 (0xf77ac000)
    libsystemc-2.3.1.so => not found
    libstdc++.so.6 => /usr/lib32/libstdc++.so.6 (0xf768f000)
    libm.so.6 => /usr/lib32/libm.so.6 (0xf7643000)
    libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf7628000)
    libc.so.6 => /usr/lib32/libc.so.6 (0xf7465000)
    /lib/ld-linux.so.2 (0xf77ad000)

Adding /usr/local/systemc/lib-linux to LD_LIBRARY_PATH solves the problem.  I used a script under /etc/profile.d/ to set this at session start, so I now consider this solved.  Out of curiousity, is it possible to avoid having to do this?

Offline

#4 2014-08-04 02:49:07

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,557

Re: [SOLVED] GCC multilib: cannot find shared library

/etc/ld.so.conf.d/ is a better way of adding something to your library path.

Offline

#5 2014-08-04 02:57:02

kamz
Member
Registered: 2008-06-04
Posts: 9

Re: [SOLVED] GCC multilib: cannot find shared library

Correct -- thanks!

EDIT:
Just in case anyone needs this:

create a file with .conf extension under /etc/ld.so.conf.d/ -- the file should contain the path to the directory in which the library is located
run ldconfig as root

Last edited by kamz (2014-08-04 03:17:06)

Offline

#6 2014-08-04 11:27:25

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,525
Website

Re: [SOLVED] GCC multilib: cannot find shared library

Thanks scimmia - I've never had to do this, so while I could see the problem I was flailing for a solution and found the environment variable in the ld.so man page.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB