Cannot build 32-bit V8 on 64-bit Windows

2,141 views
Skip to first unread message

Corey

unread,
Aug 31, 2010, 8:17:39 PM8/31/10
to v8-users
Hey, I'm a little new to V8, but I'm trying to use it in a pet project
and I simply cannot get V8 to build as 32-bit on my system. In fact,
in order to get it to build at all I had to change tools/utils.py to
lower() the platform.architecture() (because it was returning 'AMD64'
instead of 'amd64').

I'm running Windows 7 Home Premium 64-bit, with VC10.

Attempting to compile as 32-bit returns this error:

C:\Users\Corey\v8>scons arch=ia32 verbose=on
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Foobj\release\dtoa-config.obj /c src\dtoa-config.c /WX /wd4018 /
wd4244 /MT /
O2 /GL /DWIN32 /DV8_TARGET_ARCH_IA32 /D_USE_32BIT_TIME_T /
DENABLE_VMSTATE_TRACKI
NG /DENABLE_LOGGING_AND_PROFILING /DENABLE_DEBUGGER_SUPPORT /Isrc /Zi
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

dtoa-config.c
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE
\crtdefs.h(463) :
fatal error C1189: #error : You cannot use 32-bit time_t
(_USE_32BIT_TIME_T) wi
th _WIN64
scons: *** [obj\release\dtoa-config.obj] Error 2
scons: building terminated because of errors.

Corey

unread,
Sep 1, 2010, 1:52:12 AM9/1/10
to v8-users
Update:
I've managed to get it to compile, but not link, using this command
(thanks to help from the Wiki):

scons mode=debug library=shared env="PATH:C:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\bin;C:\Program Files
(x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files
(x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files
(x86)\Microsoft Visual Studio 10.0\Common7\Tools,INCLUDE:C:\Program
Files (x86)\Microsoft Visual Studio 10.0\VC\include;C:\Program Files
(x86)\Microsoft SDKs\Windows\v7.0A\Include;C:\Program Files
(x86)\Microsoft SDKs\Windows\v7.0A\Include,LIB;C:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files
(x86)\Microsoft SDKs\Windows\v7.0A\Lib;"

The error I get when linking is this:

LIBCMTD.lib(crt0dat.obj) : fatal error LNK1112: module machine type
'x64' conflicts with target machine type 'X86'

I've check the environment paths many times to make sure they're set
to the x86 versions, and I've made sure that the build script is
attempting to build as 'ia32' but nothing seems to work.

Søren Gjesse

unread,
Sep 1, 2010, 3:02:17 AM9/1/10
to v8-u...@googlegroups.com
Hi,

The AMD64/amd64 think on Windows 7 should be fixed in r5378.

Regarding the linking problem I suggest that you use the "Visual Studio 2010 Command Prompt" shortcut (assuming that Visual Studio 2010 has one) or run

> :C:\Program Files
(x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat x86

at a standard command prompt (assuming that Visual Studio 2010 still supplies "vcvarsall.bat". Having done that you can shorten your compile command

> scons mode=debug library=shared env="PATH:%PATH%,LIB=%LIB%,INCLUDE=%INCLUDE%"

Have you tried a a static library or the x64 build (passing amd64 to vcvarsall.bat should set up the environment variables for a 64-bit).

Regards,
Søren

Corey

unread,
Sep 1, 2010, 3:11:56 AM9/1/10
to v8-users
Yeah, I switched to the bleeding edge and found the AMD64/amd64
problem fixed.

Well, I tried the VC++ x86 setup batch a couple times already, with no
luck, and I initially tried that shorter env parameter which didn't
work at all (scons couldn't find the compiler then).

Ah, compiling as a static library worked just fine, I don't know why I
didn't try that, thank you!

On Sep 1, 2:02 am, Søren Gjesse <sgje...@chromium.org> wrote:
> Hi,
>
> The AMD64/amd64 think on Windows 7 should be fixed in
> r5378<http://code.google.com/p/v8/source/detail?r=5378>
> .

Corey

unread,
Sep 1, 2010, 3:36:13 AM9/1/10
to v8-users
Trying to build 32-bit on 64-bit Windows is turning into a nightmare.
Okay so, using static libraries just appears to give linking errors in
the application I'm trying to use it in:

1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__timeGetTime@0 referenced in function "public: void
__thiscall v8::internal::Time::SetToCurrentTime(void)" (?
SetToCurrentTime@Time@internal@v8@@QAEXXZ)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__bind@12 referenced in function "public: virtual bool
__thiscall v8::internal::Win32Socket::Bind(int)" (?
Bind@Win32Socket@internal@v8@@UAE_NH@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__htons@4 referenced in function "public: virtual bool
__thiscall v8::internal::Win32Socket::Bind(int)" (?
Bind@Win32Socket@internal@v8@@UAE_NH@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__htonl@4 referenced in function "public: virtual bool
__thiscall v8::internal::Win32Socket::Bind(int)" (?
Bind@Win32Socket@internal@v8@@UAE_NH@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__listen@8 referenced in function "public: virtual bool
__thiscall v8::internal::Win32Socket::Listen(int)const " (?
Listen@Win32Socket@internal@v8@@UBE_NH@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__accept@12 referenced in function "public: virtual class
v8::internal::Socket * __thiscall
v8::internal::Win32Socket::Accept(void)const " (?
Accept@Win32Socket@internal@v8@@UBEPAVSocket@23@XZ)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__freeaddrinfo@4 referenced in function "public: virtual
bool __thiscall v8::internal::Win32Socket::Connect(char const *,char
const *)" (?Connect@Win32Socket@internal@v8@@UAE_NPBD0@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__connect@12 referenced in function "public: virtual bool
__thiscall v8::internal::Win32Socket::Connect(char const *,char const
*)" (?Connect@Win32Socket@internal@v8@@UAE_NPBD0@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__getaddrinfo@16 referenced in function "public: virtual
bool __thiscall v8::internal::Win32Socket::Connect(char const *,char
const *)" (?Connect@Win32Socket@internal@v8@@UAE_NPBD0@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__closesocket@4 referenced in function "public: virtual
bool __thiscall v8::internal::Win32Socket::Shutdown(void)" (?
Shutdown@Win32Socket@internal@v8@@UAE_NXZ)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__shutdown@8 referenced in function "public: virtual bool
__thiscall v8::internal::Win32Socket::Shutdown(void)" (?
Shutdown@Win32Socket@internal@v8@@UAE_NXZ)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__send@16 referenced in function "public: virtual int
__thiscall v8::internal::Win32Socket::Send(char const *,int)const " (?
Send@Win32Socket@internal@v8@@UBEHPBDH@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__recv@16 referenced in function "public: virtual int
__thiscall v8::internal::Win32Socket::Receive(char *,int)const " (?
Receive@Win32Socket@internal@v8@@UBEHPADH@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__setsockopt@20 referenced in function "public: virtual
bool __thiscall v8::internal::Win32Socket::SetReuseAddress(bool)" (?
SetReuseAddress@Win32Socket@internal@v8@@UAE_N_N@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__WSAStartup@8 referenced in function "public: static bool
__cdecl v8::internal::Socket::Setup(void)" (?
Setup@Socket@internal@v8@@SA_NXZ)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__WSAGetLastError@0 referenced in function "public: static
int __cdecl v8::internal::Socket::LastError(void)" (?
LastError@Socket@internal@v8@@SAHXZ)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__ntohs@4 referenced in function "public: static unsigned
short __cdecl v8::internal::Socket::NToH(unsigned short)" (?
NToH@Socket@internal@v8@@SAGG@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__ntohl@4 referenced in function "public: static unsigned
int __cdecl v8::internal::Socket::NToH(unsigned int)" (?
NToH@Socket@internal@v8@@SAII@Z)
1>v8_g.lib(platform-win32.obj) : error LNK2019: unresolved external
symbol __imp__socket@12 referenced in function "public: __thiscall
v8::internal::Win32Socket::Win32Socket(void)" (??
0Win32Socket@internal@v8@@QAE@XZ)

Søren Gjesse

unread,
Sep 1, 2010, 6:49:59 AM9/1/10
to v8-u...@googlegroups.com
Looks as if you are missing tem libraries winmm.lib and ws2_32.lib when linking your application. Does the sample shell link OK (scons mode=debug sample=shell ...)?

Regards,
Søren

Corey

unread,
Sep 1, 2010, 12:04:06 PM9/1/10
to v8-users
Yeah, I added those two libraries in and it compiled fine...however
now I get a segfault whenever mode code tries to compile some
Javascript (even a simple Hello World).

And yes, the shell sample linked fine.

Søren Gjesse

unread,
Sep 1, 2010, 4:31:02 PM9/1/10
to v8-u...@googlegroups.com
If you get segfults in an application which embeds V8 you might be missing a handle scope or have no current context. If you use a debug build you might hit asserts which could be helpfull.

Regards,
Søren

Corey

unread,
Sep 1, 2010, 8:09:12 PM9/1/10
to v8-users
Oh man, I realized my paths in my environment had a semi-colon after
LIBS instead of a colon, causing the whole issue haha. I probably
should have checked over the paths after I copied them from the wiki.

Yeah, I think I'm having an issue with the context, because I now have
proper shared libraries compiled and everything. I think the issue is
that the context is in a class and the code that is compiling the
Javascript code is elsewhere.

Corey

unread,
Sep 2, 2010, 5:35:27 PM9/2/10
to v8-users
Okay, now my code breaks on this assertion when trying to create a
context scope:

ASSERT(location_ != NULL);

In this piece of code (handles-inl.h):

template <class T>
inline T* Handle<T>::operator*() const {
ASSERT(location_ != NULL);
ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue);
return *BitCast<T**>(location_);
}
Reply all
Reply to author
Forward
0 new messages