Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Hello World" + JS V8 + VS2010

I downloaded and built JS V8 for using in VS2010 in Release mode. Now I try run Hello World example:

#include "v8.h"

int _tmain(int argc, _TCHAR* argv[])
{
    v8::HandleScope handle_scope;

    v8::Persistent<v8::Context> context = v8::Context::New();

    v8::Context::Scope context_scope(context);

    v8::Handle<v8::String> source = v8::String::New("'Hello' + ', World'");

    v8::Handle<v8::Script> script = v8::Script::Compile(source);

    v8::Handle<v8::Value> result = script->Run();

    context.Dispose();

    v8::String::AsciiValue ascii (result);

    printf ("%s\n", *ascii);

    return 0;
}

I added Additional Dependencies:

"C:\v8\build\Release\lib\preparser_lib.lib"
"C:\v8\build\Release\lib\v8_base.lib"

When I try to compile and run the program, I encountered a linking error:

1>------ Build started: Project: V8_example, Configuration: Release Win32 ------
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>v8_base.lib(platform-win32.obj) : error LNK2001: unresolved external symbol __imp__inet_addr@4
...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

When I have set "Ignore All Default Libraries: Yes(/NODEFAULTLIB)", these errors showed up:

1>------ Build started: Project: V8_example, Configuration: Release Win32 ------
1>v8_base.lib(strtod.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>v8_base.lib(full-codegen-ia32.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
...
1>c:\users\admin\documents\visual studio 2010\Projects\V8_example\Release\V8_example.exe : fatal error LNK1120: 141 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Has anyone tried to run this example or know how to fix these errors?

like image 512
ibn_maksimys Avatar asked Nov 03 '22 12:11

ibn_maksimys


1 Answers

The error is caused by the missing symbol __imp__inet_addr@4, which is located in Ws2_32.lib.

Go to project Properties -> Linker -> Input -> Additional Dependencies. Simply add Ws2_32.lib and you're done.

like image 189
Jonas Byström Avatar answered Nov 12 '22 14:11

Jonas Byström