Can"t static link to mysqlclient on RH7 or 9

Can"t static link to mysqlclient on RH7 or 9

am 20.06.2003 14:58:57 von Olaf van der Spek

Hi,

I hope this is the right list to send this to because I think this is a bug
in the static mysqlclient lib.
I want to compile and static link this code, but as you can see it doesn't
work.
I've tried this on multiple systems. libmysqlclient.a exists.

# cat mysql_test.cpp
#include

int main()
{
MYSQL h;
mysql_init(&h);
return 0;
}
# g++ -lmysqlclient mysql_test.cpp
# g++ -lmysqlclient -static mysql_test.cpp
/tmp/ccwpQvKN.o(.text+0x1e): In function `main':
: undefined reference to `mysql_init'
collect2: ld returned 1 exit status
#

>Description:

>How-To-Repeat:

>Fix:
lines)>

>Originator:
>MySQL support: none
>Synopsis: Can't static link to mysqlclient on RH7 or 9
>Severity: serious
>Priority: medium
>Category: mysql
>Class: support/sw-big
>Release: mysql-3.23.56 (Source distribution)

>Environment:

System: Linux usf-cf-x86-linux-2.cf.sourceforge.net 2.4.18-5smp #1 SMP Mon
Jun 10 15:19:40 EDT 2002 i686 unknown
Architecture: i686

Some paths: /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc
/usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113)
Compilation info: CC='gcc'

CFLAGS='-O2 -march=i386 -mcpu=i686 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_L
ARGEFILE_SOURCE' CXX='gcc'\


CXXFLAGS='-O2 -march=i386 -mcpu=i686 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D
_LARGEFILE_SOURCE -fno-rtti -fno-exceptions' LDFLAGS\
=''
LIBC:
lrwxrwxrwx 1 root root 13 Mar 19 17:26 /lib/libc.so.6 ->
libc-2.2.5.so
-rwxr-xr-x 1 root root 1260480 Mar 5 13:32 /lib/libc-2.2.5.so
-rw-r--r-- 1 root root 2312442 Mar 5 13:09 /usr/lib/libc.a
-rw-r--r-- 1 root root 178 Mar 5 12:51 /usr/lib/libc.so
lrwxrwxrwx 1 root root 10 Jul 22 2002
/usr/lib/libc-client.a -> c-client.a
Configure command: ./configure '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--datadir=/usr/share' '--libdir=/usr/lib' \
'--mandir=/usr/share/man' '--infodir=/usr/share/info' '--without-debug'
'--without-readline' '--enable-shared' '--with-extra-charse\
ts=complex' '--with-bench' '--localstatedir=/var/lib/mysql'
'--with-unix-socket-path=/var/lib/mysql/mysql.sock' '--with-mysqld-user\
=mysql' '--with-extra-charsets=all' '--with-innodb' '--with-berkeley-db'
'--enable-large-files=yes' '--enable-largefile=yes' '--ena\
ble-thread-safe-client' '--enable-assembler'
'CFLAGS=-O2 -march=i386 -mcpu=i686 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_L
ARGEFILE_S\
OURCE'
'CXXFLAGS=-O2 -march=i386 -mcpu=i686 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D
_LARGEFILE_SOURCE -fno-rtti -fno-exceptions' 'CX\
X=gcc'


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: Can"t static link to mysqlclient on RH7 or 9

am 20.06.2003 18:00:48 von Alexander Keremidarski

Olaf van der Spek wrote:
> Hi,
>
> I hope this is the right list to send this to because I think this is a bug
> in the static mysqlclient lib.
> I want to compile and static link this code, but as you can see it doesn't
> work.
> I've tried this on multiple systems. libmysqlclient.a exists.
>
> # cat mysql_test.cpp
> #include
>
> int main()
> {
> MYSQL h;
> mysql_init(&h);
> return 0;
> }
> # g++ -lmysqlclient mysql_test.cpp
> # g++ -lmysqlclient -static mysql_test.cpp
> /tmp/ccwpQvKN.o(.text+0x1e): In function `main':
> : undefined reference to `mysql_init'
> collect2: ld returned 1 exit status


Examine output of:

mysql_config
on your server(s)

Here is example from my RedHat9 where I have compiled 3.23, 4.0, 4.1 and 5.0 and
I'm able to link statically against each of them.

mysql_config
Usage: /usr/local/bin/mysql_config [OPTIONS]
Options:
--cflags [-I'/usr/local/mysql-4.0/include/mysql']
--libs [-L'/usr/local/mysql-4.0/lib/mysql' -lmysqlclient -lz
-lcrypt -lnsl -lm]
--socket [/tmp/mysql.sock]
--port [3306]
--version [4.0.14]
--libmysqld-libs [ -L'/usr/local/mysql-4.0/lib/mysql' -lmysqld -lpthread
-lz -lcrypt -lnsl -lm -lpthread -lrt]


You need to add all -L and -I flags in order to link against your MySQL libraries

Best regards

--
Are you MySQL certified? -> http://www.mysql.com/certification
For technical support contracts, visit https://order.mysql.com/?ref=msal
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Alexander Keremidarski
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer
/_/ /_/\_, /___/\___\_\___/ Sofia, Bulgaria
<___/ www.mysql.com




--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: Can"t static link to mysqlclient on RH7 or 9

am 20.06.2003 18:02:58 von Sinisa Milivojevic

Olaf van der Spek writes:
> Hi,
>
> I hope this is the right list to send this to because I think this is a bug
> in the static mysqlclient lib.
> I want to compile and static link this code, but as you can see it doesn't
> work.
> I've tried this on multiple systems. libmysqlclient.a exists.
>
> # cat mysql_test.cpp
> #include
>
> int main()
> {
> MYSQL h;
> mysql_init(&h);
> return 0;
> }
> # g++ -lmysqlclient mysql_test.cpp
> # g++ -lmysqlclient -static mysql_test.cpp
> /tmp/ccwpQvKN.o(.text+0x1e): In function `main':
> : undefined reference to `mysql_init'
> collect2: ld returned 1 exit status
> #
>
> >Description:
>
> >How-To-Repeat:
>
> >Fix:
> > lines)>
>

Your link command is wrong. -l goes after command option, which you do
not have at all.

--

Regards,

--
For technical support contracts, go to https://order.mysql.com/?ref=msmi
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB
/_/ /_/\_, /___/\___\_\___/ Fulltime Developer and Support Coordinator
<___/ www.mysql.com Larnaca, Cyprus


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: Can"t static link to mysqlclient on RH7 or 9

am 20.06.2003 19:24:03 von Olaf van der Spek

----- Original Message -----
From: "Alexander Keremidarski"
To: "Olaf van der Spek"
Cc:
Sent: Friday, June 20, 2003 6:00 PM
Subject: Re: Can't static link to mysqlclient on RH7 or 9


>
>
> Olaf van der Spek wrote:
> > Hi,
> >
> > I hope this is the right list to send this to because I think this is a
bug
> > in the static mysqlclient lib.
> > I want to compile and static link this code, but as you can see it
doesn't
> > work.
> > I've tried this on multiple systems. libmysqlclient.a exists.
> >
> > # cat mysql_test.cpp
> > #include
> >
> > int main()
> > {
> > MYSQL h;
> > mysql_init(&h);
> > return 0;
> > }
> > # g++ -lmysqlclient mysql_test.cpp
> > # g++ -lmysqlclient -static mysql_test.cpp
> > /tmp/ccwpQvKN.o(.text+0x1e): In function `main':
> > : undefined reference to `mysql_init'
> > collect2: ld returned 1 exit status
>
>
> Examine output of:
>
bash-2.05a$ mysql_config
Usage: /usr/bin/mysql_config [OPTIONS]
Options:
--cflags [-I'/usr/include/mysql']
--libs
[-L'/usr/lib/mysql' -lmysqlclient -lz -lcrypt -lnsl -lm]
--socket [/var/lib/mysql/mysql.sock]
--port [3306]
--version [3.23.56]
bash-2.05a$
g++ -I'/usr/include/mysql' -L'/usr/lib/mysql' -lmysqlclient -static
mysql_test.cpp
/tmp/ccq6m9ok.o: In function `main':
/tmp/ccq6m9ok.o(.text+0x14): undefined reference to `mysql_init'
collect2: ld returned 1 exit status
bash-2.05a$

> You need to add all -L and -I flags in order to link against your MySQL
libraries
>
Wouldn't the compiler complain about missing files if it couldn't find them?


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org