Problem linking with C shared library on linux

having troubles linking files on linux:

  = note: ld.lld: error: unable to find library -llibfmodL
          ld.lld: error: unable to find library -llibfmodstudioL
          collect2: error: ld returned 1 exit status
    #[cfg(all(not(feature = "debug"), target_os = "linux"))]

    #[cfg(all(feature = "debug", target_os = "linux"))]

    #[cfg(all(feature = "studio", feature = "debug", target_os = "linux"))]

    #[cfg(all(feature = "studio", not(feature = "debug"), target_os = "linux"))]

it works on windows just fine

  hecs //crate
  fmod-sys //crate(also contains duplicates and etc)
  fmod.dll //windows only dlls

it links fine on windows though... all the lib files are in the root of the project..... idk why it cant find it... when it can on windows. On this note, the FMOD sound library comes with .libs and .dlls while the linux ones comes with only .so.12.11 files and .so being a symbolic link to those so i just renamed the .so.12.11 ones.

Here is the minimum reproducible case

The lib prefix is implied on linux. Change your printlns to cargo:rustc-link-lib=fmod etc.

Alright I removed them and it still couldn't find it. I tried uncommenting:

    let dir = env::var("CARGO_MANIFEST_DIR").unwrap();

    println!("cargo:rustc-link-search={}", dir);

and now it's saying:

target/debug/fmod_linking_test: error while loading shared libraries: cannot open shared object file: No such file or directory

I don't know why but fmod included these as symbolic links

lrwxrwxrwx   16 a  8 Aug 18:06 ->
lrwxrwxrwx   16 a  8 Aug 18:06 ->
.rwxrwxrwx 1.6M a  8 Aug  9:31
.rwxrwxrwx 1.9M a  8 Aug  9:31
lrwxrwxrwx   22 a  8 Aug 18:06 ->
lrwxrwxrwx   22 a  8 Aug 18:06 ->
.rwxrwxrwx 1.6M a  8 Aug  9:31
lrwxrwxrwx   23 a  8 Aug 18:06 ->
lrwxrwxrwx   23 a  8 Aug 18:06 ->
.rwxrwxrwx 2.4M a  8 Aug  9:31

I tried getting rid of the symbolic link files and just renaming the files it points to, to the said thing but it still no luck..

I think you're linking/compiling fine now, and that's a runtime error, in the loader

Your issue seems similar/the same as Call functions from a relative path - #2 by Yandros and Linking Rust application with a dynamic library not in the runtime linker search path - Stack Overflow

Either set the LD_LIBRARY_PATH, use an rpath, or put the .so dylibs in a folder already in your loader's search path


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.