sqlite, hack the code…
So… for about few hours now, I was puzzled on how to get sqlite working on one of our customer centos server. Problem was that all sqlite function were bugging and the sqlite databases couldn’t be queried. A quick php -v on cli, gave me the first indication that sqlite.so file wasn’t properly loading. Actually the repo sqlite install had place the lib files in the wrong directories… after quickly checking the extension dir, i decided to copy over the .so sqlite extension file and reload apache… first try… first failure.. even pointing to the right extension file, the lib couldn’t still be loaded..
that’s where the puzzle started…
After thinking it through and reading on php.net/bugs section, I came to realize that this was simply a bug starting off php 5.1…
So after a while, I decide to retrieve back to an old sqlite version and compile it myself
so
wget -q http://pecl.php.net/get/SQLite-1.0.3.tgz
tar zxvf SQLite-1.0.3.tgz; cd SQLite-1.0.3
phpize
(if you get a phpize error, just do a yum insta php-devel) then retry phpize again
./configure
make
(that’s where I was about to pull my hair, when while compiling the source code, make abruptly stopped with an error 1 and offset error)
this is where we need to hack the C code of sqlite to make it compile with our Centos 5
vi sqlite.c
then comment out this line
static unsigned char arg3_force_ref[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
so this becomes
/* static unsigned char arg3_force_ref[] = {3, BYREF_NONE, BYREF_NONE, BYREF_FORCE }; */
replace then
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, arg3_force_ref)
PHP_FE(sqlite_popen, arg3_force_ref)
to:
function_entry sqlite_functions[] = {
PHP_FE(sqlite_open, third_arg_force_ref)
PHP_FE(sqlite_popen, third_arg_force_ref)
“save - exit”
then make clean
./configure; make; make install
Once that is through with no error
cp modules/sqlite.so To_The.Php.ini.ExtensionDir
then service httpd restart
and voila
easy he.. still got me confused for a second there ![]()