mysql udf error - can't install in ubuntu 12.04 64 bit - mysql

I have trouble installing the mysql udf (https://github.com/mysqludf/lib_mysqludf_sys). Here's what I'm getting:
Compiling the MySQL UDF
gcc -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so
/usr/bin/ld: /tmp/ccw6HRtN.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/tmp/ccw6HRtN.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [install] Error 1
ERROR: You need libmysqlclient development software installed
to be able to compile this UDF, on Debian/Ubuntu just run:
apt-get install libmysqlclient15-dev
Any ideas? TIA
UPDATED:
I have already the libmysqlclient15-dev installed.

Try to recompile with -fPIC flag. It obviously hints at it:
/usr/bin/ld: /tmp/ccw6HRtN.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

I know this is an old question, however I've just had this issue using Ubuntu 16.
I solved changing the Makefile in the following way, as explained in a GitHub issue:
LIBDIR=/usr/lib/mysql/plugin
install:
gcc -DMYSQL_DYNAMIC_PLUGIN -fPIC -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o $(LIBDIR)/lib_mysqludf_sys.so

Related

Unable to build python3 container with pyldap requirement

Base image is python:3
Requirements.txt:
Django==2.0.2
django-auth-ldap==1.3.0
django-bootstrap3==9.1.0
django-crispy-forms==1.7.0
django-extensions==2.0.0
django-filter==1.1.0
djangorestframework==3.7.7
Markdown==2.6.11
psycopg2==2.7.4
psycopg2-binary==2.7.4
pyldap==2.4.45
pytz==2018.3
six==1.11.0
typing==3.6.4
Getting this error when I build the image:
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.45 -IModules -I/usr/include -I/usr/include/sasl -I/usr/local/include -I/usr/local/include/sasl -I/usr/local/include/python3.6m -c Modules/LDAPObject.c -o build/temp.linux-x86_64-3.6/Modules/LDAPObject.o
In file included from Modules/LDAPObject.c:8:0:
Modules/errors.h:7:18: fatal error: lber.h: No such file or directory
#include "lber.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
yum is not installed on base image so I can't add a RUN statement to install the dependency lber.h. Any ideas how to get around this?

MySQL UDF Lib Install

I'm trying to install and use MySql UDF Lib but I'm facing an ELF error on its install procedure.
I'm under Ubuntu 14.04LTS 64.
Tried to follow some others answers and added -m64 flag for compiler, and still having the error.
Disclaimer: I'm not linux specialist, just trying a solution for a program issue
root#server:/usr/lib/mysql/plugin# sh install.sh
Compiling the MySQL UDF
gcc -fPIC -Wall -m64 -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so
MySQL UDF compiled successfully
-e
Please provide your MySQL root password
Enter password:
ERROR 1126 (HY000) at line 29: Can't open shared library 'lib_mysqludf_sys.so' (errno: 11 /usr/lib/mysql/plugin/lib_mysqludf_sys.so: wrong ELF class: ELFCLASS32)
ERROR: unable to install the UDF
root#server:/usr/lib/mysql/plugin#
My mysql file command:
root#server:/usr/bin# file mysql
mysql: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=23996cc38af44cd87dbcde82f46c47f9047769b0, stripped
And my lib file command:
root#server:/usr/lib# file lib_mysqludf_sys.so
lib_mysqludf_sys.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=8bcbe183af9bd452325f14c89810a34c5bfbbedd, not stripped
And my mysqld file command:
root#server:/run/mysqld# file /usr/sbin/mysqld
/usr/sbin/mysqld: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=eaac3628f59f9bfefceacef50d86d8cb834c0a7a, stripped
A bit late response, but better than never I hope :)
You are installing the plugin to /usr/lib
gcc -fPIC -Wall -m64 -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so
But your MySQL server is only looking for plugins installed on /usr/lib/mysql/plugin.
So, changing the above gcc command to
gcc -fPIC -Wall -m64 -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/mysql/plugin/lib_mysqludf_sys.so
Should fix the Can't open shared library 'lib_mysqludf_sys.so' error.
Hope this helps.

How to setup Netbeans for MySQL programming in C

I am trying to develop an application in C in a target Linux system which requires Mysql Conectivity but i dont know where to include in NETBEANS the required directives for the libmysqlclient-dev library.
I have the following:
A laptop with NETBEANS IDE 8.0.2 and remote build host setup.
A remote Ubuntu linux target which is the remote build host for netbeans.
apt-get install libmysqlclient-dev in the Ubuntu Target
mysql_config --libs gives:
-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -ldl
mysql_config --libs gives:
-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -ldl
According to the Mysql C Api Building I have to include the following:
gcc -c `mysql_config --cflags` progname.c
gcc -o progname progname.o `mysql_config --libs`
Although I am able to build my program manually in the target system, I am not sure where to add the above information in Netbeans.
P.S.1 at the momment my Netbeans build command looks like this:
gcc -o dist/Debug/GNU-Linux-x86/arguments_1 build/Debug/GNU-Linux-x86/src/args.o
P.S.2 Please be gentle. I am a newbie with Netbeans, Remote builds, C and Linux development.
Ok I have managed to get it working.
First I needed to include the Mysql Library paths to the Netbeans makefile as per this post:
gcc wont compile and run MySQL C libraries
# These are the flags that gcc requires in order to link correctly against our installed
# client packages
MYSQL_LIBS := $(shell mysql_config --cflags --libs)
Then right click on my project node , select Properties->Build->Linker->Compilation Line->Additional Options and add $(MYSQL_LIBS) to the Additional options parameter.
My problem was that I was adding it into the C compiler Additional options parameter.
But this post helped to clarify the order:
Why does the order in which libraries are linked sometimes cause errors in GCC?
So now my Netbeans gcc command looks like:
gcc -c -g -MMD -MP -MF "build/Debug/GNU-Linux-x86/src/args.o.d" -o build/Debug/GNU-Linux-x86/src/args.o src/args.c
gcc -o dist/Debug/GNU-Linux-x86/arguments_1 build/Debug/GNU-Linux-x86/src/args.o -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -ldl
Thank you Lumi, Thanassis

Installing bugzilla with mysql

I'm trying to install Bugzilla as part of setting up Testopia. I'm using 3.6.3 because our company site uses that and there are no plans to upgrade in the foreseeable future. I've install mysql but when I run the /usr/bin/perl install-module.pl DBD::mysql script it fails. The error message though isn't very descriptive. I've included it below:
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="/home/y/lib/mysql:/lib64" /usr/bin/perl myld gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.so \
-L/home/y/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto \
/usr/bin/ld: skipping incompatible /home/y/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: * [blib/arch/auto/DBD/mysql/mysql.so] Error 1
CAPTTOFU/DBD-mysql-4.021.tar.gz
/usr/bin/make -- NOT OK
Skipping test because of notest pragma
Running make install
Make had returned bad status, install seems impossible
I don't know why libmysqlclient.so is incompatible. Is the installed version of mysql too old or is it too recent for this version of Bugzilla? The error message does not specify. Can anyone help?
this looks like this which suggest you update your operating system.
hope this could help

MySQL gem installation problem

I'm bit confused having error with MySQL gem installation. I have uninstalled mysql gem because of MySQL update from 5.0.xx to 5.1.39 and now I can't install it properly.
I have downloaded mysql-2.8.1.gem to the server, because it is behind proxy. I have rad a lot of tutorials where is told that I have to include mysql_config to get rid of this error, but there is no help from that.
OS is Red Hat Enterprise Linux Server release 5.3 (Tikanga).
[my#server ~]$ sudo gem install mysql-2.8.1.gem --no-rdoc --no-ri -- --with-mysql-config=/usr/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql-2.8.1.gem:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile
make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -DUNIV_LINUX -DUNIV_LINUX -fPIC -g -O2 -c mysql.c
gcc -shared -o mysql_api.so mysql.o -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [mysql_api.so] Error 1
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
Any suggestions?
From the error it looks as if your version of MySQL is not compatible with the version of the gem you are using.
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
If you have multiple MySQL versions installed, maybe the gem is picking up on an older version. You should verify with the MySQL gem documentation for the verison you are using whihch version of MySQL is required.
I'd recommend that you use the mysql2 gem. If you use ruby 1.8 series you should use the gem version 0.2.11 or 0.2.13 something or if you use ruby 1.9 series I'd recommend gem version 0.3.7. 0.3.X does not work for some reason on ruby 1.8.
It should work like a charm. :)