我试图将libcurld.lib构建到一个node.js c ++插件中,但是每当我尝试使用gyp构建它时,都会遇到问题。
我总是收到链接器错误LNK2001。如果我添加define: 'CURL_STATICLIB'
,我将获得LNK2019。
这是我的文件的样子:
{
"targets": [{
"target_name": "addon",
"sources": [ "addon.cpp", ],
'link_settings': {
'include_dirs': ["<(module_root_dir)/curl/include", "<(module_root_dir)/curlcpp/include"],
'libraries': [ '<(module_root_dir)/curl/build/lib/x64/libcurld.lib', '<(module_root_dir)/curlcpp/lib/x64/curlcppd.lib'],
},
}]
}
这里是我在构建时从cmd收到的全部错误:
addon.obj : error LNK2001: unresolved external symbol __imp_curl_easy_perform [C:\Users\Luke\Desktop\app\build\addon.vcxproj]
addon.obj : error LNK2001: unresolved external symbol __imp_curl_easy_init [C:\Users\Luke\Desktop\app\build\addon.vcxproj]
addon.obj : error LNK2001: unresolved external symbol __imp_curl_easy_cleanup [C:\Users\Luke\Desktop\app\build\addon.vcxproj]
addon.obj : error LNK2001: unresolved external symbol __imp_curl_easy_setopt [C:\Users\Luke\Desktop\app\build\addon.vcxproj]
C:\Users\Luke\Desktop\app\build\Release\addon.node : fatal error LNK1120: 4 unresolved externals [C:\Users\Luke\Desktop\app\build\addon.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\Users\Luke\Desktop\app
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok