Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Aug 1998 20:44:12 -0400
From:      Mr Bill <gmann@itw.com>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Arg...Undefined symbol...error in C program
Message-ID:  <35C8FC5C.3AB72BE8@itw.com>

next in thread | raw e-mail | index | archive | help
Hello again folks.  This oughtta be easy, but then again...I'm trying to
use the MySQL C API to access a database.  Seems easy enough.  Here's a
(non-useful) program snippet:

-------snibegin------
  #include <stdio.h>
  #include <mysql.h>

  main()
  {
    MYSQL  MySQL;  
    mysql_connect(&MySQL, "mrbill", "bill", "metekake");
  } /* main */
-------sniend---------

The header file (mysql.h) has the declaration:

  MYSQL *mysql_connect(MYSQL *mysql, const char *host,
                       const char *user, const char *passwd);
I try, and get:

  MrBill:~/db/src$ cc -I/usr/local/include/mysql -L/usr/local/lib/mysql
-lmysqlclient tryme.c
  /var/tmp/ccSBG4211.o: Undefined symbol `_mysql_connect' referenced
from text segment

The MySQL docs say I need to add a -lm library as the last linked lib,
but that does not help.  The compiler checks the mysql header, because
syntax or type errors halt compilation.  The lib seems OK:

  MrBill:/usr/local/lib/mysql$ strings libmysqlclient.a | grep connect
  _mysql_real_connect
  _mysql_connect
  _mysql_reconnect
  _mysql_real_connect
  _remember_connection
  _mysql_connect
  _connect

This oughtta be easy.  Have I lost my mind?

Thanks
-Glen

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35C8FC5C.3AB72BE8>