4

I successfully compiled v8 javascript engine (on windows) ; now I try to follow the Getting started article but I am stuck at this point:

  1. Compile hello_world.cpp, linking to the static libraries created in the build process.

The example is for linux (and probably for an earlier version).

I tried to link against all libraries that I could without success:

User@PC:/cygdrive/c/Users/Yvain/Documents/depot_tools/v8/build/Release
g++  -std=c++0x  -I"C:\Users\Yvain\Documents\depot_tools\v8" -Llib -lv8_libbase -lv8_base_0 -lv8_base_1 -lv8_base_2 -lv8_base_3 -lgmock -lgtest -licui18n -licuuc -lv8_external_snapshot -lv8_libplatform -lv8_nosnapshot hello_world.cpp -o hello_world

It gives the following errors:

  /tmp/ccPxkjlV.o:hello_world.cpp:(.text+0x1a): 
       undefined reference to « v8::V8::InitializeICU(char const*) »
  [...]undefined reference to « v8::V8::InitializeExternalStartupData(char const*) »
  [...]
  [...]undefined reference to  « v8::Isolate::Exit() »

There is a working example: v8/sample/hello-world.vcxproj but I don't understand where the libraries are specified in the project.

arthur.sw
  • 11,052
  • 9
  • 47
  • 104
  • [Please explain why you vote down](http://meta.stackexchange.com/questions/135/encouraging-people-to-explain-downvotes) when you do. – arthur.sw Sep 01 '15 at 16:15
  • Have you been through [this](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix)? – NathanOliver Sep 01 '15 at 16:17
  • Try [this](http://stackoverflow.com/questions/15071432/undefined-reference-when-linking-v8) as well – Amit Sep 01 '15 at 17:46
  • There is a working example: `v8/sample/hello-world.vcxproj` but I don't understand where the libraries are specified in the project. – arthur.sw Sep 02 '15 at 09:12
  • Since your prompt contains "/cygdrive" I assume this is all using Cygwin tools. Does the -I"C:\Users..." really work? Why not -I/cygdrive/c/Users..." ? – cardiff space man Oct 02 '15 at 19:27

1 Answers1

0

Visual Studio project v8/sample/hello-world.vcxproj has been generated with GYP from v8/build/samples/samples.gyp with all necessary dependencies.

In the current version of "Getting started" article, in "Run example" section, item list #3 contains an example of command line to build the hello_world:

Compile hello_world.cpp, linking to the static libraries created in the build process. For example, on 64bit Linux using the GNU compiler:

g++ -I. hello_world.cpp -o hello_world -Wl,--start-group out/x64.release/obj.target/{tools/gyp/libv8_{base,libbase,external_snapshot,libplatform},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -ldl -pthread -std=c++0x

On Windows you need to use the similar list of static libraries as a linker input. Please note these static libraries are placed in v8/build/Release/lib directory.

pmed
  • 1,536
  • 8
  • 13
  • I read that, but I don't have the proper files in `out/x64.release/obj.target/` (I just have a file `out\x64.release\obj.target\third_party\icu\icudata.stamp` and an empty dir`out\x64.release\obj.target\v8_base\src`). – arthur.sw Sep 05 '15 at 09:11