1 like 0 dislike
520 views
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/cceGvl84.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/tmp/cceGvl84.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
 
asked Dec 23, 2014 in Computers & Internet by Simmi (550 points) | 520 views
    

3 Answers

0 like 0 dislike

add the -fPIC parameter to the command line and I was able to compile w/o error

below is the command

gcc -fPIC -I/usr/include/mysql -I. -shared libmysqludfsys.c -o /usr/lib/libmysqludfsys.so

answered Dec 23, 2014 by Sam (1,470 points)
0 like 0 dislike

gcc -Wall -I/usr/include/mysql -I. -shared -fPIC libmysqludfsys.c -o
/usr/lib/libmysqludfsys.so

And to test

mysql> select sys_exec('ls / > /tmp/out.txt');

OUTPUT
+---------------------------------+
| sys_eval('ls / > /tmp/out.txt') |
+---------------------------------+
| NULL |
+---------------------------------+
1 row in set (0.00 sec)

answered Dec 23, 2014 by puneet
edited Dec 23, 2014
0 like 0 dislike

If still above does not work try below command

DROP FUNCTION IF EXISTS libmysqludfsysinfo;
DROP FUNCTION IF EXISTS sys
get;
DROP FUNCTION IF EXISTS sysset;
DROP FUNCTION IF EXISTS sys
exec;
DROP FUNCTION IF EXISTS syseval;
CREATE FUNCTION lib
mysqludfsysinfo RETURNS string SONAME 'libmysqludfsys.so';
CREATE FUNCTION sysget RETURNS string SONAME 'libmysqludfsys.so';
CREATE FUNCTION sys
set RETURNS int SONAME 'libmysqludfsys.so';
CREATE FUNCTION sysexec RETURNS int SONAME 'libmysqludfsys.so';
CREATE FUNCTION sys
eval RETURNS string SONAME 'libmysqludfsys.so'

Test: SELECT sys_exec('curl http://answerguru.net/');

answered Nov 4, 2015 by anonymous

Related questions

1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

Mathe Forum Schule und Studenten
1,151 questions
1,281 answers
263 comments
1,509 users