Archive for the 'tutorial' Category

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

Build MinGW Cross Compiling Environment under Debian Lenny

My environment is 32-bit Debian 5.0.5(2.6.26-2-686), a guest installed on VirtualBox.
The job refers to the tutorial of MinGW cross compiling environment.

1. Prepare Requirements,

aptitude install -R autoconf automake bash bison bzip2 \
cmake flex g++ intltool make sed \
libtool libltdl-dev openssl libssl-dev \
libxml-parser-perl patch perl \
pkg-config scons unzip wget \
xz-utils yasm

but I can not find xz-utils, so I compile and install it from source code,

wget http://tukaani.org/xz/xz-5.0.1.tar.gz
tar zxf xz-5.0.1.tar.gz
cd xz-5.0.1
./configure --prefix /usr
make
make install

2. Download and Unpack
wget https://bitbucket.org/vog/mingw-cross-env/downloads/mingw-cross-env-2.19.tar.gz
tar zxf mingw-cross-env-2.19.tar.gz
3.System-wide Installation
mv mingw-cross-env-2.19 /opt/mingw
cd /opt/mingw

4.Build mingw-cross-env
I got some error when do the building job,

1>, Autoconf need 2.62, but the version I installed is 2.61, so I have to install autoconf from source code.

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.bz2
tar jxf autoconf-2.68.tar.bz2
cd autoconf-2.68
./configure --prefix=/usr
make
make install

2> when compile glib, I got the following error,

./configure: line 10181: syntax error near unexpected token `2.2′
./configure: line 10181: `LT_PREREQ(2.2)’
make[1]: *** [build-only-glib] Error 2

after searched, I got the version of Libtool needs at least 2.2, but the version what I have installed is 1.5.26-4, I had to install it from source


wget http://ftp.gnu.org/gnu/libtool/libtool-2.4.tar.gz
tar zxf libtool-2.4.tar.gz
cd libtool-2.4
./configure --prefix=/usr
make
make install

can not access http://www.libgd.org/

[download] gd

Wrong checksum of package gd!
————————————————————
–2011-03-22 22:04:43– http://www.libgd.org/releases/gd-2.0.35.tar.bz2
Resolving www.libgd.org… 213.251.181.15
Connecting to www.libgd.org|213.251.181.15|:80… failed: Connection refused.
–2011-03-22 22:04:43– http://www.libgd.org/releases/oldreleases/gd-2.0.35.tar.bz2
Resolving www.libgd.org… 213.251.181.15
Connecting to www.libgd.org|213.251.181.15|:80… failed: Connection refused.
————————————————————
[log] /opt/mingw/log/gd-download

make: *** [/opt/mingw/usr/installed/gd] Error 1

After search, I got another download location, so I downloaded it and saved it in the pkg folder

wget http://jaist.dl.sourceforge.net/project/buluoos/0.1/src/gd-2.0.35.tar.bz2 -O /opt/mingw/pkg/gd-2.0.35.tar.bz2

then continue the make

Failed to build package openal!
————————————————————
make[3]: *** [CMakeFiles/openal-info.dir/all] Error 2
make[3]: Leaving directory `/opt/mingw/tmp-openal/openal-soft-1.13/build’
make[2]: *** [all] Error 2
make[2]: Leaving directory `/opt/mingw/tmp-openal/openal-soft-1.13/build’
make[1]: *** [build-only-openal] Error 2
make[1]: Leaving directory `/opt/mingw’
real 0m27.641s
user 0m10.549s
sys 0m16.785s
————————————————————
[log] /opt/mingw/log/openal

make: *** [/opt/mingw/usr/installed/openal] Error 1

After manually build OpenAL32, I got the following error,

[ 96%] Built target OpenAL32
Linking C executable openal-info.exe
libOpenAL32.a(dsound.obj):dsound.c:(.text+0×9e0): undefined reference to `_GUID_NULL’
libOpenAL32.a(dsound.obj):dsound.c:(.text+0xa00): undefined reference to `_GUID_NULL’
libOpenAL32.a(dsound.obj):dsound.c:(.text+0xa09): undefined reference to `_GUID_NULL’
libOpenAL32.a(dsound.obj):dsound.c:(.text+0xa12): undefined reference to `_GUID_NULL’
collect2: ld returned 1 exit status
make[2]: *** [openal-info.exe] Error 1
make[1]: *** [CMakeFiles/openal-info.dir/all] Error 2
make: *** [all] Error 2

need modify tmp-openal/openal-soft-1.13/build/CMakeFiles/openal-info.dir/link.txt and add -luuid (seems it is bug, I noticed it patched openal-1-luuid-pkg-config.patch, but no use.).

In fact, if you just want a MinGW cross compile environment, please do not directly execute make, because it has 169 packages, and most of them maybe you do not need at all.
finally, I compiled all 169 packages, and the usr folder is about 2.2G, after the created tar also 580.76M(I use tar cjf i686-pc-mingw32.tar.bz2 usr)

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

Convert html to SWF with Free tools wkhtmltopdf and pdf2swf

wkhtmltopdf is a simple shell utility to convert html to pdf using the webkit rendering engine, and qt.
pdf2swf(part of SWFTOOLS) is A PDF to SWF Converter. Generates one frame per page. Enables you to have fully formatted text, including tables, formulas, graphics etc. inside your Flash Movie. It’s based on the xpdf.
Both of them are open source and can works on multi-platform(cross platform), so If we want to convert a html file or webpage to SWF, we can use wkhtmltopdf to convert html(webpage) to PDF, then use pdf2swf to convert pdf to swf.

reference,

P.S. A simple routine and example(result),
wkhtmltopdf "http://www.grzmobile.com/blog/2009/11/13/integrating-lua-into-an-iphone-app.html?printerFriendly=true" "Integrating Lua into an iPhone App.pdf"
pdf2swf "Integrating Lua into an iPhone App.pdf" "Integrating Lua into an iPhone App.swf"

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