Bug #2325 compiling error
Submitted: 8 Jan 2004 9:43 Modified: 8 Jan 2004 13:10
Reporter: Raymundo Cesar Alexandre Cuen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:mysql-3.23.52-3 OS:Linux (linux)
Assigned to: Dean Ellis CPU Architecture:Any

[8 Jan 2004 9:43] Raymundo Cesar Alexandre Cuen
Description:

  iam trying to compile the example client1.c of its book but I have problems this is what I do:

gcc -o Conex1 conex.c -I/usr/local/mysql/include/ -L/usr/local/mysql/lib/ -lmysqlclient

 and  appears this:

En el fichero incluĆ­do de /usr/local/mysql/include/my_global.h:303,
de conex.c:1:
/usr/include/asm/atomic.h:40:2: aviso: #warning Using kernel header in userland program. BAD!
/usr/local/mysql/lib//libmysqlclient.a(my_compress.o): In function `my_compress_alloc':
my_compress.o(.text+0xb4): undefined reference to `compress'
/usr/local/mysql/lib//libmysqlclient.a(my_compress.o): In function `my_uncompress':
my_compress.o(.text+0x12a): undefined reference to `uncompress'
collect2: ld devolvió el estado de salida 1

  this is code: 
#include <my_global.h>
#include <mysql.h>
static char *opt_host_name = NULL; /* server host (default=localhost) */
static char *opt_user_name = NULL; /* username (default=login name) */
static char *opt_password = NULL; /* password (default=none) */
static unsigned int opt_port_num = 0; /* port number (use built-in value) */
static char *opt_socket_name = NULL; /* socket name (use built-in value) */
static char *opt_db_name = NULL; /* database name (default=none) */
static unsigned int opt_flags = 0; /* connection flags (none) */
static MYSQL *conn; /* pointer to connection handler */

int main (int argc, char *argv[])
{
  /* initialize connection handler */
  conn = mysql_init (NULL);
  /* connect to server */
  mysql_real_connect (conn, opt_host_name, opt_user_name, opt_password,
  opt_db_name, opt_port_num, opt_socket_name, opt_flags);
  /* disconnect from server */
  mysql_close (conn);
  exit (0);
}

How to repeat:
 i dont know

Suggested fix:

 i dont know
[8 Jan 2004 13:10] Dean Ellis
This looks to be not a bug; check the output of mysql_config and make sure you are linking to all of the required libraries.
[4 Jan 2005 8:16] Andrew Morrow
In this case, you simply need ot add "-lz" to you command line to include libz, which defineds compress and uncompress.