我有一个简单的 binding.gyp 文件来构建我的 node.js 扩展。我想更改库“mylib”的链接方法并静态链接它而不是使用共享库。
{
"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" ]
}
]
}
mylib 的静态和共享版本在同一目录中:
# ls /home/admin/MyLib/Library/binaries/linux/Release
libmylib.a libmylib.so
我想静态链接以避免库安装/加载问题。