LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-13-2014, 12:22 AM   #1
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Rep: Reputation: 54
Linux "header only" library to connect to mysql


Is there a header only code I can include in my program to make it possible to connect and interact with mysql? I hate dealing with dependencies and shared libs, it's always a nightmare as from system to system you never know what issues you'll run into at compile or run time. I just want something that is purely code, no libs, and that just works and I just include in my program so that my program can be dropped on any machine and compile and work with no issues.

I'm even thinking of writing my own if such thing does not exist, I'd have to find some specs on how the protocol works at the tcp/ip level though.

I'm trying to get mysql++ to work with a program on my server and since I migrated to a new server it just refuses to work properly. I just hate dealing with shared libs and wasting time getting them to work, I just want to get to coding. So is there such library out there that is strictly a header that I can include? If not, where can I find info on the mysql protocol so I can write my own?
 
Old 11-13-2014, 01:01 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

if you don't want to use shared libraries you can statically link.

Evo2.
 
1 members found this post helpful.
Old 11-13-2014, 02:25 AM   #3
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
I've been trying to figure out how to do that but so far no luck. When I bring the binary on another system it's still looking for the libraries to be at a very specific spot.

ex:

Code:
./uogpoller: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
This is the string I'm using, is there a better way?

Code:
g++ -o uogpoller uogpoller.cpp -g -w -Bdynamic -lpthread -Bstatic -lmysqlpp -L/usr/lib64/mysql -lmysqlclient -I/usr/local/include/mysql++/ -I/usr/include/mysql
 
Old 11-13-2014, 02:41 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

you need the static versions of the libraries installed on the build machine (the .a files which usually come with the -dev package that provides the headers) and you need to use the -static option.

See for example:
http://www.linuxquestions.org/questi...raries-696714/

HTH,

Evo2.
 
Old 11-13-2014, 02:47 AM   #5
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Mint 20.1 on workstation, Debian 11 on servers
Posts: 1,336

Original Poster
Rep: Reputation: 54
How do I tell it to use the static files? Ex: What would I change in my compile string? What happens if the package does not come with .a files?

I did a /usr wide search on the dev machine to see what I could find and this is what I found:

/usr/lib64/mysql/libmysqlclient.so.16
/usr/lib64/mysql/libmysqlclient.so
/usr/lib64/mysql/libmysqlclient.so.18
/usr/lib64/mysql/libmysqlclient.so.18.0.0
/usr/lib64/mysql/libmysqlclient.so.16.0.0


So am I out of luck for that specific lib? Can I just copy it over to the other system to the same location or is that going to cause issues? It does exist on the other system but it's not at the same place, which is often the cause of issues with this whole shard library thing. It would be nice if there was a standard place for them.
 
Old 11-13-2014, 03:33 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You should have to have a file called libmysqlclient.a somewhere (the location depends on your distribution)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "net rpc" "failed to connect to ipc$ share on" or "unable to find a suitable server" larieu Linux - General 0 11-09-2014 12:45 AM
Can't locate object method "connect" via package "mysql" (perhaps you forgot to load xman fiji Linux - Newbie 9 07-11-2012 08:05 PM
Buzilla issue: "Can't connect to local MySQL server through socket '/tmp/mysql.sock'" vitopn Linux - General 3 05-21-2007 10:13 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration