Tôi đã tải xuống và xây dựng JS V8 để sử dụng trong VS2010 ở chế độ Phát hành. Bây giờ tôi cố gắng chạy Hello World example:"Hello World" + JS V8 + VS2010
#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;
}
tôi thêm Dependencies bổ sung:
"C:\v8\build\Release\lib\preparser_lib.lib"
"C:\v8\build\Release\lib\v8_base.lib"
Khi tôi cố gắng biên dịch và chạy chương trình, tôi gặp một lỗi khi liên kết:
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 [email protected]
...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Khi tôi đã đặt "Bỏ qua tất cả thư viện mặc định: Có (/ NODEFAULTLIB)", các lỗi này xuất hiện:
1>------ Build started: Project: V8_example, Configuration: Release Win32 ------
1>v8_base.lib(strtod.obj) : error LNK2001: unresolved external symbol @[email protected]
1>v8_base.lib(full-codegen-ia32.obj) : error LNK2001: unresolved external symbol @[email protected]
...
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 ==========
Có ai đã cố chạy ví dụ này hoặc biết cách sửa các lỗi này không?
Số lỗi giảm xuống dưới 28: 1> LINK: cảnh báo LNK4098: defaultlib 'LIBCMT' xung đột với việc sử dụng các lib khác; sử dụng/NODEFAULTLIB: thư viện 1> v8_base.lib (platform-win32.obj): lỗi LNK2001: chưa được giải quyết biểu tượng bên ngoài __imp__timeGetTime @ 0 1> v8_base.lib : lỗi LNK2001: biểu tượng bên ngoài chưa được giải quyết "riêng tư: static int const v8: : internal :: Snapshot :: cell_space_used_ "(? cell_space_used_ @ Ảnh chụp @ nội bộ @ v8 @@ 0HB) ... –