fatal error: 'mysql/mysql.h' file not found - mysql

I have installed mysql using
brew install mysql
Then compiled using
gcc -I/usr/include mydb.c
However it gives me the error:
fatal error: 'mysql/mysql.h' file not found
What am I doing wrong here? Am on macosx 10.12
edit: tried gcc -I/usr/local/include/mysql/ mydb.c still broken

On ubuntu16.04,mysql.h locates in /usr/include/mysql.
You can find it after install libmysqlclient20 or libmysqlclient-dev.

Verify at where are install mysql, for this, using the command for see the file list of directory
ls
and using
cd
The installation, in my example, are is in directory:
/usr/local/mysql-<version_my_mysql>/include/
second step is indicate the directory everytime compiller:
gcc my_program_code_file.c -I /usr/local/mysql-5.7.9-osx10.9-x86_64/include/ -o my_program_executable
the includers in code are:
#include <mysql.h>

Related

How to solve a problem of including json-glib.h in a c++ file

I'm trying to compile a c++ file that requires the header json-glib.h and the compilation log says that such header is not found. I'm in ubuntu 18.04 LTS.
I've tried executing dpkg -l '*json-glib*' to check that i have such file in my system and the result is:
||/ Nombre Versión Arquitectura
ii libjson-glib-1.0-0:amd64 1.4.2-3 amd64
ii libjson-glib-1.0-common 1.4.2-3 all
So next, i executed the command pkg-config --cflags libjson-glib-1.0 and got:
Package libjson-glib-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libjson-glib-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libjson-glib-1.0' found
I tried pkg-config --cflags json-glib-1.0 , pkg-config --cflags json-glib, and pkg-config --cflags libjson-glib as well and the result is similar as above.
I also followed the instructions of the answers of Fatal error: json-glib.h file not found and https://unix.stackexchange.com/questions/297277/make-doesnt-find-an-installed-library/298035#298035 and still i have the problem.
My include in the code is:
#include <json-glib/json-glib.h>
...
I will appreciate any help you can give me, Thanks.
Try to install the package libjson-glib-dev, after that run pkg-config --cflags json-glib-1.0
Same issue... I've resolved with the following:
sudo apt-get install libjson-glib-dev

How to link mysql-client installed from Homebrew with diesel-cli?

I have been trying to install the Rust Diesel CLI tool using cargo install diesel_cli, but the installation fails with a linking error
ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1
(use -v to see invocation)
I installed the MySQL client using Homebrew: brew install mysql-client. During installation I got the following warning:
mysql-client is keg-only, which means it was not symlinked into /usr/local,
because conflicts with mysql.
If you need to have mysql-client first in your PATH run:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
For compilers to find mysql-client you may need to set:
export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
export CPPFLAGS="-I/usr/local/opt/mysql-client/include”
I set the PATH and flags as in that warning message, but I still get the above linking error when trying to install the diesel-cli tool. I am unfamiliar with how to do linking in Rust - are there extra steps I need to do here to link mysqlclient directly?
Cargo ignores LDFLAGS and CPPFLAGS, you should set RUSTFLAGS instead. Something like this untested invocation:
RUSTFLAGS="-L/your_lib -I/your_include" cargo install diesel_cli
Relevant documentation.
On my side, I did not make it work with a mysql-client only. I had to install mysql with
brew install mysql
In the end, what matters is that you have a version of the mysqlclient dynamic lib.
Mines where installed here :
/usr/local/lib/libmysqlclient.21.dylib
/usr/local/Cellar/mysql/8.0.15/lib/libmysqlclient.21.dylib
And it worked.

QBox configuration error: unable to find "cc"

I am trying to build QBox
https://git.greensocs.com/qemu/qbox
For Configuration, I am using
./configure --target-list=arm-softmmu --library --qbox --with-tlm2c=/proj/user/tlm2c --prefix=/proj/user/Qbox --disable-pie --extra-cflags=--ftls-model=initial-exec
But I am getting the following error while configuration:
ERROR: "cc" either does not exist or does not work
I tried to set the flag --cc=gcc but still getting the same error. I am using gcc version 4.7.2.
It is missing gcc, so run the below command to resolve it
$ sudo apt-get install gcc

configure: error: invalid MySQL root directory

I've a problem installing sphinx with percona 5.6 on centos 6.4.
I'm getting the following error while building from source:
******************************************************************************
ERROR: cannot find MySQL include files.
Check that you do have MySQL include files installed.
The package name is typically 'mysql-devel'.
If include files are installed on your system, but you are still getting
this message, you should do one of the following:
1) either specify includes location explicitly, using --with-mysql-includes;
2) or specify MySQL installation root location explicitly, using --with-mysql;
3) or make sure that the path to 'mysql_config' program is listed in
your PATH environment variable.
To disable MySQL support, use --without-mysql option.
******************************************************************************
Percona-Server-devel is installed:
rpm -qa | grep -i percona
percona-release-0.0-1.x86_64
Percona-Server-server-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-client-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-devel-56-5.6.16-rel64.2.el6.x86_64
Percona-Server-shared-56-5.6.16-rel64.2.el6.x86_64
What I've tried:
locate "libmysql"
/usr/lib64/libmysqlclient.so.18
/usr/lib64/libmysqlclient.so.18.0.0
/usr/lib64/libmysqlclient_r.so.18
/usr/lib64/libmysqlclient_r.so.18.0.0
/usr/lib64/mysql/libmysqlclient.so.16
/usr/lib64/mysql/libmysqlclient.so.16.0.0
/usr/lib64/mysql/libmysqlclient_r.so.16
/usr/lib64/mysql/libmysqlclient_r.so.16.0.0
/usr/lib64/mysql/libmysqlservices.a
than:
./configure --with-mysql=/usr/lib64/mysql --with-mysql-libs=/usr/lib64/mysql
./configure --with-mysql=/usr/lib64 --with-mysql-libs=/usr/lib64
./configure --with-mysql=/usr/bin/mysql --with-mysql-libs=/usr/bin/mysql
./configure --with-mysql=/usr
configure: error: invalid MySQL root directory '/usr/lib64/mysql';
neither bin/mysql_config, nor include/ and lib/ were found there
which mysql_config
/usr/bin/mysql_config
Have you tried installing mysql-devel ?
sudo yum install mysql-devel
If properly setup, try as suggested in the error message to point to these libs manually using a command like the following one (to be adapted to your environment)
./configure --with-mysql-includes=/usr/local/src/mysql-XXX/include

Installing Levenstein Functions on centos 6 cloud server

I'd like to install the following UDF's from sam J levy's site
I have run through the windows (32 bit) installation with wamp for my testing server with no problem. Now I have my proper server running centOs 6.4. I have copied the .so files to
usr/lib64/mysql/plugin/damlev.so
I then try to run one of the sql statements to create the function
CREATE FUNCTION damlev RETURNS INTEGER SONAME 'damlev.so';
And get the following error
1126 - Can't open shared library 'damlev.so' (errno: 22 /usr/lib64/mysql/plugin/damlev.so: wrong ELF class: ELFCLASS32)
What Am I doing wrong. Is it because the server is 64bit?
Edit Bounty Started:
If more details about the server are required I can gladly supply them. I need this function installed.
It seems that you're trying to use the damlev.so library included in the damlev.zip file of the Levi's site, but that library is for an Ubuntu 32-bit system, therefore it cannot work on your Centos 64-bit system, so you'll have to compile from sources.
As a prerequisite, you must install the g++ compiler and the mysql development libraries:
yum install gcc-c++ mysql-devel
Also, if you don't have wget and unzip, install them with the following command:
yum install wget unzip
Then download the source code and unzip it somewhere:
cd tmp
mkdir damlev
cd damlev
wget http://samjlevy.com/wp-content/uploads/2011/03/damlev.zip
unzip damlev.zip
cd src
Finally compile, install the plugin and restart the mysql server:
g++ -fPIC -I /usr/include/mysql/ -o damlev.so -shared damlev.cpp
cp damlev.so /usr/lib64/mysql/plugin/
service mysql restart
Please note that all the above command must be run as "root".