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/[EMAIL PROTECTED]



Reply via email to