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.
Related
i want to use mysql in lua program. But when run require "luasql.mysql",
throws error infomation
error loading module 'luasql.mysql' from file '/usr/local/luarocks/lib/lua/5.4/luasql/mysql.so':
/usr/local/luarocks/lib/lua/5.4/luasql/mysql.so:1: unexpected symbol near '<\207>'
stack traceback:
[C]: in ?
[C]: in function 'require'
stdin:1: in main chunk
[C]: in ?
I install lua and mysql by brew.
which lua is /opt/homebrew/bin/lua, lua -v is Lua 5.4.3 Copyright (C) 1994-2021 Lua.org, PUC-Rio
which mysql is /opt/homebrew/bin/mysql, mysql -V is mysql Ver 8.0.23 for osx10.16 on x86_64 (Homebrew)
install luarocks by luarocks source code, this is the source code website (https://luarocks.github.io/luarocks/releases/ ), luarocks --version is
/usr/local/luarocks/bin/luarocks 3.9.1
LuaRocks main command-line interface
which luarocks is /usr/local/bin/luarocks
Install luasql-mysql by command
luarocks install luasql-mysql MYSQL_INCDIR=/opt/homebrew/Cellar/mysql/8.0.23_1/include/mysql MYSQL_LIBDIR=/opt/homebrew/Cellar/mysql/8.0.23_1/lib
and then the result is
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/include/lua5.4 -c src/luasql.c -o src/luasql.o -I/opt/homebrew/Cellar/mysql/8.0.23_1/include/mysql
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -O2 -fPIC -I/opt/homebrew/include/lua5.4 -c src/ls_mysql.c -o src/ls_mysql.o -I/opt/homebrew/Cellar/mysql/8.0.23_1/include/mysql
env MACOSX_DEPLOYMENT_TARGET=11.0 gcc -bundle -undefined dynamic_lookup -all_load -o luasql/mysql.so src/luasql.o src/ls_mysql.o -L/opt/homebrew/Cellar/mysql/8.0.23_1/lib -lmysqlclient
luasql-mysql 2.6.0-1 is now installed in /usr/local/luarocks (license: MIT/X11)
run luarocks list, the result is
Rocks installed for Lua 5.4
---------------------------
luarocks
3.9.1-1 (installed) - /usr/local/luarocks/lib/luarocks/rocks-5.4
luasql-mysql
2.6.0-1 (installed) - /usr/local/luarocks/lib/luarocks/rocks-5.4
I config export LUA_PATH="/usr/local/luarocks/lib/lua/5.4/?.so;;" in .zshrc profile. When execute print(package.path), the output is
/usr/local/luarocks/lib/lua/5.4/?.so;/opt/homebrew/share/lua/5.4/?.lua;/opt/homebrew/share/lua/5.4/?/init.lua;/opt/homebrew/lib/lua/5.4/?.lua;/opt/homebrew/lib/lua/5.4/?/init.lua;./?.lua;./?/init.lua
so run require "luasql.mysql", i don't know the reason about
error loading module...
how should i solve this problem, is anyone knows?
i expected anyone else tell me how to solve this problem
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
I've been googling a lot about the problem that I have trying to install MySQL library.
I've downloaded library files from https://github.com/mysqludf/lib_mysqludf_sys and placed it on digitalocean server (running on CentOS x64) on location: /usr/lib64/mysql/plugin
Library's Makefile was altered so now it looks like this:
install:
gcc -m64 -fPIC -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib64/mysql/plugin/lib_mysqludf_sys.so -L/usr/lib/x86_64-linux-gnu/libstdc++.so.6
When I try to install the library from terminal using following command:
mysql -u root -p mysql < /usr/lib64/mysql/plugin/lib_mysqludf_sys.sql
I get this error:
ERROR 1126 (HY000) at line 26: Can't open shared library 'lib_mysqludf_sys.so' (errno: 22 /usr/lib64/mysql/plugin/lib_mysqludf_sys.so: wrong ELF class: ELFCLASS32)
Googling this error I've found this potential solution but it didn't help. Could anyone help me solve this issue?
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
First I wanted to build the DBD::mysql package. That kept failing because whatever make resulted in could not be loaded for the tests with a Symbol not found: _is_prefix. So I assumed that cpan might be a tad old. I know it's a random assumption, but cpan did tell me to install the latest Bundle::CPAN.
Who's successfully installed either DBD::mysql or Bundle::CPAN on Mac OS X 10.5? Could you recommend any thing I could be doing differently?
This is perl, v5.8.8 built for darwin-thread-multi-2level
(with 4 registered patches, see perl -V for more detail)
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.1.36,
for apple-darwin9.5.0 (i386) using readline 5.1
Here's a log of the CPAN output for DBD::mysql:
Writing Makefile for DBD::mysql
cc -c -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql/include -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -arch ppc -arch i386 -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include -O3 -DVERSION=\"4.012\" -DXS_VERSION=\"4.012\" "-I/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE" dbdimp.c
/usr/bin/perl -p -e "s/~DRIVER~/mysql/g" /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBI/Driver.xst > mysql.xsi
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
/usr/bin/perl /System/Library/Perl/5.8.8/ExtUtils/xsubpp -typemap /System/Library/Perl/5.8.8/ExtUtils/typemap mysql.xs > mysql.xsc && mv mysql.xsc mysql.c
cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm
cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod
cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm
cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs
chmod 644 blib/arch/auto/DBD/mysql/mysql.bs
Warning: duplicate function definition 'do' detected in mysql.xs, line 225
Warning: duplicate function definition 'rows' detected in mysql.xs, line 650
cc -c -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql/include -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -arch ppc -arch i386 -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include -O3 -DVERSION=\"4.012\" -DXS_VERSION=\"4.012\" "-I/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE" mysql.c
dbdimp.c: In function 'mysql_describe':
dbdimp.c:3309: warning: assignment from incompatible pointer type
dbdimp.c: In function 'mysql_describe':
dbdimp.c:3309: warning: assignment from incompatible pointer type
rm -f blib/arch/auto/DBD/mysql/mysql.bundle
LD_RUN_PATH="/usr/local/mysql/lib" /usr/bin/perl myld cc -mmacosx-version-min=10.5.7 -arch ppc -arch i386 -bundle -undefined dynamic_lookup -L/usr/local/lib dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.bundle \
-L/usr/local/mysql/lib -lmysqlclient -lz -lm \
chmod 755 blib/arch/auto/DBD/mysql/mysql.bundle
Manifying blib/man3/DBD::mysql.3pm
Manifying blib/man3/DBD::mysql::INSTALL.3pm
Manifying blib/man3/Bundle::DBD::mysql.3pm
CAPTTOFU/DBD-mysql-4.012.tar.gz
/usr/bin/make -j3 -j3 -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .................. 1/6 Bailout called. Further testing stopped: Unable to load DBD::mysql
# Failed test 'use DBD::mysql;'
# at t/00base.t line 21.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/dlamblin/.cpan/build/DBD-mysql-4.012-4n3pv8/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/dlamblin/.cpan/build/DBD-mysql-4.012-4n3pv8/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Symbol not found: _is_prefix
# Referenced from: /Users/dlamblin/.cpan/build/DBD-mysql-4.012-4n3pv8/blib/arch/auto/DBD/mysql/mysql.bundle
# Expected in: dynamic lookup
# at (eval 7) line 2
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 255
CAPTTOFU/DBD-mysql-4.012.tar.gz
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports CAPTTOFU/DBD-mysql-4.012.tar.gz
Running make install
make test had returned bad status, won't install without force
Failed during this command:
CAPTTOFU/DBD-mysql-4.012.tar.gz : make_test NO
Okay, if you get these errors I now know the following:
MySQL 5.1 for Mac OS X x86_64 is not compatible with DBD::mysql (yet). Install the 32-bit x86 version, and try again. You'll succeed. I wish the perl Makefile.pl would just tell you that in a banner.
Bundle::CPAN had issues because I wasn't installing as root. Why that makes it report circular references instead of installation permission issues, I'll never understand.
Please add a comment if and when this became outdated information.
Installing the (beta) 5.4.1 64 bit version of mysql, available from their developer website, fixes the issue. Tested on Snow Leopard.
Did you try installing Bundle::DBD::mysql?
I haven't dealt with this problem, but I found that MacPorts cleaned up all my UNIX incompatibility problems. You might want to try that before enduring too much pain and suffering.
Where is it complaining about a circular dependency? It looks like you are trying to link to an incompatible version of the mysql libraries. The symbol it's looking for isn't in the library you loaded. I don't think this is a problem caused by CPAN.pm or the cpan script.
Some questions:
Who compiled perl? Is this Apple's perl?
Who compiled mysql? Is that your own version since it's in /usr/local?
Did you previously compile other versions? I start with a compile to ensure everything points to the right places.
Installing latest beta 64bit version of Mysql fixed problem on my computer.