1

I get unresolved external symbol __imp_td_receive. I have .lib static library files in node-gyp incorrectly. Also, I get same error except about other function (from this header). And i have one warning LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification [C:\Users\poega\Desktop\node-tg-cli\build\ td_json.vcxproj]

I use node-gyp, tdlib windows x32,

td_json_client.h: https://core.telegram.org/tdlib/docs/td__json__client_8h_source.html

part of 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)

binding.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_static",
          ],
        'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
      }
    ]
  }

logs

gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\poega\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose'
gyp verb cli ]
gyp info using node-gyp@8.4.1
gyp info using node@16.13.1 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python3" can be used
gyp verb find Python - executing "python3" to get executable path
gyp verb find Python - "python3" is not in PATH or produced an error
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path
gyp verb find Python - executable path is "C:\Python310\python.exe"
gyp verb find Python - executing "C:\Python310\python.exe" to get version
gyp verb find Python - version is "3.10.1"
gyp info find Python using Python version 3.10.1 found at "C:\Python310\python.exe"
gyp verb get node dir no --target version specified, falling back to host node version: 16.13.1
gyp verb command install [ '16.13.1' ]
gyp verb install input version string "16.13.1"
gyp verb install installing version: 16.13.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 16.13.1
gyp verb build dir attempting to create "build" dir: C:\Users\poega\Desktop\node-tg-cli\build
gyp verb build dir "build" dir needed to be created? Yes
gyp verb find VS msvs_version not set from command line or npm config
gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp verb find VS checking VS2019 (16.9.31205.134) found at:
gyp verb find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp verb find VS - found "Visual Studio C++ core features"
gyp verb find VS - found VC++ toolset: v142
gyp verb find VS - found Windows SDK: 10.0.19041.0
gyp info find VS using VS2019 (16.9.31205.134) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: C:\Users\poega\Desktop\node-tg-cli\build\config.gypi
gyp verb config.gypi checking for gypi file: C:\Users\poega\Desktop\node-tg-cli\config.gypi
gyp verb common.gypi checking for gypi file: C:\Users\poega\Desktop\node-tg-cli\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Python310\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\poega\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\poega\\Desktop\\node-tg-cli\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\poega\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\poega\\AppData\\Local\\node-gyp\\Cache\\16.13.1\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\poega\\AppData\\Local\\node-gyp\\Cache\\16.13.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\poega\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\poega\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.13.1\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\poega\\Desktop\\node-tg-cli',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\poega\\Desktop\\node-tg-cli\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1
gyp verb found first Solution file build/binding.sln
gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 19.01.2022 14:01:18.
Project "C:\Users\poega\Desktop\node-tg-cli\build\binding.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Release|x64".
Project "C:\Users\poega\Desktop\node-tg-cli\build\binding.sln" (1) is building "C:\Users\poega\Desktop\node-tg-cli\buil
d\node_modules\node-addon-api\nothing.vcxproj" (2) on node 1 (default targets).
PrepareForBuild:
  Creating directory "Release\obj\nothing\".
  Creating directory "C:\Users\poega\Desktop\node-tg-cli\build\Release\".
  Creating directory "Release\obj\nothing\nothing.tlog\".
InitializeBuildStatus:
  Creating "Release\obj\nothing\nothing.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
MakeDirsForCl:
  Creating directory "C:\Users\poega\Desktop\node-tg-cli\build\node_modules\node-addon-api\Release\obj\nothing\node_mod
  ules\node-addon-api".
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\CL.exe /c /I"
  C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\include\node" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.1
  3.1\src" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\openssl\config" /I"C:\Users\poega\AppData\Local\
  node-gyp\Cache\16.13.1\deps\openssl\openssl\include" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\uv\i
  nclude" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\zlib" /I"C:\Users\poega\AppData\Local\node-gyp\Ca
  che\16.13.1\deps\v8\include" /Z7 /nologo /W3 /WX- /diagnostics:column /MP /Ox /Ob2 /Oi /Ot /Oy /GL /D NODE_GYP_MODULE
  _NAME=nothing /D USING_UV_SHARED=1 /D USING_V8_SHARED=1 /D V8_DEPRECATION_WARNINGS=1 /D V8_DEPRECATION_WARNINGS /D V8
  _IMMINENT_DEPRECATION_WARNINGS /D _GLIBCXX_USE_CXX11_ABI=1 /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DE
  PRECATE /D _HAS_EXCEPTIONS=0 /D OPENSSL_NO_PINSHARED /D OPENSSL_THREADS /D "HOST_BINARY=\"node.exe\"" /GF /Gm- /MT /G
  S /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR- /Fo"Release\obj\nothing\\node_modules\node-addon-api\nothi
  ng.obj" /Fd"C:\Users\poega\Desktop\node-tg-cli\build\Release\nothing.pdb" /Gd /TC /wd4351 /wd4355 /wd4800 /wd4251 /wd
  4275 /wd4244 /wd4267 /FC /errorReport:queue /Zc:__cplusplus "..\..\..\node_modules\node-addon-api\nothing.c"
  nothing.c
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\CL.exe /c /I"
  C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\include\node" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.1
  3.1\src" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\openssl\config" /I"C:\Users\poega\AppData\Local\
  node-gyp\Cache\16.13.1\deps\openssl\openssl\include" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\uv\i
  nclude" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\zlib" /I"C:\Users\poega\AppData\Local\node-gyp\Ca
  che\16.13.1\deps\v8\include" /Z7 /nologo /W3 /WX- /diagnostics:column /MP /Ox /Ob2 /Oi /Ot /Oy /GL /D NODE_GYP_MODULE
  _NAME=nothing /D USING_UV_SHARED=1 /D USING_V8_SHARED=1 /D V8_DEPRECATION_WARNINGS=1 /D V8_DEPRECATION_WARNINGS /D V8
  _IMMINENT_DEPRECATION_WARNINGS /D _GLIBCXX_USE_CXX11_ABI=1 /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DE
  PRECATE /D _HAS_EXCEPTIONS=0 /D OPENSSL_NO_PINSHARED /D OPENSSL_THREADS /D "HOST_BINARY=\"node.exe\"" /GF /Gm- /MT /G
  S /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR- /Fo"Release\obj\nothing\\" /Fd"C:\Users\poega\Desktop\node
  -tg-cli\build\Release\nothing.pdb" /Gd /TP /wd4351 /wd4355 /wd4800 /wd4251 /wd4275 /wd4244 /wd4267 /FC /errorReport:q
  ueue /Zc:__cplusplus "C:\Users\poega\AppData\Roaming\npm\node_modules\node-gyp\src\win_delay_load_hook.cc"
  win_delay_load_hook.cc
Lib:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\Lib.exe /OUT:
  "C:\Users\poega\Desktop\node-tg-cli\build\Release\nothing.lib" /NOLOGO /MACHINE:X64 /LTCG:INCREMENTAL Release\obj\not
  hing\win_delay_load_hook.obj
  "Release\obj\nothing\\node_modules\node-addon-api\nothing.obj"
  nothing.vcxproj -> C:\Users\poega\Desktop\node-tg-cli\build\Release\\nothing.lib
FinalizeBuildStatus:
  Deleting file "Release\obj\nothing\nothing.tlog\unsuccessfulbuild".
  Touching "Release\obj\nothing\nothing.tlog\nothing.lastbuildstate".
Done Building Project "C:\Users\poega\Desktop\node-tg-cli\build\node_modules\node-addon-api\nothing.vcxproj" (default t
argets).

Project "C:\Users\poega\Desktop\node-tg-cli\build\binding.sln" (1) is building "C:\Users\poega\Desktop\node-tg-cli\buil
d\td_json.vcxproj.metaproj" (3) on node 1 (default targets).
Project "C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxproj.metaproj" (3) is building "C:\Users\poega\Desktop\nod
e-tg-cli\build\td_json.vcxproj" (4) on node 1 (default targets).
PrepareForBuild:
  Creating directory "Release\obj\td_json\".
  Creating directory "Release\obj\td_json\td_json.tlog\".
InitializeBuildStatus:
  Creating "Release\obj\td_json\td_json.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\CL.exe /c /I"
  C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\include\node" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.1
  3.1\src" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\openssl\config" /I"C:\Users\poega\AppData\Local\
  node-gyp\Cache\16.13.1\deps\openssl\openssl\include" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\uv\i
  nclude" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\zlib" /I"C:\Users\poega\AppData\Local\node-gyp\Ca
  che\16.13.1\deps\v8\include" /I"..\node_modules\node-addon-api" /I"C:\Users\poega\Desktop\node-tg-cli\td\tdlib\includ
  e" /Z7 /nologo /W3 /WX- /diagnostics:column /MP /Ox /Ob2 /Oi /Ot /Oy /GL /D NODE_GYP_MODULE_NAME=td_json /D USING_UV_
  SHARED=1 /D USING_V8_SHARED=1 /D V8_DEPRECATION_WARNINGS=1 /D V8_DEPRECATION_WARNINGS /D V8_IMMINENT_DEPRECATION_WARN
  INGS /D _GLIBCXX_USE_CXX11_ABI=1 /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _HAS_EXCEPTIONS
  =0 /D OPENSSL_NO_PINSHARED /D OPENSSL_THREADS /D NAPI_DISABLE_CPP_EXCEPTIONS /D BUILDING_NODE_EXTENSION /D "HOST_BINA
  RY=\"node.exe\"" /D _WINDLL /GF /Gm- /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR- /Fo"Release\obj
  \td_json\\lib.obj" /Fd"Release\obj\td_json\vc142.pdb" /Gd /TP /wd4351 /wd4355 /wd4800 /wd4251 /wd4275 /wd4244 /wd4267
   /FC /errorReport:queue /Zc:__cplusplus ..\lib.cc
  lib.cc
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\CL.exe /c /I"
  C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\include\node" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.1
  3.1\src" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\openssl\config" /I"C:\Users\poega\AppData\Local\
  node-gyp\Cache\16.13.1\deps\openssl\openssl\include" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\uv\i
  nclude" /I"C:\Users\poega\AppData\Local\node-gyp\Cache\16.13.1\deps\zlib" /I"C:\Users\poega\AppData\Local\node-gyp\Ca
  che\16.13.1\deps\v8\include" /I"..\node_modules\node-addon-api" /I"C:\Users\poega\Desktop\node-tg-cli\td\tdlib\includ
  e" /Z7 /nologo /W3 /WX- /diagnostics:column /MP /Ox /Ob2 /Oi /Ot /Oy /GL /D NODE_GYP_MODULE_NAME=td_json /D USING_UV_
  SHARED=1 /D USING_V8_SHARED=1 /D V8_DEPRECATION_WARNINGS=1 /D V8_DEPRECATION_WARNINGS /D V8_IMMINENT_DEPRECATION_WARN
  INGS /D _GLIBCXX_USE_CXX11_ABI=1 /D WIN32 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _HAS_EXCEPTIONS
  =0 /D OPENSSL_NO_PINSHARED /D OPENSSL_THREADS /D NAPI_DISABLE_CPP_EXCEPTIONS /D BUILDING_NODE_EXTENSION /D "HOST_BINA
  RY=\"node.exe\"" /D _WINDLL /GF /Gm- /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR- /Fo"Release\obj
  \td_json\\" /Fd"Release\obj\td_json\vc142.pdb" /Gd /TP /wd4351 /wd4355 /wd4800 /wd4251 /wd4275 /wd4244 /wd4267 /FC /e
  rrorReport:queue /Zc:__cplusplus "C:\Users\poega\AppData\Roaming\npm\node_modules\node-gyp\src\win_delay_load_hook.cc
  "
  win_delay_load_hook.cc
Link:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\link.exe /ERR
  ORREPORT:QUEUE /OUT:"C:\Users\poega\Desktop\node-tg-cli\build\Release\td_json.node" /INCREMENTAL:NO /NOLOGO kernel32.
  lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.li
  b DelayImp.lib "C:\\Users\\poega\\AppData\\Local\\node-gyp\\Cache\\16.13.1\\x64\\node.lib" "C:\Users\poega\Desktop\no
  de-tg-cli\td\tdlib\lib\tdjson_static.lib" Delayimp.lib /DELAYLOAD:node.exe /MANIFEST /MANIFESTUAC:"level='asInvoker'
  uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:\Users\poega\Desktop\node-tg-cli\build\Release\td_json.pdb" /OPT:REF
   /OPT:ICF /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /LTCG:INCREMENTAL /ignore:4199 /DLL Release\obj\td_json\win_de
  lay_load_hook.obj
  Release\obj\td_json\\lib.obj
  "C:\Users\poega\Desktop\node-tg-cli\build\Release\nothing.lib"
     Creating library C:\Users\poega\Desktop\node-tg-cli\build\Release\td_json.lib and object C:\Users\poega\Desktop\no
  de-tg-cli\build\Release\td_json.exp
lib.obj : error LNK2001: unresolved external symbol td_receive [C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxpro
j]
lib.obj : error LNK2001: unresolved external symbol td_send [C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxproj]
lib.obj : error LNK2001: unresolved external symbol td_create_client_id [C:\Users\poega\Desktop\node-tg-cli\build\td_js
on.vcxproj]
lib.obj : error LNK2001: unresolved external symbol td_execute [C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxpro
j]
C:\Users\poega\Desktop\node-tg-cli\build\Release\td_json.node : fatal error LNK1120: 4 unresolved externals [C:\Users\p
oega\Desktop\node-tg-cli\build\td_json.vcxproj]
Done Building Project "C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxproj" (default targets) -- FAILED.

Done Building Project "C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxproj.metaproj" (default targets) -- FAILED.

Done Building Project "C:\Users\poega\Desktop\node-tg-cli\build\binding.sln" (default targets) -- FAILED.


Build FAILED.

"C:\Users\poega\Desktop\node-tg-cli\build\binding.sln" (default target) (1) ->
"C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxproj.metaproj" (default target) (3) ->
"C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxproj" (default target) (4) ->
(Link target) ->
  lib.obj : error LNK2001: unresolved external symbol td_receive [C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxp
roj]
  lib.obj : error LNK2001: unresolved external symbol td_send [C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxproj
]
  lib.obj : error LNK2001: unresolved external symbol td_create_client_id [C:\Users\poega\Desktop\node-tg-cli\build\td_
json.vcxproj]
  lib.obj : error LNK2001: unresolved external symbol td_execute [C:\Users\poega\Desktop\node-tg-cli\build\td_json.vcxp
roj]
  C:\Users\poega\Desktop\node-tg-cli\build\Release\td_json.node : fatal error LNK1120: 4 unresolved externals [C:\Users
\poega\Desktop\node-tg-cli\build\td_json.vcxproj]

    0 Warning(s)
    5 Error(s)

Time Elapsed 00:00:04.02
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\poega\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\poega\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose"
gyp ERR! cwd C:\Users\poega\Desktop\node-tg-cli
gyp ERR! node -v v16.13.1
gyp ERR! node-gyp -v v8.4.1
gyp ERR! not ok
Yaroslav
  • 61
  • 5
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Stephen Newell Jan 18 '22 at 16:26
  • @StephenNewell I know about this error. I can't understand why this error happens. – Yaroslav Jan 18 '22 at 16:59
  • Did you read the top answer that explains the linking process? – Stephen Newell Jan 18 '22 at 18:06

1 Answers1

0
  • If you are linking a library statically, you need to fix the #defines. Look at the header files of your library, there will be some kind of conditional #define that controls the inclusion of dllimport/dllexport decorators. Make it so they do not get included - they are needed only when building a DLL. That's why the linker generates the __imp_ prefix - it means it is trying to import from a DLL.
  • If you are linking a library DLL you need both the DLL and an import .lib library and you need to add this .lib in the libraries section:
   "conditions": [
     ["OS == 'win'", {
       "libraries": [
         "<path...>/tdjson.lib"
       ]
     }]
   ]
mmomtchev
  • 2,497
  • 1
  • 8
  • 23
  • This library is link to dll. So do it no sense – Yaroslav Jan 18 '22 at 19:01
  • You want to link your addon to a DLL? Is this `tdjson`? You need both the DLL and the import library, do you have them both? Then you must specify your import library in `libraries` – mmomtchev Jan 18 '22 at 19:04
  • I have static variant of this library, and link to dll. I have tried all ways to do it, but all ways is failed. Library exactly contains declaration of functions. – Yaroslav Jan 18 '22 at 19:13
  • I don't understand, which part is static and which part is a DLL? – mmomtchev Jan 18 '22 at 19:16
  • This library compiled as linking library and static, I tried every build. – Yaroslav Jan 18 '22 at 19:19
  • If you are compiling the library statically, then my first answer applies - go through the header files of the library, find where the `dllimport`/`dllexport` is coming from and make it so they do not get included – mmomtchev Jan 18 '22 at 19:20
  • I did it. I read your answer. – Yaroslav Jan 18 '22 at 19:23
  • I got same error without __imp_ prefix – Yaroslav Jan 18 '22 at 19:25
  • How are you linking this library? Do you have a `.lib` file? Did you add it to the `libraries` section? – mmomtchev Jan 18 '22 at 19:35
  • Yes, I have. And I added to libraries section. – Yaroslav Jan 18 '22 at 19:38
  • Try to find the `vcproj` file that `node-gyp` generated and check if the library is included and that the `.lib` file can indeed be found in the specified directory. Check also that you are using a static library version and not an import library. You can find a tool on the Microsoft site to check what symbols are contained in the `.lib` file to make sure that the symbol you are trying to link is there. – mmomtchev Jan 18 '22 at 19:41
  • I have checked this library contains this functions declaration and obj files. But I opened vcxproj, and didn't find lib in references – – Yaroslav Jan 18 '22 at 20:33
  • post your entire gyp in the question – mmomtchev Jan 18 '22 at 21:02
  • @momtchev I have added gyp logs – Yaroslav Jan 19 '22 at 12:03
  • @momtchev Also There are all content of binding.gyp file – Yaroslav Jan 19 '22 at 12:05
  • If this file `C:\Users\poega\Desktop\node-tg-cli\td\tdlib\lib\tdjson_static.lib` exists and contains all the symbols that are missing - I am at loss to explain what is the problem. You should probably ask the same question with a Visual Studio tag - in this case the problem is not `node-gyp` – mmomtchev Jan 19 '22 at 19:24