to access MySQL

Posted on 2004-11-10
Last Modified: 2011-10-03
hello, all,

  i have very simple C++ program, which is to be used to create a connection with MySQL (V4.0) server. In this short program only few MySQL APIs are called, such as "mysql_init(...)", "mysql_real_connect(...)". of course, the header file was included "mysql.h".
  This  program had been successfully compiled, however, when it is to be linked to an exe file, a few errors were thrown out ( the error info is following ) , is the command wrong , or do any other header files have to be included in source?
  Operating system is RedHat !

[root@hw userproject]# gcc -I../include Test.o ../lib/libmysqlclient.a -o test
Test.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
../lib/libmysqlclient.a(my_compress.o)(.text+0xb4): In function `my_compress_alloc':
: undefined reference to `compress'
../lib/libmysqlclient.a(my_compress.o)(.text+0x12a): In function `my_uncompress':
: undefined reference to `uncompress'
collect2: ld returned 1 exit status

  thanx in advance
Question by:kim_wei
    LVL 9

    Expert Comment

    Do you have any files in /usr/lib/mysql path? Also, check if you have installed mysql-devel package for your distro.

    Author Comment

    hello, gtkfreak,

     i found a solution, it looks like,

    [root@hw userproject]# gcc -o Test Test.cpp  -I../include Test.o -L../lib -lmysqlclient -lz,
    however, i hav no idea about the option "-lz"? any idea?


    LVL 9

    Accepted Solution

    No. I use Anjuta IDE for C programming and in there, I can add the libraries to the make file. This makes it more easy to manage large software projects. Anjuta is available at

    To find what -lz stands for, you can try $ man gcc on the command line on your system.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
    The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now