Failed to launch hello_world.cc

246 views
Skip to first unread message

劉君羿

unread,
Oct 2, 2012, 9:49:49 AM10/2/12
to v8-u...@googlegroups.com
I am using ubuntu 10.04 on x86_64 machine.
I built v8 with "make native",
and copied and pasted the hello_world.cc to the root directory of v8.
I typed "g++ -Iinclude hello_world.cc hello_world", and it gave me the following error:

/tmp/ccjmXg7T.o: In function `main':
hw.cc:(.text+0x26): undefined reference to `v8::HandleScope::HandleScope()'
hw.cc:(.text+0x53): undefined reference to `v8::Context::New(v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)'
hw.cc:(.text+0x79): undefined reference to `v8::String::New(char const*, int)'
hw.cc:(.text+0xb4): undefined reference to `v8::Script::Compile(v8::Handle<v8::String>, v8::ScriptOrigin*, v8::ScriptData*, v8::Handle<v8::String>)'
hw.cc:(.text+0xda): undefined reference to `v8::Script::Run()'
hw.cc:(.text+0x114): undefined reference to `v8::String::AsciiValue::AsciiValue(v8::Handle<v8::Value>)'
hw.cc:(.text+0x13f): undefined reference to `v8::String::AsciiValue::~AsciiValue()'
hw.cc:(.text+0x155): undefined reference to `v8::String::AsciiValue::~AsciiValue()'
hw.cc:(.text+0x193): undefined reference to `v8::HandleScope::~HandleScope()'
hw.cc:(.text+0x1b5): undefined reference to `v8::HandleScope::~HandleScope()'
/tmp/ccjmXg7T.o: In function `v8::Context::Scope::Scope(v8::Handle<v8::Context>)':
hw.cc:(.text._ZN2v87Context5ScopeC1ENS_6HandleIS0_EE[v8::Context::Scope::Scope(v8::Handle<v8::Context>)]+0x2b): undefined reference to `v8::Context::Enter()'
/tmp/ccjmXg7T.o: In function `v8::Context::Scope::~Scope()':
hw.cc:(.text._ZN2v87Context5ScopeD1Ev[v8::Context::Scope::~Scope()]+0x1c): undefined reference to `v8::Context::Exit()'
/tmp/ccjmXg7T.o: In function `v8::Persistent<v8::Context>::Dispose()':
hw.cc:(.text._ZN2v810PersistentINS_7ContextEE7DisposeEv[v8::Persistent<v8::Context>::Dispose()]+0x2c): undefined reference to `v8::V8::DisposeGlobal(v8::internal::Object**)'
collect2: ld returned 1 exit status

Jakob Kummerow

unread,
Oct 2, 2012, 10:19:12 AM10/2/12
to v8-u...@googlegroups.com
Please follow the provided instructions:

Compile hello_world.cpp, linking to the static libraries created in the build process. For example, on 64bit Linux using the GNU compiler:
g++ -Iinclude hello_world.cc -o hello_world out/x64.release/obj.target/tools/gyp/libv8_{base,snapshot}.a -lpthread

Simply omitting the reference to the libraries is not going to work. Since you built with "make native", you'll have to adapt the path to "out/native/...".


劉君羿

unread,
Oct 3, 2012, 2:47:27 AM10/3/12
to v8-u...@googlegroups.com
It works!! Thank you.

2012/10/2 Jakob Kummerow <jkum...@chromium.org>
Reply all
Reply to author
Forward
0 new messages