2

I'm trying to use V8 in my project. I've built it as a static library and now in the out.gn/x64.release/obj folder I have quite many .lib files. Based on this parameters list to g++:

--start-group \
out.gn/x64.release/obj/{libv8_{base,libbase,external_snapshot,libplatform,libsampler},\
third_party/icu/libicu{uc,i18n},src/inspector/libinspector}.a \
-Wl,--end-group

I've undefined and linked the following libraries in v8.cpp file:

#pragma comment(lib, "v8_base.lib")
#pragma comment(lib, "v8_libbase")
#pragma comment(lib, "v8_external_snapshot")
#pragma comment(lib, "v8_libplatform")
#pragma comment(lib, "v8_libsampler")
#pragma comment(lib, "icuuc.lib")
#pragma comment(lib, "icui18n.lib")
#pragma comment(lib, "inspector")

But now I get many linker errors:

1>------ Build started: Project: v8, Configuration: Release x64 ------
1>v8_libbase.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __imp_timeGetTime
1>v8_libbase.lib(time.obj) : error LNK2001: unresolved external symbol __imp_timeGetTime
1>v8_libbase.lib(stack_trace_win.obj) : error LNK2001: unresolved external symbol __imp_StackWalk64
1>v8_libbase.lib(stack_trace_win.obj) : error LNK2001: unresolved external symbol __imp_SymSetOptions
...
1>C:\...\Documents\Visual Studio 2015\Projects\v8\x64\Release\v8.exe : fatal error LNK1120: 11 unresolved externals

I've read here that

If you are manually adding the *.lib files to your link dependencies, then you are also responsible for linking against any DLLs they depend on

So my question is how to identify these DLL's and how to link them? I'm using Visual Studio 2015.

Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • This lib dll stuff is something very VisualStudio specific. May be, you should add the resp. tag. I do not know whether this is a must but if we built dlls we get also corresponding libs. The libs are needed for linkage. The dll itself is not linked - it's loaded at runtime. (The lib provides the symbols which are expected to find in the corresponding dll.) Thus, I would expect that there are libs and dlls with equal name. The most simple way is to store the dlls in the same folder like the exe to grant that the former are found/bound when the latter is started. – Scheff's Cat May 10 '17 at 05:25
  • Another hint: If we have problems with our Windows applications concerning dll dependencies we use a free tool: [Dependency Walker](http://www.dependencywalker.com/). I'm not quite sure if this helps in your problem... – Scheff's Cat May 10 '17 at 05:33
  • @Scheff, thanks, _but if we built dlls we get also corresponding libs_ - there are no corresponding `.dll`, for example for `v8_base` there are the following files: `v8_base.lib, v8_base.ninja, v8_stamp`. But there is a bunch of `.dlls` in the `out.gn/x64.release` folder. – Max Koretskyi May 10 '17 at 05:37
  • Hmm. For my luck, I started with "I do not know whether this is a must..." I see two opportunities: 1st Dig into MSDN and learn how this dll hell works. 2nd Put all dlls into the dir. of the exe (or set PATH respectively or do any other appropriate setting) and once you got the executable running Dependency Walker can tell you what's really used/needed. If you decide for the 1st option I would really enjoy your answer with a clear understandable explanation... – Scheff's Cat May 10 '17 at 05:45
  • I googled a little bit and found [SO: Is there any native DLL export functions viewer?](http://stackoverflow.com/questions/1548637/is-there-any-native-dll-export-functions-viewer) and [SO: Tools for inspecting .lib files?](http://stackoverflow.com/questions/488809/tools-for-inspecting-lib-files). You may find more if you google "windows dll exported symbols" and "windows dump library symbols". – Scheff's Cat May 10 '17 at 05:54

1 Answers1

3

You should read the documentation of the functions you use in your code.

For example for StackWalk64 , You find in the requirements section:

  • Redistributable - DbgHelp.dll 5.1 or later
  • Header - DbgHelp.h
  • Library - DbgHelp.lib
  • DLL - DbgHelp.dll
napuzba
  • 6,033
  • 3
  • 21
  • 32