Compile 32 bit MySQL C application on 64 bit Ubuntu

January 21st, 2010 | Tags:

I wrote a small program in C, using MySQL C API. This program was compiled on x86 machine. After a hardware upgrade and installing Ubuntu x64, compiling the program error occurred:

segfault at 1 ip 00007fdcf44f4a29 sp 00007fff19659078 error 4 in[7fdcf4451000+166000]

After a research in diffrent forums, the solution is:

sudo apt-get install libc6-dev-i386

Now we need 32 bit version of MySQL development clien library. But there is a small utility, to help install libraries: getlibs. Download getlibs-all from

sudo  dpkg -i getlibs-all.deb

32 bit libraries we needed: libmysqlclient-dev and zlib1g-dev.

getlibs -w

The version of MySQL server is:

mysql  Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (x86_64)

And last libruary:

getlibs -w

Compiler ( gcc version 4.4.1, x86_64-linux-gnu) command line:

gcc -m32 -c radauth.c -L/usr/lib/mysql -lmysqlclient -lnsl -lm -lz

m32 – 32 bit application
m64 – 64 bit application

No comments yet.