I'm having a problem creating a MySQL udf on my server (I was able to do it locally on OS X). I am compiling it like this on the server:
gcc $(mysql_config --cflags) -I /usr/include/mysql -I. -shared udf_median.cc -o udf_median.so
Here is the output of mysql_config --cflags
mysql_config --cflags -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
So from what I can tell, MySQL is compiled for 32bit (it was done via x86_64 RPM). I had to install a bunch of different packages to get it to compile (32 bit packages, I think).
When I try to do:
CREATE AGGREGATE FUNCTION median RETURNS REAL SONAME 'udf_median.so';
Can't open shared library 'udf_median.so' (errno: 11 /usr/lib64/mysql/plugin/udf_median.so: wrong ELF class: ELFCLASS32)
From what I can tell this is a conflict between 32 and 64 bit but I'm not sure on how to fix it. I tried to put the .so in /usr/lib/mysql/plugin/ however MySQL doesn't seem to be recognizing that directory.
Anyone have any recommendations?
So if I try to compile it without the mysql_config like this:
gcc -shared -fPIC -I /usr/include/mysql -o udf_median.so udf_median.cc
I get these errors:
In file included from udf_median.cc:36: /usr/include/mysql/m_string.h: In function ‘const uchar* skip_trailing_space(const uchar*, size_t)’: /usr/include/mysql/m_string.h:261: error: cast from ‘const uchar*’ to ‘intptr’ loses precision /usr/include/mysql/m_string.h:263: error: cast from ‘const uchar*’ to ‘intptr’ loses precision /usr/include/mysql/m_string.h:265: error: cast from ‘const uchar*’ to ‘intptr’ loses precision