[英]i got an error while compiling - node-gyp windows (c++)
我得到unresolved external symbol __imp_td_receive
。 我可以在代碼中看到錯誤,但我認為代碼中有錯誤。 可能錯誤是在 node-gyp 中錯誤地包含了.lib 文件。 此外,除了其他 function (來自此標題)之外,我得到了同樣的錯誤。 我有一個警告LINK: warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification [C:\Users\poega\Desktop\node-tg-cli\build\ td_json.vcxproj]
我使用 node-gyp,tdlib windows x32,
td_json_client.h: https://core.telegram.org/tdlib/docs/td__json__client_8h_source.html
main.cpp 的一部分
// hello.cc
// #include <napi.h>
#include <napi.h>
#include <iostream>
//#include <node.h>
#include "td/telegram/td_json_client.h"
using std::string;
void create_client_id(Napi::CallbackInfo& info) {
// Isolate* isolate = args.GetIsolate();
// args.GetReturnValue().Set(String::NewFromUtf8(
// isolate, "world").ToLocalChecked());
td_create_client_id();
}
// td_send(int client_id, const char *request)
綁定.gyp
{
"targets": [
{
"target_name": "td_json",
"sources": [ "lib.cc" ],
"include_dirs": [
"<!(node -p \"require('node-addon-api').include_dir\")",
"<(module_root_dir)/td/tdlib/include"
],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
],
"libraries": [
"<(module_root_dir)/td/tdlib/lib/tdjson",
],
# "conditions": [
# ["OS==\"win\"", {
# "copies": [
# {
# "destination": "<(module_root_dir)/build/Release/",
# "files": [ "<(module_root_dir)/td/build/Release/tdjson.dll" ]
# }
# ]
# }]
# ],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
}
]
}
#define
。 查看庫的 header 文件,會有某種條件#define
控制dllimport
/ dllexport
裝飾器的包含。 使其不被包括在內 - 只有在構建 DLL 時才需要它們。 這就是 linker 生成__imp_
前綴的原因 - 這意味着它正在嘗試從 DLL 導入。.lib
庫,並且需要在libraries
部分添加此.lib
: "conditions": [
["OS == 'win'", {
"libraries": [
"<path...>/tdjson.lib"
]
}]
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.