Answer the question
In order to leave comments, you need to log in
How to build a cross-distributive native node.js module?
Hello.
I am writing a module in C++ using NAN. Wrote it on Debian 9. Compiled, ran everything worked well. There I have gcc version 6.8.0.
On another laptop, I have CentOS 7. When I tried to run the application with my module on it, I got an error:
A Javascript error occurred in the main process
Uncaught Exception:
Error: Cannot open /tmp/.mount_figma-ijkRXB/resources/app.asar/main/binding.node: Error: /lib64/libstdc++.so.6:
/lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found
Answer the question
In order to leave comments, you need to log in
Two options:
1) Link with the -static-libstdc++ flag. In this case, the static version of the lib will be linked into the executable. All other dependencies can also be linked statically. What is usually done for plugins. All in all, this is a very good option.
2) Supply the required version of the lib with the application, and link with '-Wl,-rpath,$ORIGIN/relative_path_to_lib_dir'. The same goes for other dependencies.
The first option may not work for some reasons (most likely it will not affect you):
1) If it is not known with which flags the host application executes dlopen on your plugin. This can be circumvented by introducing another layer without unnecessary dependencies, which will correctly execute dlopen.
2) Licenses. Something may be impossible to link statically, or it is possible, but with unfavorable conditions for you.
The second option can also be problematic. If the host application has already loaded a dependency whose name and version matches the name and version of the dependency your plugin needs, then the dependency for your plugin will not be loaded. This is not a problem if the dependencies are the same. But if you patch or your own dependencies, then you will have to rename them and use the soname flag. But then again, I'm not sure that this problem will affect you.
Welcome to the world of C++ :)
PS
Try writing your plugin in Rust, for example. Life is likely to get easier.
As one of the options to use Docker for building, it will be possible to compile with the necessary packages and version of gcc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question