How to add dependence to static library in binding.gyp?
See original GitHub issueI did not find in the documentation how to add static library to binding.gyp?
I’ve successfully compiled my node.js extension with reference to the shared library as follows:
{
"targets": [
{
"target_name": "myext",
"sources": [
"code/main.cpp",
"code/load.cpp",
"include/load.h"
],
"include_dirs": [
"include", "../Library/include"
],
"libraries": [
"-lmylib", "-L/home/admin/MyLib/Library/binaries/linux/Release"
],
"cflags!": [ "-fno-exceptions" ],
"cflags": [ "-std=c++11" ],
"cflags_cc!": [ "-fno-exceptions" ]
}
]
}
and now want to add static version of the library to the extension to avoid libray loading issues. Is this possible?
Thanks!
Issue Analytics
- State:
- Created 10 years ago
- Reactions:11
- Comments:23 (6 by maintainers)
Top Results From Across the Web
how to add dependence to static library in binding.gyp node ...
Just add the path of static .a or .so file in the "libraries" section,. "libraries ...
Read more >Configure binding.gyp file in C++ Addon - Node.js - Manh Phan
Make the static library / executable file / shared library. You can add property “type” in binding.gyp with the following sample:.
Read more >User Documentation - GYP
Add new source files; Add a new executable; Add settings to a target; Cross-compiling; Add a new library; Dependencies between targets; Support for...
Read more >How to use a static library with node-gyp on Windows?-C++
which is also the issue encountered in this question (i.e., error LNK2001: unresolved external symbol ). The solution is to create the static...
Read more >node.gyp - nodejs/node - Sourcegraph
For AIX, always generate static library first,. # It needs an extra step to generate exp and. # then use both static lib...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just specify the path the to the static .a file in the “libraries” section:
For making the path relative, just use
module_root_dir
, which is a variable exposed bynode-gyp
.-Wl,-rpath,...
did not work for me, causing symbol lookup errors.