Skip to content

Instantly share code, notes, and snippets.

@gabrielschulhof
Last active April 18, 2017 13:56
Show Gist options
  • Save gabrielschulhof/2aa53679e517ad9985052d71b7f4c11e to your computer and use it in GitHub Desktop.
Save gabrielschulhof/2aa53679e517ad9985052d71b7f4c11e to your computer and use it in GitHub Desktop.
{
"targets": [ {
"target_name": "hello",
"sources": [ "hello.cc" ],
"conditions": [
[ "'<!(node -p \"require('node-api').isNodeApiBuiltin\")'=='false'", {
"include_dirs+": ["<!(node -p \"require('node-api').include\")"],
"conditions": [
[ "OS=='win'", {
"libraries+": [ "<(PRODUCT_DIR)/node-api.lib" ]
} ]
]
} ]
],
"dependencies": [
"<!(node -p \"require('node-api').gyp\")"
]
} ]
}
#include <node_api.h>
napi_value some_function(napi_env env, napi_callback_info info) {
napi_value return_value = 0;
napi_create_number(env, 42, &return_value);
return return_value;
}
void Init(napi_env env, napi_value exports, napi_value module, void *nothing) {
napi_value the_function = 0;
napi_create_function(env, "some_function", some_function, 0, &the_function);
napi_set_named_property(env, module, "exports", the_function);
}
NAPI_MODULE(hello, Init)
{
"name": "hello",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"bindings": "^1.2.1",
"node-api": "github:gabrielschulhof/node-api#backcompat2"
}
}
@gabrielschulhof
Copy link
Author

Output on Windows (among others):

hello.obj : error LNK2001: unresolved external symbol __imp_napi_create_function [C:\Users\nix\h
ello\build\hello.vcxproj]
hello.obj : error LNK2001: unresolved external symbol __imp_napi_create_number [C:\Users\nix\hel
lo\build\hello.vcxproj]
hello.obj : error LNK2001: unresolved external symbol __imp_napi_module_register [C:\Users\nix\h
ello\build\hello.vcxproj]
hello.obj : error LNK2001: unresolved external symbol __imp_napi_set_named_property [C:\Users\ni
x\hello\build\hello.vcxproj]
C:\Users\nix\hello\build\Release\hello.node : fatal error LNK1120: 4 unresolved externals [C:\Us
ers\nix\hello\build\hello.vcxproj]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment