_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
i loaded mysql++ by following instructions in 'README' file within the
package.
in order to check that all include and libs were available, i tried to
compile
the following program (taken from the manual):
#include <iostream>
#include <iomanip>
#include <sqlplus.hh>
int main() {
Connection con("mysql_cpp_data");
// The full format for the Connection constructor is
// Connection(cchar *db, cchar *host="",
// cchar *user="", cchar *passwd="")
// You may need to specify some of them if the database is not
on
// the local machine or you database username is not the same as
your
// login name, etc..
Query query = con.query();
// This creates a query object that is bound to con.
query << "select * from stock";
// You can write to the query object like you would any other
ostrem
Result res = query.store();
// Query::store() executes the query and returns the results
cout << "Query: " << query.preview() << endl;
// Query::preview() simply returns a string with the current
query
// string in it.
cout << "Records Found: " << res.size() << endl << endl;
Row row;
cout.setf(ios::left);
cout << setw(17) << "Item"
<< setw(4) << "Num"
<< setw(7) << "Weight"
<< setw(7) << "Price"
<< "Date" << endl
<< endl;
Result::iterator i;
// The Result class has a read-only Random Access Iterator
for (i = res.begin(); i != res.end(); i++) {
row = *i;
cout << setw(17) << row[0]
<< setw(4) << row[1]
<< setw(7) << row["weight"]
// you can use either the index number or column name when
// retrieving the colume data as demonstrated above.
<< setw(7) << row[3]
<< row[4] << endl;
}
return 0;
}
i get the following errors (on compiling the above program by giving
command: g++ filename or g++ filename -L/usr/local/lib ) :
/tmp/cc7TYDR6.o: In function `main':
/tmp/cc7TYDR6.o(.text+0x2b): undefined reference to
`MysqlConnection::MysqlConnection(char const *, char const *, char const *,
char const *, bool)'
/tmp/cc7TYDR6.o(.text+0x46c): undefined reference to `operator<<(ostream &,
mysql_ColData<const_string> const &)'
/tmp/cc7TYDR6.o(.text+0x482): undefined reference to `operator<<(ostream &,
mysql_ColData<const_string> const &)'
/tmp/cc7TYDR6.o(.text+0x498): undefined reference to `operator<<(ostream &,
mysql_ColData<const_string> const &)'
/tmp/cc7TYDR6.o(.text+0x4ae): undefined reference to `operator<<(ostream &,
mysql_ColData<const_string> const &)'
/tmp/cc7TYDR6.o(.text+0x4b9): undefined reference to `operator<<(ostream &,
mysql_ColData<const_string> const &)'
/tmp/cc7TYDR6.o(.text+0x5ad): undefined reference to
`MysqlConnection::~MysqlConnection(void)'
/tmp/cc7TYDR6.o(.text+0x6ea): undefined reference to
`MysqlConnection::~MysqlConnection(void)'
/tmp/cc7TYDR6.o: In function `MysqlQuery::preview(void)':
/tmp/cc7TYDR6.o(.MysqlQuery::gnu.linkonce.t.preview(void)+0x15): undefined
reference to `SQLQuery::str(SQLQueryParms const &) const'
/tmp/cc7TYDR6.o: In function `MysqlRes::~MysqlRes(void)':
/tmp/cc7TYDR6.o(.gnu.linkonce.t._._8MysqlRes+0x15): undefined reference to
`MysqlResUse::~MysqlResUse(void)'
/tmp/cc7TYDR6.o: In function `MysqlQuery::store(SQLQueryParms &,
query_reset)':
/tmp/cc7TYDR6.o(.MysqlQuery::gnu.linkonce.t.store(SQLQueryParms &,
query_reset) +0x38): undefined reference to `SQLQuery::str(SQLQueryParms
const &, query_reset)'
/tmp/cc7TYDR6.o: In function `MysqlConnection::store(basic_string<char,
string_char_traits<char>, __default_alloc_template<true, 0> > const &)':
/tmp/cc7TYDR6.o(.MysqlConnection::gnu.linkonce.t.store(basic_string<char,
string_char_traits<char>, __default_alloc_template<1, 0> > const &)+0x1a):
undefined reference to `MysqlConnection::store(basic_string<char,
string_char_traits<char>, __default_alloc_template<true, 0> > const &,
bool)'
/tmp/cc7TYDR6.o: In function `MysqlRes::data_seek(unsigned int) const':
/tmp/cc7TYDR6.o(.MysqlRes::gnu.linkonce.t.data_seek(unsigned int)
const+0x11): undefined reference to `mysql_data_seek'
/tmp/cc7TYDR6.o: In function `MysqlRes::fetch_row(void) const':
/tmp/cc7TYDR6.o(.MysqlRes::gnu.linkonce.t.fetch_row(void) const+0xb5):
undefined reference to `mysql_fetch_row'
/tmp/cc7TYDR6.o(.MysqlRes::gnu.linkonce.t.fetch_row(void) const+0xc6):
undefined reference to `mysql_fetch_lengths'
/tmp/cc7TYDR6.o: In function `MysqlFieldNames::MysqlFieldNames(MysqlResUse
const *)':
/tmp/cc7TYDR6.o(.MysqlFieldNames::gnu.linkonce.t.(MysqlResUse const
*)+0x17): undefined reference to `MysqlFieldNames::init(MysqlResUse const
*)'
/tmp/cc7TYDR6.o: In function `FieldTypes::FieldTypes(MysqlResUse const *)':
/tmp/cc7TYDR6.o(.FieldTypes::gnu.linkonce.t.(MysqlResUse const *)+0x17):
undefined reference to `FieldTypes::init(MysqlResUse const *)'
collect2: ld returned 1 exit status
the object file (filename.o) is created without errors on giving command :
g++ filename -c
the contents of /usr/local/lib directory is:
-rwxrwxrwx 1 root root 5518186 Sep 13 09:08 libsqlplus.a
-rwxr-xr-x 1 root root 707 Sep 13 09:08 libsqlplus.la
lrwxrwxrwx 1 root root 19 Sep 13 09:08 libsqlplus.so ->
libsqlplus.so.1.0.7
lrwxrwxrwx 1 root root 19 Sep 13 09:08 libsqlplus.so.1 ->
libsqlplus.so.1.0.7
-rwxr-xr-x 1 root root 3146629 Sep 13 09:08 libsqlplus.so.1.0.7
also i have added the line '/usr/local/lib in /etc/ld.so.conf file.
i would like to add the following:
- the command: 'rpm -q mysql' reports mysql not installed, though the mysql
server is installed
and runs normally. it is located in directory: /usr/local/mysql. i had not
used rpm
file to install mysql.
- the include files of mysql were in /usr/local/mysql/include directory
and lib was in /usr/local/mysql/lib. i created the directories
/usr/local/mysql/lib/mysql
and /usr/local/mysql/include/mysql and copied the necessary files from the
above
directories into them. the file configure of mysql++ package completed its
job
only after doing this subdirectory creation and copying of files. i could
then
run make and make install.
i would like to add that i am sort of a novice in C++ and Linux. i am using
Redhat linux 6.20
please help me.
regards
Hormuzd Irani
(Mumbai- India)