Thursday, December 22, 2005

How to compile SQLite for Windows

Here you will see how to compile SQLite for Windows with MinGW and without TCL. For bots.

How to install MINGW
  1. Download necessary files from
    At the moment these are:
  2. Install MSYS ("minimal system" - some kind of unix emulator) to D:\MSYS (for example). If you see prompt to execute post install instructions you may say no, because you probably do not have MinGW or MSYS previously installed.
  3. Install MinGW (with GPP option necessary for SQLite) to D:\MSYS\mingw
    Installator didn't work with my proxy, so each file used by MinGW-5.0.0.EXE was downloaded separately and placed into installator's directory. Some downloaded files with newer versions than installer could understand were renamed to make it happy. List of packages required by MinGW-5.0.0.exe installer:
    mingw-runtime-3.9.tar.gz (renamed to mingw-runtime-3.8.tar.gz)
    w32api-3.5.tar.gz (renamed to w32api-3.3.tar.gz)
    gcc-g++-3.4.2-20040916-1.tar.gz (C++ preprocessor required by SQLite configure)
  4. After installer finished your environment is ready. Launch MSYS to start working. Home directory in this case ("cd ~") is located at D:\MSYS\home\yourusername if you need to find out where to place you files from windows to be found in MSYS.
  5. Optionally if you will need to run additional developer tools such as autoconf or automake, these are available through separate msysDTK-1.0.1.exe installer from the sourceforge download page above.
How to compile SQLite
  1. Download SQLite and upack it into subdirectory "sqlite" (for example) of your MSYS home directory (something like D:\MSYS\home\techtonik in my case)
  2. Launch MSYS
  3. cd sqlite
  4. mkdir bld; cd bld
  5. ../configure --disable-tcl
  6. This will create "tsrc" directory with all necessary files to compile SQLite
    make target_source
    cd tsrc
  7. Since there is no TCL libraries, tclsqlite.c should be removed to avoid errors during compilation (this is purely optional)
    mv tclsqlite.c tclsqlite.c.unused
  8. Compile sources with a some optimization (-O2 flag).
    gcc -O2 -DNDEBUG=1 -DTHREADSAFE=1 -c *.c
  9. Link compiled object (*.o) files to make sqlite3.exe (-s tell gcc to strip additional info used for debug)
    gcc -s -o sqlite3 *.o
  10. Remove shell.o object file used as entry point for command line utility. Useless for DLL.
    rm shell.o
  11. Link compiled object (*.o) files to make .dll The command below tells GCC to link all object files into one shared library (for windows it is .dll) and make functions listed in .def available for use to external programs (export). sqlite3.def file can be found in official distribution
    gcc -shared -s -o sqlite3.dll *.o *.def
  12. There is one more thing you may need in future if you would like to compile other programs with SQLite support. It is import library. To make one for MinGW (called libsqlite3.dll.a) link .dll with command
    gcc -shared -s -o sqlite3.dll *.o *.def -Wl,--out-implib,libsqlite3.dll.a
  13. Wrap release.
    mkdir ../release
    cp sqlite3.dll sqlite3.exe libsqlite3.dll.a sqlite3.h ../release
    cd ../release
That's all. If you want reduce the size of .dll by several kbytes use strip --strip-unneeded command. By default strip will remove all symbols from file, but with this key it doesn't remove information needed for .dll relocation.

Ready to use files for SQLite 3.3.17 are available at

Saturday, December 03, 2005

About Zend and PHP —Āollaboration

What you are going to read in this post (if you decide to continue) is my sole IMHO, gathered from those little bits of information I ocassionally catch on the web. I do not communicate with developes and my vision is often filtered through the prism of negative positivism and critic to make the dark side of the facts more visible (I am not original here). Somebody may call it FUD, but on the other side somebody has to be evil and spit acid on behalf of good. Here is the vision of the Zend story, which may or may not be true.

Zend makes money. That's all I can say. Not a bad goal, but it took wrong side IMHO. Perhaps it was since the beginning, when folks decided to sell engine itself and not PHP, but the situation changed with PHP took over the web and Zend has to admit it. Quickly guys realized that engine itself is not very popular and PHP quickly overruns the budget for its support and development on a full time basis. Perhaps it was the time when Zend appeared on the web scene proposing PHP services, such as famous Zend Studio. Well, I've never used Zend Studio, because it was just too expensive for me and simple Far Manager + Colorer was more than sufficient for my needs. Of course, Zend needs money to support all PHP.NET infrastructure, developers, to promote it's products, but.. it seems that Zend more concerned with the money than with anything else, making chaotic PHP users community a fortunate third party instrument for their goals. Perhaps they were dragged to the "money for money" road by these "enterprise" mindmakers and business suits, but this doesn't make things better. It is rather obvious that Zend is under the pressure these days. The great struggle enforces Zend to take a decision and I do not think this decision will be good for those, who was inspired by README.CVS-RULES to elaborate in the past. Neutrality was the primary guide of core PHP developers from start and we all were excited to participate and make this world a little better.

Global trust what could be easy to learn is also easy to lose. I do not believe PHP license was intended to hurt or protect anyone's rights, but rather expressed trust to core PHP developers and to their intentions from those, who released scripts with it's terms. But GPL folks from one side and lawsuits other both want to formalize development process to degree when human relations will be absolutely ruined with an aim to feed servants of law and a bigger players behind. After some experiments with communities I must admit that your professional skills do not play any significant role when there is a real person, who just doesn't like you on receiver side - but this is another story with some peanuts about commercial social engineering, though some aspects of it directly influence current state of business with Zend. I'd like to recommend this company to provide more visibility into future plans, feel responsibility for the buzzwords, support PHP.NET and collaboration from developer's side.

Detect installed MSXML version

MSXML version check can be done with the help of online MSXML version sniffer, which works from within IE. See this link for example. Unfortunately, it does not tell you the exact version of MSXML with service pack installed. If you need service pack info - you may use the following information from Microsoft and the script below.

----- msxml_detect_versions.js ---
// display versions of msxml .dll files

var fso = new ActiveXObject("Scripting.FileSystemObject");
var WindowsFolder = 0 , SystemFolder = 1, TemporaryFolder = 2;
var system32 = fso.GetSpecialFolder(SystemFolder);

function ReportSystem32File(filename)
var s = filename;
var system32file = fso.BuildPath(system32, filename);
if (fso.FileExists(system32file))
s += " \tversion\t " + fso.GetFileVersion(system32file);
s += " \tdoes not exist";

ReportSystem32File("msxml.dll") + "\n" +
ReportSystem32File("msxml2.dll") + "\n" +
ReportSystem32File("msxml3.dll") + "\n" +
ReportSystem32File("msxml4.dll") + "\n" +
ReportSystem32File("msxml5.dll") + "\n" +
ReportSystem32File("msxml6.dll") + "\n" +
"\n" + "For information about versions of MS XML parser " +
"\n" + "corresponding to above file version numbers see " +
"\n" + ""
// techtonik// $Date$
----- msxml_detect_versions.js ---

Wednesday, October 26, 2005

Zend, Eclipse and DLTK

Why abandon PHP cause? I am a little bit concerned about Zend future and direction PHP takes from. I would like to see development of PHP itself more vibrant in terms of community support. Quality assurance technologies, new development instrumentation to overcome political PHP problems when new released versions are not compatible with the old ones - when API and quirks notices are growing bigger and bigger without any hope of refactoring. Majority of the tools available from PHP.NET site are outdated and even if considered minimally useful they definitely could be better. If only Zend could support full-time developers to support PHP.NET and community services like IBM does for Eclipse.

Zend is missing opportunities drowned in self-promotions in enterprise market. Should be good for them, but it needs to pay more attention to developers and PHP community. Zend seems to be a bunch of good folks, but also the ones who either very cautious, or do not have trust or resources to invest in communiy projects, or lack some essential management, market analysis skills used to keep in touch with the rest of the world to forecast and interpret the vision of PHP from outside.

Take a look at this initiatives that are quite dead and seem to be promoted only as a plug for community demands.

I could only hope that Zend could crawl out from this crisis and receive good support from developers and financial companies to promote and bring joy of easy and fast application development to many of us. It is hard for a company who survives by selling products which ease the development, but another models of evolution are still possible.

I hope that the example of Eclipse success will make Zend think about elaboration on a global scale to reach common goals. Like support in the following project.

As for PHP freelancer and enthusiast if I'd be asked "Who is Zend?" I would tell "Zend's dead, baby. Zend's dead."

Tuesday, October 18, 2005

PHP PEAR File SearchReplace

If you're not a PHP programmer the following info is a complete waste of time. You've been warned.

To tell the truth I've almost finished writing another "Why I dislike PEAR?" article, but under a fit of creativity I've completely forgot what I want to tell in the first place. So I stripped all spicy stuff and left only fruits.

Let me introduce my tool written by Richard Heyes ( ). Very useful PHP library for filtering files, bunch of .html or sources all at once. It is a low-level analog of numerous "Search and Replace" utilities. Well written articles about how to use it are here:;1186595404;pp;2;fp;2;fpid;76768

The main flaw in this library that it doesn't support Search without Replace. By calling doSearch() you immediately start write modifications. No preview, no read-only grep. This may become quite dangerous and was meant to be changed in version 2 or even in another new package that was proposed , but the proposal has been rejected. That's why I disliked PEAR. There is no way to change API even though this API is a bug in the first place. It was also not possible to release new refactored version with new API without the approval. You have to be nice and polite and even then nobody guarantees that your arguments are acceptable. The method for search without replace could be easily added if not this PEAR bureaucracy and backwards compatibility talks.

Since a lot of time has passed and I still can't release a package, it will be good to say something about planned modifications and let people use proper API to avoid possible conflicts in the future. I am not able to support PEAR packages anymore, because I've switched to SVN and Python (sorry), moreover and I do not know any convenient CVS tools that work through the proxy, but just in case somebody will get the courage to take over development my last advice to those who still use this library.

If you intend to use this package in future - use doReplace() method instead of doSearch(). doReplace() method is not documented, because 1.0.1 doesn't have it, but it more accurately describes what SearchReplace() do. It may happen that in futer doSearch() will be used just for search and statistics collection. Now that you've been warned you may edit your scripts with the goal for better future compatibility in mind (sorry, couldn't resist to include usual marketing crap).