Cross Compiling static and shared Win32 version PoDoFo under Debian Lenny

I tried many times to compile Podofo 0.9 and svn trunk under Windows 7 + MinGW32, but always failed(I have successfully compiled static and shared version PoDoFo 0.84 under the same environment). So I decided to do the job under Linux with MinGW cross compiling environment.
After the job, Build MinGW Cross Compiling Environment under Debian Lenny, very first time, I tried to compile PoDoFo 0.9 and svn trunk(r1445), and finally both succeed.
download and unpack
wget http://ncu.dl.sourceforge.net/project/podofo/podofo/0.9/podofo-0.9.0.tar.bz2
tar jxf podofo-0.9.0.tar.bz2

Compile Win32 Static Version
mkdir podofo-0.9.0-win32-static
cd podofo-0.9.0-win32-static
cmake -DCMAKE_TOOLCHAIN_FILE=/opt/mingw/usr/i686-pc-mingw32/share/cmake/mingw-cross-env-conf.cmake ../podofo-0.9.0 -DFREETYPE_INCLUDE_DIR_FT2BUILD:PATH=/opt/mingw/usr/i686-pc-mingw32/include/freetype2 -DFREETYPE_INCLUDE_DIR_FTHEADER:PATH=/opt/mingw/usr/i686-pc-mingw32/include -DFREETYPE_LIBRARY_RELEASE:FILEPATH=/opt/mingw/usr/i686-pc-mingw32/lib/libfreetype.a -DWIN32=1 -DCMAKE_INSTALL_PREFIX:PATH=/root/podofo-0.9.0-win32-static
make
make install

Maybe because of the bug of the podofo-0.9.0/cmake/modules/FindFREETYPE.cmake, I had to explicit add the freetype info to cmake, if you execute the following command,
cmake -DCMAKE_TOOLCHAIN_FILE=/opt/mingw/usr/i686-pc-mingw32/share/cmake/mingw-cross-env-conf.cmake ../podofo-0.9.0-win32-static -DWIN32=1 -DCMAKE_INSTALL_PREFIX:PATH=/root/podofo-0.9.0-win32-static
you will get the following error message, even though you have already installed FreeType correctly,

CMake Error at /usr/share/cmake-2.6/Modules/FindPackageHandleStandardArgs.cmake:52 (MESSAGE):
Could NOT find FREETYPE
Call Stack (most recent call first):
cmake/modules/FindFREETYPE.cmake:75 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:354 (FIND_PACKAGE)

and because Linux is case sensitive, so I got the following two error messages,
Scanning dependencies of target ContentParser
[ 57%] Building CXX object test/ContentParser/CMakeFiles/ContentParser.dir/main.cpp.obj
Linking CXX executable ContentParser.exe
/opt/mingw/usr/lib/gcc/i686-pc-mingw32/4.5.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lWS2_32
/opt/mingw/usr/lib/gcc/i686-pc-mingw32/4.5.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lWS2_32
/opt/mingw/usr/lib/gcc/i686-pc-mingw32/4.5.2/../../../../i686-pc-mingw32/bin/ld: cannot find -lWS2_32
collect2: ld returned 1 exit status
make[2]: *** [test/ContentParser/ContentParser.exe] Error 1
make[1]: *** [test/ContentParser/CMakeFiles/ContentParser.dir/all] Error 2
make: *** [all] Error 2

(to solve it, just run the following command
ln -s /opt/mingw/usr/i686-pc-mingw32/lib/libws2_32.a /opt/mingw/usr/i686-pc-mingw32/lib/libWS2_32.a
)
and

Scanning dependencies of target helloworld-base14
[100%] Building CXX object examples/helloworld-base14/CMakeFiles/helloworld-base14.dir/helloworld-base14.cpp.obj
/opt/test/podofo-0.9.0/examples/helloworld-base14/helloworld-base14.cpp:31:21: fatal error: BaseTsd.h: No such file or directory
compilation terminated.
make[2]: *** [examples/helloworld-base14/CMakeFiles/helloworld-base14.dir/helloworld-base14.cpp.obj] Error 1
make[1]: *** [examples/helloworld-base14/CMakeFiles/helloworld-base14.dir/all] Error 2
make: *** [all] Error 2

(
to solve it, just run the following command
ln -s /opt/mingw/usr/i686-pc-mingw32/include/basetsd.h /opt/mingw/usr/i686-pc-mingw32/include/BaseTsd.h

)

and when compiled podofoimg2pdf, another error message met,

Scanning dependencies of target podofoimg2pdf
[ 86%] Building CXX object tools/podofoimg2pdf/CMakeFiles/podofoimg2pdf.dir/podofoimg2pdf.cpp.obj
[ 86%] Building CXX object tools/podofoimg2pdf/CMakeFiles/podofoimg2pdf.dir/ImageConverter.cpp.obj
Linking CXX executable podofoimg2pdf.exe
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_write_raw_data':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:321: undefined reference to `_jpeg_write_raw_data'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_finish_compress':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:328: undefined reference to `_jpeg_finish_compress'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_set_colorspace':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:288: undefined reference to `_jpeg_set_colorspace'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_create_compress':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:265: undefined reference to `_jpeg_CreateCompress'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_set_defaults':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:282: undefined reference to `_jpeg_set_defaults'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_write_tables':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:334: undefined reference to `_jpeg_write_tables'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_set_quality':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:294: undefined reference to `_jpeg_set_quality'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_suppress_tables':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:301: undefined reference to `_jpeg_suppress_tables'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_start_compress':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:307: undefined reference to `_jpeg_start_compress'
/opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a(tif_jpeg.o): In function `TIFFjpeg_write_scanlines':
/opt/mingw/tmp-tiff/tiff-3.9.4/libtiff/tif_jpeg.c:314: undefined reference to `_jpeg_write_scanlines'
collect2: ld returned 1 exit status
make[2]: *** [tools/podofoimg2pdf/podofoimg2pdf.exe] Error 1
make[1]: *** [tools/podofoimg2pdf/CMakeFiles/podofoimg2pdf.dir/all] Error 2
make: *** [all] Error 2

from the message, I know it need Jpeg library, checking podofo-0.9.0-win32-static/tools/podofoimg2pdf/CMakeFiles/podofoimg2pdf.dir/link.txt
/opt/mingw/usr/bin/i686-pc-mingw32-g++ -O3 -DNDEBUG CMakeFiles/podofoimg2pdf.dir/podofoimg2pdf.cpp.obj CMakeFiles/podofoimg2pdf.dir/ImageConverter.cpp.obj -o podofoimg2pdf.exe -Wl,--out-implib,libpodofoimg2pdf.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -L/opt/test/podofo-win32/src -lpodofo /opt/mingw/usr/i686-pc-mingw32/lib/libz.a /opt/mingw/usr/i686-pc-mingw32/lib/libjpeg.a -lpthread -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lWS2_32 /opt/mingw/usr/i686-pc-mingw32/lib/libfreetype.a /opt/mingw/usr/i686-pc-mingw32/lib/libpng.a /opt/mingw/usr/i686-pc-mingw32/lib/libz.a /opt/mingw/usr/i686-pc-mingw32/lib/libjpeg.a -lpthread -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lWS2_32 /opt/mingw/usr/i686-pc-mingw32/lib/libfreetype.a /opt/mingw/usr/i686-pc-mingw32/lib/libpng.a /opt/mingw/usr/i686-pc-mingw32/lib/libtiff.a
it already includes libjpeg.a, I do not know why, but have to append some code to let it works, and finally the content of link.txt is as following,
/opt/mingw/usr/bin/i686-pc-mingw32-g++ -O3 -DNDEBUG CMakeFiles/podofoimg2pdf.dir/podofoimg2pdf.cpp.obj CMakeFiles/podofoimg2pdf.dir/ImageConverter.cpp.obj -o podofoimg2pdf.exe -Wl,--out-implib,libpodofoimg2pdf.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -L/opt/test/podofo-win32/src -lpodofo /opt/mingw/usr/i686-pc-mingw32/lib/libz.a /opt/mingw/usr/i686-pc-mingw32/lib/libjpeg.a -lpthread -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lWS2_32 /opt/mingw/usr/i686-pc-mingw32/lib/libfreetype.a /opt/mingw/usr/i686-pc-mingw32/lib/libpng.a /opt/mingw/usr/i686-pc-mingw32/lib/libz.a /opt/mingw/usr/i686-pc-mingw32/lib/libjpeg.a -lpthread -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lWS2_32 /opt/mingw/usr/i686-pc-mingw32/lib/libfreetype.a /opt/mingw/usr/i686-pc-mingw32/lib/libpng.a -L/opt/mingw/usr/i686-pc-mingw32/lib -ltiff -ljpeg -lz .
and now, the Win32 static version PoDoFo 0.9.0 created and installed into /root/podofo-0.9.0-win32-static folder.
To compile shared version, we need do some modification, by default, /opt/mingw/usr/i686-pc-mingw32/share/cmake/mingw-cross-env-conf.cmake has set BUILD_SHARED_LIBS option as OFF, so you need set it ON
mkdir podofo-0.9.0-win32-shared
cd podofo-0.9.0-win32-shared
cmake -DCMAKE_TOOLCHAIN_FILE=/opt/mingw/usr/i686-pc-mingw32/share/cmake/mingw-cross-env-conf.cmake ../podofo-0.9.0 -DFREETYPE_INCLUDE_DIR_FT2BUILD:PATH=/opt/mingw/usr/i686-pc-mingw32/include/freetype2 -DFREETYPE_INCLUDE_DIR_FTHEADER:PATH=/opt/mingw/usr/i686-pc-mingw32/include -DFREETYPE_LIBRARY_RELEASE:FILEPATH=/opt/mingw/usr/i686-pc-mingw32/lib/libfreetype.a -DWIN32=1 -DCMAKE_INSTALL_PREFIX:PATH=/root/podofo-0.9.0-win32-shared -DBUILD_SHARED_LIBS:BOOL=TRUE -DPODOFO_BUILD_SHARED=1
make
make install

and when Creating library file: libpodofo.dll.a will get the same error as podofoimg2pdf, and the solution is also same.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride

Code::Blocks Windows setup package download mirror

I am studying PoDoFo now, and want a better IDE to work with MinGW, after some search, I decided to use Code::Block(aka CB or CodeBlocks). At office I have easily downloaded the Windows setup package, but when I tried to download at home several times without success and the error message is Too many Clients!.
So I uploaded it to my project hosting at Google Code,
please use another mirror.

P.S.

Code::Blocks is a open source, cross platform, free C++ IDE built to meet the most demanding needs of its users. It is designed to be very extensible and fully configurable.
Finally, an IDE with all the features you need, having a consistent look, feel and operation across platforms.
Built around a plugin framework, Code::Blocks can be extended with plugins. Any kind of functionality can be added by installing/coding a plugin. For instance, compiling and debugging functionality is already provided by plugins!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride

LibJpeg vs LibJpeg-turbo

libjpeg is a library written entirely in C which contains a widely-used implementation of a JPEG decoder, JPEG encoder and other JPEG utilities. This library is maintained by the Independent JPEG Group.

libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG compression and decompression. libjpeg-turbo is generally 2-4x as fast as the unmodified version of libjpeg, all else being equal(for non-grayscale JPEG compression and decompression, libjpeg-turbo is between 1.8x and 4.5x as fast as libjpeg v6b).

libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but the TigerVNC and VirtualGL projects made numerous enhancements to the codec, including improved support for Mac OS X, 64-bit support, support for 32-bit and big endian pixel formats (RGBA, ABGR, etc.), accelerated Huffman encoding/decoding, and various bug fixes. The goal was to produce a fully open source codec that could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL and TurboVNC. libjpeg-turbo generally achieves 80-120% of the performance of TurboJPEG/IPP. It is faster in some areas but slower in others(for non-grayscale JPEG compression and decompression, libjpeg-turbo 64-bit is between 80% and 118% as fast as TurboJPEG/IPP. libjpeg-turbo 32-bit is between 60% and 93% as fast as TurboJPEG/IPP. libjpeg-turbo’s primary weakness relative to TurboJPEG/IPP is 32-bit performance, particularly on Intel processors and even more particularly on legacy Intel processors. This is largely due to the Huffman encoder/decoder running out of registers and having to swap some inner loop variables back and forth from memory).

In one word, libjpeg-turbo is a fork of libjpeg that uses SIMD instructions to accelerate JPEG encoding and decoding.

btw, projects such as Mozilla and fedora switched to libjpeg-turbo in 2010.

References,
libjpeg-turbo HomePage
Independent JPEG Group’s JPEG software release 6b
with x86 SIMD extension for IJG JPEG library version 1.02

Independent JPEG Group(IJG)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • blogmarks
  • blogtercimlap
  • connotea
  • DotNetKicks
  • Fark
  • Fleck
  • Gwar
  • Haohao
  • IndianPad
  • Internetmedia
  • LinkaGoGo
  • MyShare
  • Netscape
  • NewsVine
  • Rec6
  • Reddit
  • Scoopeo
  • Slashdot
  • StumbleUpon
  • Technorati
  • Webride