?
Solved

to access MySQL

Posted on 2004-11-10
3
Medium Priority
?
424 Views
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
0
Comment
Question by:kim_wei
  • 2
3 Comments
 
LVL 9

Expert Comment

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

Author Comment

by:kim_wei
ID: 12552778
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?

thanx

kim
0
 
LVL 9

Accepted Solution

by:
gtkfreak earned 250 total points
ID: 12557335
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 http://www.anjuta.org

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

840 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