Sunday, March 26, 2006

wxtide32 build with mingw

Noticed that wxtide32 a windows port of xtide includes source code. The author uses lcc to compile but I wanted to try mingw. During the process I learned a bit about windows programming, resource files, and resource file editors.

Tools that I used:
01. firefox for research
02. MinGW and MSYS
03. vim6
04. olly debugger
05. diff and patch
06. xnresourceeditor
07. Gorcjorg.zip resource compiler

The source files are included with the wxtide distribution and compressed with 7-zip after unzipping, I started trying to compile each .c file. For the most part there were no problems and the error messages from MinGW were helpful.

I spent a quite some time trying to figure out a problem compiling WXTide32.RC with windres.exe which gave parse errors at various lines. My first approach was to comment out the offending lines which worked. Then I tried the GoRC.exe resource compiler which had no problems with the source. At the time I didnt know anything about resource files and after some research on the web had no more insight about how to debug the problem with windres.exe. I tried a couple of resource tools, resource hacker and resource editor but they seemed to have no problems with the source. Eventually I realized that the header file had some definition mismatches with the .rc file and corrected it in the resource file and two of the .c files.

I made several mistakes while editing the Makefile and getting the link to work. After the application was linked, it died at runtime. I ran it through the olly debugger and there was a message about tide2idx so removed it from the object linking. After that the application ran with the addition of some input files. Later I realized that there was some documentation about how to compile the application but was not aware of it during my initial efforts.

The process was educational and I would recommend it to anyone who is interested in c programming using free compilers. The failure of windres.exe to compile WXTide32.rc was valid and I decided to use diff and patch to make the necessary changes to the original source code so that it would compile with MinGW. Although the author uses lcc which is free for non commercial use, getting wxtide32 to compile using MinGW was a good idea after all.

Wednesday, March 08, 2006

building firefox 1.5 with cygwin

Begin by reading this post which covers the steps in detail

http://gemal.dk/mozilla/build.html

After reading over the documentation, I decided to try to build firefox with a default cygwin environment and using the cygwin shell.

Here are the steps:


01. download wintools.zip from

http://ftp.mozilla.org/pub/mozilla.org/mozilla/source/wintools.zip

create the build directory for the tools

mkdir c:\mozilla
mkdir c:\mozilla\moztools

unzip to a temp location for example c:\temp
result c:\temp\wintools
cd c:\temp\wintools\buildtools\windows
install.bat
run this script and use c:\mozilla\moztools


02. go to the cygwin site and download the entire distribution which is 630 MBytes

http://www.cygwin.com/setup.exe

I know it is possible to use a subset of the cygwin distribution but
the setup program is hard to explain and not easy for a novice
Run the setup.exe program, choose a mirror and download.
You can install at the same time but I prefer to install after
the download. For the install location use c:\cygwin


03. Download the firefox 1.5 source

ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5.0.1/source/

ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/1.5/source/firefox-1.5-source.tar.bz2

with the project notes here

http://developer.mozilla.org/en/docs/Download_Mozilla_Source_Code


I use 7-zip and unzipped the file in a temp location. Move the mozilla subfolder to
c:\mozilla with the result being c:\mozilla\mozilla


04. Use the cygwin shell and cygwin env for the build

open a cygwin shell

cd /cygdrive/c/mozilla/mozilla

MOZTOOLS=/cygdrive/c/mozilla/moztools
export MOZ_TOOLS

PATH=$PATH:$MOZ_TOOLS/bin


05. Here is my example .mozconfig file which needs to be created in
c:\mozilla\mozilla with the result being c:\mozilla\mozilla\.mozconfig


$topsrcdir/browser/config/mozconfig
CFLAGS=-mno-cygwin
CXXFLAGS=-mno-cygwin
CC=gcc
CXX=g++
CPP=cpp
AS=as
LD=ld
ac_add_options --enable-application=browser
ac_add_options --disable-accessibility
ac_add_options --disable-activex




06. Execute the build, prepare for a 6 hour wait

make -f client.mk build_all_depend


If everything goes well you will find the firefox executable in

c:\mozilla\mozilla\dist\bin\firefox.exe