The problem is that you are mixing the use of v8 in a shared (DLL) versus
static library. Building v8 line this
  scons msvcrt=shared env="INCLUDE:%INCLUDE%,LIB:%LIB%"

creates a static library. Using msvcrt=shared means that the Visual C++
runtime library is pulled from a shared library, not that V8 itself is build
as a shared library. When linking with this static library you should not
define USING_V8_SHARED. Changing your command to (winmm.lib ws2_32.lib are
needed as they are used by V8)

  cl /Iinclude hello_world.cpp v8.lib winmm.lib ws2_32.lib

will probable give other link errors as the v8 code will use the shared
version of the Visual C++ runtime library whereas hello_world.cpp will try
to use the static. You will need to add the option /MD to
have hello_world.cpp use the shared version of the Visual C++ runtime
library as well. Also the V8 scons build uses link-time code generation so
adding option /GL will save you from a linker warning. This command should
give you an executable

  cl /Iinclude /MD /GL hello_world.cpp v8.lib winmm.lib ws2_32.lib

I suggest that you use static libraries only while experimenting, and switch
off link-time code generation

  scons msvcltcg=off
  cl /Iinclude hello_world.cpp v8.lib winmm.lib ws2_32.lib

Switching off link-time code generation makes linking with the static
library much faster.

Alternatively you can go for the v8 shared library, then you don't need to
link with the other libraries used by V8 (winmm.lib ws2_32.lib).

  scons library=shared
   cl /I..\include /DUSING_V8_SHARED hello_world.cpp v8.lib

If you want a smaller v8.dll and executable you can have them use the shared
version of the Visual C++ runtime library.

  scons library=shared msvcrt=shared
  cl /I..\include /DUSING_V8_SHARED /MD hello_world.cpp v8.lib

This last setup will give you a ~ 6k hello_world.exe and ~ 1.2M v8.dll and
fast turnaround when editing and rebuilding.

Regards,
Søren

On Wed, Sep 9, 2009 at 10:15, Zhiguo Ge <[email protected]> wrote:

> If I execute
>
> >vsvars32.bat  >scons msvcrt=shared env="INCLUDE:%INCLUDE%,LIB:%LIB%"
>
> for compiling V8 and then execute:
>
> cl /Iinclude /DUSING_V8_SHARED hello_world.cpp v8.lib
>
>
>
> The following error happens:
>
>
> hello_world.obj : error LNK2019: unresolved external symbol
> "__declspec(dllimpor
> t) public: __thiscall v8::HandleScope::~HandleScope(void)"
> (__imp_??1HandleScope
> @v8@@q...@xz) referenced in function _main
> hello_world.obj : error LNK2019: unresolved external symbol
> "__declspec(dllimpor
> t) public: __thiscall v8::Context::Scope::~Scope(void)" (
> __imp_??1sc...@context@
> v8@@q...@xz) referenced in function _main
>
>
>
> On Wed, Sep 9, 2009 at 3:00 PM, zhiguo <[email protected]> wrote:
>
>>
>> When comping hello_world.cpp exmaple using Visual Studio 2005 via
>> command cl /Iinclude hello_world.cpp v8.lib, fatal error happens.
>>
>> The following is the error message:
>>
>> c:\Chrome-V8\include\v8.h(494) : fatal error C1001: INTERNAL COMPILER
>> ERROR
>>        (compiler file 'msc1.cpp', line 2701)
>>         Please choose the Technical Support command on the Visual C++
>>         Help menu, or open the Technical Support help file for more
>> information
>>
>> Anyone can give any help? thanks!
>> >>
>>

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to