how to add dependence to static library in binding.gyp node-gyp for node.js extension

北慕城南 提交于 2019-12-04 01:35:03

Just add the path of static .a or .so file in the "libraries" section,

"libraries": [ "/usr/local/lib/libnetfilter_queue.so.1.3.0" ]

You could have node-gyp insert the path for you with the built in variable module_root_dir If I interpret your code correctly, changing your libraries to e.g.:

"libraries": [
    "-lmylib",
    "-L<(module_root_dir)/../Library/binaries/linux/Release"
],

might do the trick. Though I'm not sure if it will link with the .a or .so version, to specify that you could try:

"libraries": [
    "<(module_root_dir)/../Library/binaries/linux/Release/libmylib.a"
],

without the -L prefix and -lmylib. Further more, I'm a bit unsure if you're allowed to traverse above the root directory though. I have not tested using anything above the module root directory before. Other than that you should be good to go.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!