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
Related
I encountered the following error while trying to install mysqlclient using the command
pip3 install mysqlclient
System information: Python 3.9, GNU/Linux Ubuntu 20.04 running on WSL
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/usr/include/mysql -I/home/eweinsh/microservice/src/auth/_venv/include -I/usr/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-39/MySQLdb/_mysql.o -std=c99
MySQLdb/_mysql.c:46:10: fatal error: Python.h: No such file or directory
46 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
Initially, the error seemed to be that I hadn't install the python3 dev tools correctly, so I reinstalled python3. However, I know believe this is an issue with my installation of MySql.
I reinstalled python3 with suggested packages. I also ensured configuration files were added for mysql.
You are in a virtual environment using python 3.9 instead of python 3.8 shipped with Ubuntu 20.04 try :
sudo apt install python3.9-dev
This package installs all headers files needed to build python3.9 instead of 3.8
I try to install luasql-mysql with luarocks (Lua 5.3.5, LuaRocks 3.0.3). I have Mysql Connector C 6.1 installed in directory "C:\Program Files\MySQL\MySQL Connector C 6.1". I have MinGW installed in C:\TDM-GCC-64 dir.
When I run command
luarocks --from=http://rocks.luarocks.org/dev install luasql-mysql cvs-1 MYSQL_INCDIR="C:\mysql-5.7.23-winx64\include" MYSQL_LIBDIR="C:\Program Files\MySQL\Connector C++ 8.0\lib64"
I get the error
Cloning into 'luasql'...
remote: Enumerating objects: 122, done.
remote: Counting objects: 100% (122/122), done.
remote: Compressing objects: 100% (92/92), done.
remote: Total 122 (delta 46), reused 55 (delta 16), pack-reused 0
Receiving objects: 100% (122/122), 94.79 KiB | 197.00 KiB/s, done.
Resolving deltas: 100% (46/46), done.
C:\TDM-GCC-64\bin\gcc.exe -O2 -c -o src/luasql.o -IC:\lua\include src/luasql.c -IC:\mysql-5.7.23-winx64\include
C:\TDM-GCC-64\bin\gcc.exe -O2 -c -o src/ls_mysql.o -IC:\lua\include src/ls_mysql.c -IC:\mysql-5.7.23-winx64\include
C:\TDM-GCC-64\bin\gcc.exe -shared -o luasql/mysql.dll src/luasql.o src/ls_mysql.o -LC:\Program Files\MySQL\Connector C++ 8.0\lib64 -lmysqlclient C:\lua\bin/lua53.dll -lm
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmysqlclient
collect2.exe: error: ld returned 1 exit status
How to specify paths correctly?
I could find workaround solution. Here is steps to make Lua 5.1 running in Windows 10 x64 Pro connect to Mysql server:
Get the latest Lua 5.1 from https://code.google.com/archive/p/luaforwindows/downloads
Install it. I have to remove all previous Lua and LuaRocks installations in my workstation
Added environment variable LUA_CPATH with value:
C:\Program Files (x86)\Lua\5.1\clibs\?.dll;C:\Program Files (x86)\Lua\5.1\clibs\luasql\?.dll
Run mysql lua script in NEW cmd
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.
Hey all, I'm trying to install 64-bit MySQL on Snow Leopard for a rails app.
I've installed it from the dmg and I can get to mysql fine from the command line. Based on various blog posts as well as the other topics here on Stack, I shut down mysql, uninstall the mysql gem, and then try to update the gem with the following:
sudo env ARCHFLAGS='-arch x86_64' gem install --verbose --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
That produces the following:
GET 200 OK: http://gems.rubyforge.org/latest_specs.4.8.gz
Installing gem mysql-2.8.1
Downloading gem mysql-2.8.1.gem
GET 302 Found: http://gems.rubyforge.org/gems/mysql-2.8.1.gem
GET 200 OK: http://s3.amazonaws.com/gemcutter_production/gems/mysql-2.8.1.gem
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/COPYING
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/COPYING.ja
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/History.txt
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/Manifest.txt
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/README.txt
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/Rakefile
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/extconf.rb
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/mysql.c
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/extra/README.html
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/extra/README_ja.html
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/extra/tommy.css
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql.rb
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/tasks/gem.rake
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/tasks/native.rake
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/tasks/vendor_mysql.rake
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/test/test_mysql.rb
Building native extensions. This could take a while...
/usr/local/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/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/universal-darwin8.0 -I. -DHAVE_MYSQL_H -I/usr/local/mysql/include -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -g -O2 -fno-common -pipe -fno-common -arch i386 -c mysql.c
cc -dynamic -bundle -undefined suppress -flat_namespace -arch i386 -L"/usr/local/lib" -o mysql_api.bundle mysql.o -lruby -L/usr/local/mysql/lib -lmysqlclient -lz -lm -lmygcc -lpthread -ldl -lobjc
ld: warning: in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture
ld: warning: in /usr/local/mysql/lib/libmygcc.a, file is not of required architecture
make install
/usr/bin/install -c -m 0755 mysql_api.bundle /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib
Successfully installed mysql-2.8.1
1 gem installed
Those two warnings at the end seem ominous. I then go to my rails app and run
rake db:migrate
And get:
dyld: NSLinkModule() error
dyld: Symbol not found: _mysql_affected_rows
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Trace/BPT trap
And that's as far as I'm able to get. I've tried installing MySQL via the dmg and via macports and I seem to run into this error in both cases.
I'm kind of a noob when it comes to rails; any light anyone can shed would be wildly appreciated. Thanks!
--- EDIT ---
In response to John's (and khelll's) answers below:
When I do the first command that John specified, I get:
No definition for next_result
No definition for field_name
No definition for field_table
There's about 40 lines of this. I assumed this was because of the documentation. But when I do rake db:migrate I get:
dyld: NSLinkModule() error
dyld: Symbol not found: _mysql_affected_rows
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Trace/BPT trap
Using the ARCHFLAGS command produces the error I specified earlier.
--- SECOND EDIT ---
I should add that I did not install from source. After peeking at the Hivelogic instructions again, I went down this route.
When I tried to run:
./configure --prefix=/usr/local/mysql --with-extra-charsets=complex \
--enable-thread-safe-client --enable-local-infile --enable-shared \
--with-plugins=innobase
I got:
config.status: creating zlib/Makefile
dyld: Library not loaded: /opt/local/lib/libintl.8.dylib
Referenced from: /opt/local/bin/gawk
Reason: no suitable image found. Did find:
/opt/local/lib/libintl.8.dylib: mach-o, but wrong architecture
./config.status: line 1782: 69228 Done(141) eval sed ç"ç$ac_sed_extraç" "$ac_file_inputs"
69229 Trace/BPT trap
So I did:
sudo port deactivate gettext
sudo port activate gettext #0.17_3
However, after following all the steps, reinstalling the gem, upon rake db:migrate I still get:
dyld: NSLinkModule() error
dyld: Symbol not found: _mysql_affected_rows
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Expected in: flat namespace
in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
Trace/BPT trap
---- THIRD EDIT ----
Okay - I believe what's happening here is that, even though I'm specifying the 64 bit gem above, it's installing the 32 bit version. I do:
file /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle
And get:
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle: Mach-O bundle i386
So it would seem I keep installing the 32 bit version
I installed it from source following these instructions on Hivelogic and it works great. Then I installed the MySQL RubyGem using:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
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.