gpt4 book ai didi

javascript - "Hello World"+ JS V8 + VS2010

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:45:07 26 4
gpt4 key购买 nike

我下载并构建了 JS V8,以便在 Release模式下的 VS2010 中使用。现在我尝试运行 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;
}

我添加了额外的依赖:

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

当我尝试编译和运行程序时,我遇到了一个链接错误:

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 ==========

当我设置“Ignore All Default Libraries: Yes(/NODEFAULTLIB)”时,出现了这些错误:

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 ==========

有没有人试过运行这个例子或者知道如何修复这些错误?

最佳答案

错误是由于缺少符号__imp__inet_addr@4引起的,它位于Ws2_32.lib中。

转到项目属性 -> 链接器 -> 输入 -> 附加依赖项。只需添加 Ws2_32.lib 即可。

关于javascript - "Hello World"+ JS V8 + VS2010,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13117358/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com