Author: nicdex

building v8 using mingw on windows

By default v8 only builds on MSVC for Windows. It also supports building with mingw, but it is not documented anywhere and I’ve lost some time finding how. So here it is, easy steps for whoever needs it.

Prerequisites

1. v8 source code (of course), in my case I used trunk.

svn checkout http://v8.googlecode.com/svn/trunk/ v8

2. scons (building tool used by v8)

http://prdownloads.sourceforge.net/scons/scons-1.3.0.win32.exe

3. mingw32 (gcc 4.x.x is required to build v8)


binutils-2.20.1-2-mingw32-bin.tar.gz
gcc-full-4.4.0-mingw32-bin-2.tar.lzma
make-3.81-20090914-mingw32-bin.tar.gz
mingwrt-3.15.2-mingw32-dev.tar.gz
mingwrt-3.15.2-mingw32-dll.tar.gz
w32api-3.13-mingw32-dev.tar.gz

You can get those from http://sourceforge.net/projects/mingw/files/.

Building v8 with mingw

1. Using the “toolchain=gcc” command line paremeter doesn’t work, so you need to modify Scons.

a) Open file C:\Python26\Lib\site-packages\scons-1.3.0\SCons\Tool\__init__.py
b) Find the line “if str(platform) == ‘win32’:”
c) Modify the tools lists to use mingw tools instead of msvc tools by default.

Should look something like this once done:

linkers = ['gnulink', 'mslink', 'ilink', 'linkloc', 'ilink32' ]
c_compilers = ['mingw', 'msvc', 'gcc', 'intelc', 'icl', 'icc', 'cc', 'bcc32' ]
cxx_compilers = ['g++', 'msvc', 'intelc', 'icc', 'c++', 'bcc32' ]
assemblers = ['nasm', 'masm', 'gas', '386asm' ]
fortran_compilers = ['g77', 'gfortran', 'ifl', 'cvf', 'f95', 'f90', 'fortran']
ars = ['ar', 'mslib', 'tlib']
other_plat_tools=['msvs','midl']

2. Open a command line (cmd.exe)

3. Set you environment path (if required)


set path=c:\python26;c:\python26\scripts;c:\mingw\bin;%PATH%

4. Build v8


scons mode=debug visibility=default

note: the visibility=default parameter is required otherwise gcc generate a warning (as an error) and the build doesn’t work.

note: currently (revision 4432) only static debug mode works with mingw building, debug=release produce errors (warning as error) and so does library=shared (building dll). Will try to fix this in a next post.

Have fun with v8 😉

Exporting html to excel 2003 and 2007 using utf-8

Using html in Excel is very usefull, because it allows to do easy reporting with nice features like colors, tabular formatting, etc.

First we need to output some headers so the browser will open the ouput with Excel. This works in both 2003 and 2007 :

(pseudo-code)
headers.Add(“Content-Type”, “application/vnd.excel”)
headers.Add(“Content-Disposition”, “attachment;filename=something.xls”)

The tricky thing was the output encoding. In utf-8, it worked in 2007, but not in 2003. In utf-7 it worked in 2003, but not in 2007. In unicode, it did not work at all.

After alot of tries, I finally discovered, that the output must be in utf-8, but we need to output the UTF-8 BOM wich identify the utf-8 byte order. Then it worked perfectly. You need to output this at the beginning of your data :

(pseudo-code)
OutputStream.WriteByte(0xEF);
OutputStream.WriteByte(0xBB);
OutputStream.WriteByte(0xBF);

exceptions and threads with mingw

If you’re having trouble using exceptions and threads with MingW, here is the solution:

1. Add these compiler options:
-mthreads (enable exception support in threads)
-fexceptions (enable exception handling)

2. Get the latest version of gcc (I have the 4.4.0, see the g++ -v ouput below)

It is very important that you check your gcc version and configuration (-v), because the last version I had 3.4.0 did not work even with the -mthreads.


Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.4.0/configure --enable-languages=c,ada,c++,fortran,jav
a,objc,obj-c++ --disable-sjlj-exceptions --enable-shared --enable-libgcj --enable-libgomp --with-dwarf2 --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --prefix=/mingw --with-gmp=/mingw/src/gmp/root --with-mpfr=/mingw/src/mpfr/root --build=mingw32
Thread model: win32
gcc version 4.4.0 (GCC)

I lost a lot of time trying to debug/fix this, so I hope this helps.

X1office.com

X1office est un nouveau service offert par l’entreprise où je travaille. Le type de clientèle visée est la petite et moyenne entreprise.

Voici un résumé des services offerts:

– Boite de courriel Outlook 2007 avec serveur Exchange.

– Service de sauvegarge des données.

– Service Sharepoint.

– Service de synchronisation des mobiles Blackberry.

Vous pouvez voir plus en détails les services offerts sur le site web de X1office au http://www.x1office.com.

Voila 😉

Using dynamic canvas creation with google excanvas using IE

When you are using IE and ExplorerCanvas, dynamically created canvas with document.createElement are not working. They’re are not extending the ExplorerCanvas functionnality by default.

Include this script after excanvas.js in your html header to extend the created element at creation:

if ( /MSIE/.test(navigator.userAgent) )
{
document._createElement = document.createElement;
document.createElement = function( tag )
{
var element = document._createElement( tag );
if ( tag == “canvas” )
{
//width and height are required for initElement
element.width = 1;
element.height = 1;
G_vmlCanvasManager.initElement(element);
}

return element;
}
}

Now you’re dynamically created canvas will actually work. This is surelly not the best way to do it, because of performance overhead, but at least it works. Plus, you rarely use tons of canvas in the same document.

if ( /MSIE/.test(navigator.userAgent) )
{
document._createElement = document.createElement;
document.createElement = function( tag )
{
var element = document._createElement( tag );
if ( tag == “canvas” )
{
//width and height are required for initElement
element.width = 1;
element.height = 1;
G_vmlCanvasManager.initElement(element);
}

return element;
}
}

Reportage sur mon employeur

Voici les trois reportages qui ont été réalisé sur PCMS Conseil, l’entreprise pour laquelle je travaille.

http://www.radio-canada.ca/audio-video/pop.shtml#idMedia=0&urlMedia=/Medianet/2007/RDI2/Telejournal200707262100_1.asx

http://www.radio-canada.ca/audio-video/pop.shtml#urlMedia=http://www.radio-canada.ca/Medianet/2008/CBFT/TelejournalMontreal200802251800_3.asx

http://www.radio-canada.ca/audio-video/pop.shtml#urlMedia=http://www.radio-canada.ca/Medianet/2009/RDI2/TelejournalSurRdi200904231700_4.asx