Mailing List
Home
MySQL General - General MySQL discussion
MaxDB - Everything about MaxDB, formerly known as SAP DB
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
ODBC - ODBC with the MySQL Connector/ODBC driver
Perl - Perl support for MySQL with DBI and DBD::mysql
MySQL++ - Programming with the C++ API to MySQL
Subjects
mysql openssl Question
mysql:it 's a db not a dbms how it 's possible?!
Does the binary log enabling affect the MySQL performances?
Strange behavior, Table Level Permission
FULLTEXT query format question
Preventing Duplicate Entries
Comparing and writing out BLOBS
Executing MySQL Commands From Within C Program
Can 't access mysql after kernel upgrade
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Downgrade Mysql from 4 to 3 23
MySQL Cluster Software
mysql test 4 1 fails with the gis test
ERROR 2002: Can 't connect to local MySQL server through socket
Getting Identity after INSERT
Update one field with more fields from another table
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
mysql have same function mthod as Oracle decode()
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
problems compiling a mysql tool

problems compiling a mysql tool

2004-03-19       - By Sasha Pachev

 Back
Reply:     1     2  

Jason Unrein wrote:
> Before I start, this is a compile problem (or so I
> think) and from what little I read in this forum, it
> looks ok to post. If not and you know the proper place
> to post, please let me know. Now for the good
> stuff....
>
> I 'm attempting to write a simple tool in C that needs
> to be compiled statically with mysql client support.
> It needs this (correct me if I 'm wrong in what I say)
> because it will be used on the majority of Redhat 'S
> and SuSE 's OSes. Instead of compiling for each one of
> their glibc 's and requiring that the mysql shared
> libraries are installed, I want to compile it once,
> statically for all of them (excluding the x86_64 and
> ia64).
>
> When I run
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
> CC = gcc
> CFLAGS = -O2 -Wall -static
> ALL:
> gcc -O2 -Wall -static -o logger scsiInquiry.o sg_err.o
> sgScan.o logger.o /usr/lib/mysql/libmysqlclient.a
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
>
> I get the following
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
> /usr/lib/mysql/libmysqlclient.a(mf_pack.o)(.text+0x9ac):
> In function `expand_tilde ':
> : Using 'getpwnam ' in statically linked applications
> requires at runtime the shared libraries from the
> glibc version used for linking
> /usr/lib/mysql/libmysqlclient.a(libmysql.o)(.text+0x7a7):
> In function `read_user_name ':
> : Using 'getpwuid ' in statically linked applications
> requires at runtime the shared libraries from the
> glibc version used for linking
> /usr/lib/mysql/libmysqlclient.a(mf_pack.o)(.text+0x9b9):
> In function `expand_tilde ':
> : Using 'endpwent ' in statically linked applications
> requir....
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------

Jason:

I share with your your dislike of shared libraries. I guess some people have a
hard time with the idea that you may want to compile a binary and have it just
run everywhere with no fuss :-)

To make a long story short, the easiest way to solve the problem, as it seems to
me -

get MySQL source
CXX=gcc CC=gcc ./configure --with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static --prefix=/opt/my-own-mysql
make
make install


Then compile with -I/opt/my-own-mysql/include/mysql and link with
-L/opt/my-own-mysql/lib -static -lmysqlclient -lz -lm

For machines with an incompatible libc gethostbyname() will fail when you call
mysql_real_connect(), so just use IP addresses instead of host names. There is a
solution that works around this problem, but it requires a libc patch.

--
Sasha Pachev
Create online surveys at http://www.surveyz.com/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=mysql @(protected)