MacOS dlopen search path does not add .dylib extension using gcc/ld

33 views Asked by At

I have a dylib that loads my other dylib on Mac but the search path is correct but it is without extension.

Here is an example:

hmodule = dlopen(str, RTLD_NOW);

I get an error:

dlopen(@rpath/libtestx.dylib, 0x0002): Library not loaded: libtestx
  Referenced from: <58F0B046-B8BD-3821-8A7F-E269C121E72F> /Users/user/.dev/lib64/libtest.dylib
  Reason: tried: '/Users/user/sqllib/lib/libtestx' (no such file), '/Users/user/.dev/lib64/libtestx' (no such file), 'libtestx' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibtestx' (no such file),  '/Users/user/sqllib/lib/libtestx' (no such file), '/Users/user/Documents/GitHub/main/libtestx' (no such file)

Libray is there but is in /Users/user/.dev/lib64/libtestx.dylib if I add a symlink to it without extension then it works.

ln -s ~/.dev/lib64/libtestx.dylib ~/.dev/lib64/libtestx

Does someone know how to fix this?

I have tried to add a double dlopen("@rpath/libtestx.dylib.dylib", RTLD_NOW) but it did not fix the problem.

0

There are 0 answers