CLSQL on CentOS installation - mysql

I want to connect to MySQL from SBCL using CLSQL. I loaded CLSQL using quicklisp (ql:quickload 'clsql). However, when calling (clsql:connect '(...) :database-type :mysql), it said:
Couldn't load foreign libraries "libmysqlclient", "libmysql". (searched CLSQL-SYS:FOREIGN-LIBRARY-SEARCH-PATHS).
I'm on CentOS, and basically what I want to do is
Install mysql client development headers with yum, so UFFI can find it (which I failed to do)
after installing, be able to connect to local MySQL server (I think after 1. is done, it could be working automatically).
I'm currently using:
CentOS 5.7 Final (32 bit)
SBCL 1.0.55
Quicklisp beta
yum repositories: base, epel, extras, updates
I didn't just ask about how to install MySQL development headers on CentOS, because that would solve only part of my problem, I would still need to know what's missing from my machine. I also didn't try to build libmysqlclient/libmysql from source, because I don't know whether clsql would be able then to find it or not. I think not.
I'm really sorry if my question somehow misses the point, but extensive googling didn't yield any results. If anyone told me they couldn't install mysql client development headers on CentOS, I would laugh at them and tell them to use yum search, but I couldn't find it neither with yum neither online.
I know the solution for ubuntu (and debian), because there is a cl-sql package and I can easily find mysql headers there too, but I need it on CentOS.
Thanks in advance.

Somehow, when you try something long enough, it will get done ;)
Here's what I did if anyone needs an answer and stumbles upon this question:
(ql:quickload 'clsql)
;tell clsql where to search for mysql libs
(push #P"/usr/lib/mysql" CLSQL-SYS:*FOREIGN-LIBRARY-SEARCH-PATHS*)
;add mysql libs to clsql library path [apparent from code :]
(clsql:push-library-path "/usr/lib/mysql/")
;directly tell uffi to load mysqlclient shared library
(uffi:load-foreign-library "/usr/lib/mysql/libmysqlclient.so")
Of course, you can replace "/usr/lib/mysql" with a different path for mysql libraries, if needed.

Related

Endless loop of installs in cygwin to get mysql

I'm running windows 10. I am evaluating software that was written in cygwin / mysql / python.
I installed cygwin from the mirrors.cs.vt.edu site. According the setup program mysql is installed.
When I try to run mysql I get "-bash: mysql: command not found"
I found a note on stackoverflow that says "OH, just use apt-cyg", but when I do that it says
"-bash: apt-cyg: command not found"
Another note said "Oh, use lynx to install apt-cyg", but it can't find that either.
Dear god, can someone please explain what I have to install? Apparently, it's already in there someplace.
Also can't download and build package X, because it can't find gcc either.
The only that works are ls, pwd, find, python, a few other things.

"Fatal error: 'EXTERN.h' file not found" while installing Perl modules

While trying to install Perl modules like JSON::XS or YAML::XS, i receive the same error:
XS.xs:1:10: fatal error: 'EXTERN.h' file not found
I use MacBook, xCode is up to date, everything else that could help is up to date too.
Since OS X El Capitan, Apple introduced System Integrity Protection which restricts writing to /usr/lib /usr/bin and other sensitive directories (even to root or sudo user) that are used by the installation of Perl bundled with the Operating System. This can cause issues when it comes to installing new modules and also if trying to install XS modules ( those linked to external C libraries ).
For this reason you should not consider the default Perl installation as a working development environment, especially if you are installing custom modules.
Check out this thread on PM and others. I had since El-Capitan managed to solve this before by manually building from tarball and adding a few params or environment variables to set the paths believing that it would be best to retain use of the system Perl but this is not the way to go. This makes your environment difficult to build but also brittle and sensitive to OS updates that may either break things in many different ways.
The best practice seems to be starting with a Perl using brew install perl and work in this environment, remembering to setup your bash_profile as directed by the installer.
Also worth remembering to do a brew link perl. If you receive warnings about this clobbering what looks like system Perl libraries don't worry - these are likely modules that were installed by you over the top and it will cause you less trouble to link over these. If you have concerns, make a note of which module installs will be cleared and re-install them once your environment is configured ( ie your module installer approach is configured using cpanm or sticking with the old perl -MCPAN -e shell etc)
This new Perl setup from brew eliminates the need to continuing running sudo which adds another layer of things that can go wrong as environment variables don't follow through and permission conflicts arise etc.
Finally to simplify package/module installation I suggest doing a brew install cpanminus. If you had previously already installed this, you can ensure the paths etc are configured by doing a brew reinstall cpanminus
If you want to take it another step further then you can install perlbrew as well which will give you the ability to run multiple versions of Perl as your user and configure these with their own libs and modules which can be very useful particularly if aligning with your production environment for testing etc.
One problem you may face if moving from system Perl to this kind of approach is needing to deal with any hangovers from installing things with sudo. It wis worth taking a little time to get all this set up right though and your issues going forward will be greatly reduced and you won't be left with that nagging feeling that you don't want to change anything for fear of it all breaking.
I have also come across a Perl Blog Article that suggests a fix for XS issues with perlbrew on Mojave
This Gist described updating your cpan shell install root though this shouldn't be necessary unless your cpan is stuck in an old config after taking steps above.
I've also raised this as a new issue on PerlMonks
After reading https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624 and installing the Additional headers via
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
I successfully compiled without the missing 'EXTERN.h' error
In order to follow the common advice I also tried with Perlbrew to install a dedicated development version of Perl. Especially with the advice in mind First, do not use the system Perl on MacOS. The installed version is for Apple, not for you (see the discussion here: https://www.perlmonks.org/?node_id=1224727).
Unfortunately, the following error occurred:
Test Summary Report
-------------------
porting/libperl.t (Wstat: 65280 Tests: 35 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=2653, Tests=1217766, 708 wallclock secs (52.74 usr 9.40 sys + 395.38 cusr 49.90 csys = 507.42 CPU)
Result: FAIL
make: *** [test_harness] Error 1
##### Brew Failed #####
Therefore, I decided to install it the following way (and not following the advice due to the error).
Even after having the above mentioned macOS SDK headers already installed on Catalina (macOS 10.15.2) it didn't work for me. I faced the issue during the installation of the Perl module Mac-SystemDirectory-0.13. The following steps (by identifying the missing file in hope of having a more generic approach for more or less equivalent issues) did the trick:
Locate the header file (in this case EXTERN.h)
sudo find /Library -type f -name EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h
Ensure the installed Perl version (here 5.18) match the header file:
perl -v | grep version
This is perl 5, version 18, subversion 4 (v5.18.4) built for darwin-thread-multi-2level
Export the path for the C-Compiler (note MacOSX10.15.sdk for Catalina and Perl Version 5.18)
export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE
Invoke the Makefile.PL with perl
perl Makefile.PL
BTW — For anybody who's still struggling with this, my workaround was:
bash% module="Sub::Util" # For example
bash% cpanm --configure-args="INC=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE" "$module"
Please try this
CPATH=$(dirname $(find /usr/local/Cellar/ -name EXTERN.h)) cpan JSON::XS
For Big Sur and perl 5.30, EXTERN.h is at /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE
I'm trying to upgrade CPAN itself and got that error. But I have /usr/bin/cpan and I can't write there so I have to tweak it to write the updated version to /usr/local/bin/cpan.
No promises, but yum install perl-devel worked for me.
As #huyz has helpfully pointed out, if you hit this error on a Mac, you don't have this option, even though this is probably your issue, and you need to follow one of the above methods of getting a version of Perl that isn't missing important chunks, as per other answers.
But if, dear reader, you hit this error on a linux host, as I did, then this might be an option for you.
Building on what E Lisse suggested, you might also have luck looking in
/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/
For example:
CPATH=$(dirname $(find /System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/ -name EXTERN.h)) cpan JSON::XS
You could also find where EXTERN.h is located and add that to your shell by default, e.g. in your .bashrc or .zshrc file:
export CPATH=/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/

Error with MySQL Instalattion in Centos 6.4

I'm trying to install MySQL in my CentOS 6.4 (X86_64) with the command:
"yum install mysql mysql-server"
And I'm having problems with the installation, the error presented is the following:
Check the error log in the following link http://pastie.org/10022423
Any Idea why this error ? thanks for you helps!
The problem is you already have a version of some MySQL packages installed that are from a different distribution/vendor than CentOS.
Since different people created the packages using different names and standards, yum does not know how to fix this situation.
You have libmysqlclient16-5.1.69-1.w6.x86_64 installed already providing the client libraries, but the CentOS package is mysql-libs. This package appears to be provided by "webtatic":
https://webtatic.com/packages/mysql55/
http://rpm.pbone.net/index.php3/stat/4/idpl/21966562/dir//com/libmysqlclient16-5.1.69-1.w6.x86_64.rpm.html
Likely you need to consider removing the libmysqlclient package and installing mysql-libs in it's place. That will probably remove some items because of dependencies, you might be able to get away with manually removing it with the rpm --nodeps -e, but it may also be the packages cannot have their dependency satisfied by mysql-libs so slightly risk move if you don't fully check everything first. This often works, though.
As an alternative looks like you can install the mysql server package from webtatic as well, based on their instructions here, that might be a less complex alternative if you are happy to continue relying on their repository:
https://webtatic.com/packages/mysql55/
As far that I know, that error will shows up when you attempt to install packages that already have been installed before. So, you probably should reinstall your mysql.
Source : https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s3-rpm-conflicting-files.html

Using MySQL in R for Windows

How to use MySQL in R (statistic language) for Windows (7)?
There is no problems then using linux:
install.packages('RMySQL')
library(RMySQL)
...
But I found no such package for Windows on CRAN. There is only note about this fact.
I found package for version 2.10, but it is not usable in 2.12.1.
Also tried
install.packages("RMySQL", type="source")
but got an error :
* installing *source* package 'RMySQL' ...
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/.../R/win-library/2.12/RMySQL'
Is there any way to connect to MySQL database from R in windows?
Found solution with help of ran2, who gave me link to common question. The basic process is described here, but there are several hints, So I will describe the whole solution (please change the R version and paths if needed):
Install latest RTools from here
install MySQL or header and library files of mysql
create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
run install.packages('RMySQL',type='source') and wait while compilation will end.
Thanks to all who tried to answer.
possible duplicate. However, my suggestions is to try WAMP which comes as a one click install. Admittedly you get more than you need (webserver) but the MySQL installation runs pretty well.
You need to install the MySQL headers and libraries, as explained in the installation instructions. Please do read the documentation before turning to SO.

CLSQL and MYSQL on OS X

I'm working on OS X 10.6.4. I've been using clbuild to install supporting libraries for SBCL (including clsql), and I do all my work through Aquamacs. I installed MySQL using the excellent instructions over at Hive Logic. But when I call (require 'clsql) -- which seems to work fine -- and then try to execute (clsql:connect '(nil "lisp" "root" "") :database-type :mysql) to connect to my local running database, I get this error message:
erred while invoking #<COMPILE-OP (:VERBOSE NIL) {12096109}> on
#<CLSQL-MYSQL-SOURCE-FILE "clsql_mysql" {1208E071}>
[Condition of type ASDF:OPERATION-ERROR]
From my research of this problem, I think it comes from me not having a compiled version of the libmysqlclient.dylib file, of which I have a copy in /usr/local/mysql/lib/, but I'm not clear on how to go about compiling it. This forum post seems to say that's exactly what I need to do, but there's no make file in that directory.
Nowadays, you should use homebrew for MySQL installation on Snow Leopard. Homebrew installs MySQL 5.5.10 which doesn't have the compiler problem that 5.5.8 had (AFAIK).
I would guess you can download mysql-5.5.8-osx10.6-x86_64.dmg from http://dev.mysql.com/downloads/mysql/#downloads
I would expect that to include the precompiled client libs. I haven't tried it though.
If it really doesn't have the precompiled client libs, you'll probably need to download the MySQL source code from the same place (select "Source Code" from the "Select Platform" dropdown box) and compile it. Even though the description says "Generic Linux" I think mysql-5.5.8.tar.gz should work.
Having previously installed MySQL 5.0 on Leopard, I am sure it came with the client libs, but of course something could have changed. It just seems unlikely they would not provide them.
EDIT:
After installing the version for OS X 10.5, this is what I find in terms of client libs:
/usr/local/mysql-5.5.8-osx10.5-x86_64/lib/libmysqlclient.16.dylib
/usr/local/mysql-5.5.8-osx10.5-x86_64/lib/libmysqlclient.a
/usr/local/mysql-5.5.8-osx10.5-x86_64/lib/libmysqlclient.dylib
/usr/local/mysql-5.5.8-osx10.5-x86_64/lib/libmysqlclient_r.16.dylib
/usr/local/mysql-5.5.8-osx10.5-x86_64/lib/libmysqlclient_r.a
/usr/local/mysql-5.5.8-osx10.5-x86_64/lib/libmysqlclient_r.dylib
so they are indeed installed along with the server.