0

Recently, I have a try to build and run sample hello world program of google v8. My xcode version is 4.0.2GA, x86_64.

The guide's link: get Started

But when run the command: g++ -Iinclude hello_world.cpp -o hello_world libv8.a -lpthread

The errors show:

ld: warning: ignoring file libv8.a, file was built for archive which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"v8::Context::Enter()", referenced from:
      v8::Context::Scope::Scope(v8::Handle<v8::Context>)in ccJsmYlc.o
  "v8::V8::DisposeGlobal(v8::internal::Object**)", referenced from:
      v8::Persistent<v8::Context>::Dispose()      in ccJsmYlc.o
  "v8::Context::Exit()", referenced from:
      v8::Context::Scope::~Scope()in ccJsmYlc.o
  "v8::HandleScope::HandleScope()", referenced from:
      _main in ccJsmYlc.o
  "v8::Context::New(v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)", referenced from:
      _main in ccJsmYlc.o
  "v8::String::New(char const*, int)", referenced from:
      _main in ccJsmYlc.o
  "v8::Script::Compile(v8::Handle<v8::String>, v8::ScriptOrigin*, v8::ScriptData*, v8::Handle<v8::String>)", referenced from:
      _main in ccJsmYlc.o
  "v8::Script::Run()", referenced from:
      _main in ccJsmYlc.o
  "v8::String::AsciiValue::AsciiValue(v8::Handle<v8::Value>)", referenced from:
      _main in ccJsmYlc.o
  "v8::String::AsciiValue::~AsciiValue()", referenced from:
      _main in ccJsmYlc.o
  "v8::HandleScope::~HandleScope()", referenced from:
      _main in ccJsmYlc.o

ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status.
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
kennyeric
  • 43
  • 4

1 Answers1

2

It should be obvious you are trying to link with a .a that was build for another architecture. Check out How do I determine the target architecture of static library (.a) on Mac OS X? to learn how to check the target architecture of that .a. Once you know that you can either retarget you project, or create a new libv8.a for the x86_64 architecture.

Community
  • 1
  • 1
fvu
  • 32,488
  • 6
  • 61
  • 79