How to add dependence library in binding.gyp
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.7k
- Forks
- 1.9k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 5
Description
{
"targets": [
{
"target_name": "hello",
"cflags!": ["-fno-exceptions"],
"cflags_cc!": ["-fno-exceptions"],
'conditions': [
['OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
}
}]
],
"sources": [ "hello.cpp" ],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
"./include/",
"./include/glib-2.0"
],
"libraries:": ["-llibgobject-2.0.0.dylib", "-L/usr/local/lib",
"-llibgobject-2.0.0.dylib", "-L/usr/local/lib"
"-llibvips.42.dylib", "-L/usr/local/lib"
"-llibvips-cpp.42.dylib", "-L/usr/local/lib"
],
"dependencies":[
"<!@(node -p \"require('node-addon-api').gyp\")"
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
}
]
}
hello.cpp
#include <napi.h>
#include <string>
#include <vips/vips.h>
#include <vips/vips8>
std::string get_str()
{
VIPS_INIT("hello");
vips::VImage text = vips::VImage::text("LoremIpsum", vips::VImage::option()->set("dpi", 400));
return "success";
}
Napi::String Method(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
std::string aa = get_str();
return Napi::String::New(env, aa.c_str());
}
Napi::Object Init(Napi::Env env, Napi::Object exports) {
exports.Set(Napi::String::New(env, "hello"),
Napi::Function::New(env, Method));
return exports;
}
NODE_API_MODULE(hello, Init)
symbol not found in flat namespace '__ZTVN4vips7VOptionE'
nm libvips-cpp.42.dylib | grep ZTVN4vips7VOptionE
000000000003c360 S __ZTVN4vips7VOptionE
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading binding.gyp and hello.cpp, then reproduce the native addon build that reports the missing vips::VOption symbol. Compare the declared libraries with the symbols in libvips-cpp.42.dylib; the work is done when the addon links and builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, nodejs
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100