melchor629 / node-flac-bindings

Nodejs bindings to libFLAC
ISC License
17 stars 1 forks source link

library is not loaded dynamically as the doc says #2

Closed smoebody closed 7 years ago

smoebody commented 7 years ago

instead i have to provide the path to the library manually:

flac_bindings.bindings.load('/usr/lib64/libFLAC.so.8.3.0');

my system is fedora 24

melchor629 commented 7 years ago

Usually, dlopen (the function that loads the library) searches for a library that its name (in linux) is libFLAC.so. But this file you provided is not of this kind, so that's (possibly) why the library cannot load the file. Check if the package manager of fedora made a soft link from /usr/lib64/libFLAC.so.8.3.0 to /usr/lib64/libFLAC.so, or if you compiled flac, you should make the link yourself.

I tested the library loading on Windows, macOS and Ubuntu and all of three worked, but it's true that I should test on more linux distros. Tell me if the soft link I mentioned is already created. Also you can check if /usr/lib64/ is inside the libraries path (that is obvious). See this to check the library paths.

With that information, I could see what is the problem. Thanks for reporting the bug.

smoebody commented 7 years ago

you are right, there is no libFLAC.so symlink. i have this on my system:

$ ls -l /usr/lib64/libFLAC*
lrwxrwxrwx. 1 root root     18  2. Jan 14:50 /usr/lib64/libFLAC++.so.6 -> libFLAC++.so.6.3.0
-rwxr-xr-x. 1 root root 105584  2. Jan 14:50 /usr/lib64/libFLAC++.so.6.3.0
lrwxrwxrwx. 1 root root     16  2. Jan 14:50 /usr/lib64/libFLAC.so.8 -> libFLAC.so.8.3.0
-rwxr-xr-x. 1 root root 374760  2. Jan 14:50 /usr/lib64/libFLAC.so.8.3.0

maybe you can add a condition level for so.8 to cover mayor version numbers?

melchor629 commented 7 years ago

The problem is that dlopen only searches for .so files. Thats how is implemented on Linux systems. So, the solution you suggest could be good to workaround the problem, but is not a real solution.

Anyway, I will add this condition for Linux OSes so they can load flac using this special symlink. Fix is coming.

Tell if this really fixes your problem. I tested loading libFLAC.so.8 on my Ubuntu and it worked, so this should work for you too (I expect).

smoebody commented 7 years ago

works like a charm, thanks!

melchor629 commented 7 years ago

I'm glad to hear that. Problem solved.