4

If I import the .lib and .h files in the Google V8 Engine, it will attempt to use them in a different c ++ project.

Do I need to import a file of any name?

When the source of the v8 was compile and build,

  • cctest
  • fuzzer_support
  • generate-bytecode-expectations
  • gmock
  • gtest
  • icui18n
  • icuuc
  • inspector_protocol
  • json_fuzzer_lib
  • mksnapshot
  • parser_fuzzer_lib
  • regexp_fuzzer_lib
  • unittests
  • v8
  • v8_base_0
  • v8_base_1
  • v8_base_2
  • v8_base_3
  • v8_external_snapshot
  • v8_libbase
  • v8_libplatform
  • v8_libsampler
  • v8_nosnapshot
  • v8_simple_json_fuzzer
  • v8_simple_parser_fuzzer
  • v8_simple_regexp_fuzzer
  • v8_simple_wasm_asmjs_fuzzer
  • v8_simple_wasm_fuzzer
  • wasm_fuzzer_lib
  • wasm_asmjs_fuzzer_lib

name file is generated.

I simply use the v8, and it outputs a run value of javascript.

My guess, seems to use only "v8.lib, v8_base (0,1,2,3) .lib" and "v8.h".

Is the sample code in a new c ++ project by copying the contents of the "hello-world.cc", made a cpp file. And I run, "LNK2019", "LNK1120" error occurs.

1>----- Build started: Project: v8Application, Configuration: Debug Win32 -----
1> v8Application.cpp
1>v8Application.obj : error LNK2019: unresolved external symbol _main referenced in function"class v8::Platform * __cdecl v8::platform::CreateDefaultPlatform(int)" (?CreateDefaultPlatform@platform@v8@@YAPAVPlatform@2@H@Z) 1>c:\users\kito\documents\visual studio 2015\Projects\v8Application\Debug\v8Application.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

It seems must not defined "platform :: CreateDefaultPlatform" part is turned only in 'libplatform.h' declaration. However, I would add "src \ libplatform \ default-platform.cc" the platform :: CreateDefaultPlatform has been defined, other error occurs in the add.

"Ws2_32.lib, winmm.lib" was also added to the project of the Additional Dependencies property.

How do I do this?

Kito
  • 45
  • 10

1 Answers1

1

You must create your project and then LINK with V8, but you must not add V8's source files to your project.

The first thing to do is to compile V8 and take note of where the libraries were generated (or copy them to the directory of your choice). The same applies to V8's include files, they must be available in order to be included in your project (it is not advisable to copy them to your project directory).

In your console project's settings go to Linker -> Input -> Additional Dependencies and put v8.lib there. If the error is still present work you might want to add v8_libplatform.lib too.

Something similar applies to the include files, in your project settings you should go to C/C++ -> General -> Additional Include Directories and add V8's include directory there.

But remember, you must first compile v8 alone and expose the lib and include directories to your new project.

Update:

Your project file indicates that you configured Your project only for the configuración "Release", but the output above indicates that you are compiling in Debug mode.

Project config:

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    ...
    <Link>
        <AdditionalDependencies>ws2_32.lib;winmm.lib;v8.lib;v8_base_0.lib;v8_base_1.lib...
    </Link>
<ItemDefinitionGroup

Compiler output above:

1>----- Build started: Project: v8Application, Configuration: Debug Win32 -----

You must configure your project for all configurations, or at least test it using the configuration you've setup.

On the other hand, v8_libplatform.lib is not in the list of additional dependencies, you may want to add it.

ichramm
  • 6,437
  • 19
  • 30
  • I have copied the contents of the "hello-world" of v8 example source to the new project. Did I use the wrong way? "Linker -> Input -> Additional Dependencies" and "C / C ++ of -> General -> Additional Include Directories" was setting. – Kito Aug 22 '16 at 04:53
  • The new project of the location, "C: \ Users \ kito \ Documents \ Visual Studio 2015 \ Projects \ v8Application". Configuration of v8Application is, include folders and lib folder, there is a v8Application.cpp files and project files. In the lib folder "v8.lib, v8_base_0.lib, v8_base_1.lib, v8_base_2.lib, v8_base_3.lib, v8_libbase.lib, v8_libplatform.lib, there is a v8_nosnapshot.lib" file. – Kito Aug 22 '16 at 05:09
  • I was set the v8.lib and v8_base (0,1,2,3) in the "Linker - > Input-> Additional Dependencies". In the include folder there is a h file of "v8, v8config, v8-debug, v8-experimental, v8-platform, v8-profiler, v8-testing, v8-util, v8-version". And libplatform folder is in the include folder. There is a "libplatform, v8-tracing 'h file is in. Version is different but "include folder", please refer to the "include" in the "master" from the "https://github.com/v8/v8/" link – Kito Aug 22 '16 at 05:29
  • Would you mind uploading your `.vcxproj` to gist.gihub.com/ and providing the path where V8 libs are located? – ichramm Aug 22 '16 at 14:45
  • I posted the contents of the `.vcxproj` file and the `.cpp` file. [https://gist.github.com/anonymous/8e5bc61a057d59735bb4de015a7d8f6d](https://gist.github.com/anonymous/8e5bc61a057d59735bb4de015a7d8f6d) Please check. – Kito Aug 23 '16 at 00:34
  • Thank you for the answer ichramm. test was seen both Debug and Release, `. vcxpoj file` when to upload is being tested in Release mode. I have tried to also add `v8-libplatform.lib`, many of `LNK2001`, `LNK2019` error occurs. #ifdef NDEBUG #ifdef _DEBUG #undef _DEBUG #endif #endif I tried to test using the code but was the same. – Kito Aug 29 '16 at 00:36
  • I today, was found look to try in other ways. I dropped the lib files of some of this. Need to import is not know where to find a list of lib file, it seems to have been a problem. I am currently in the test, but seems to have can be solved if the study than a little bit. I am very grateful to give an answer. – Kito Aug 29 '16 at 07:13