我需要在Windows上编译Node.js插件。我的问题是该插件依赖于共享库(libgeometry)。在Linux和MacOS上进行编译时,与libgeometry
链接时没有问题,但是我真的不知道如何在Windows上做到这一点。我已经有libgeometry.dll
和libgeometry.dll.a
可用,但是如何在编译时链接它呢?
这是我的binding.gyp
文件:
{
"targets": [
{
"target_name": "test",
"sources": [
"src/test.cpp"
],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
"<(module_root_dir)/native/include"
],
"conditions": [
['OS in "linux"', {
"libraries": [
"-lgeometry",
"-L<(module_root_dir)/native/lib/linux/libgeometry",
"-Wl,-rpath,\$$ORIGIN/../../native/lib/linux/libgeometry"
],
"defines": [
"NAPI_CPP_EXCEPTIONS"
]
}],
['OS in "mac"', {
"libraries": [
"-lgeometry",
"-L<(module_root_dir)/native/lib/darwin/libgeometry",
"-Wl,-rpath,@loader_path/../../native/lib/darwin/libgeometry"
],
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"CLANG_CXX_LIBRARY": "libc++"
}
}]
],
"dependencies": ["<!(node -p \"require('node-addon-api').gyp\")"],
"cflags": ["-fexceptions"],
"cflags_cc": ["-fexceptions"],
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": 1
}
}
}
]
}