Hello,

this my first approach to mysql++.

I have installed
-----------------------------
redhat 7.0
MySQL-shared-3.23.33-1
MySQL-client-3.23.33-1
MySQL-3.23.33-1
MySQL-devel-3.23.33-1
mysql++-1.7.8-1


when I try to build the first example(simpe1.cc attached) this giv me
some errors, like this:
--------------------------------------------------------------------------------------------

/tmp/ccFoGsdT.o: In function `main':
/tmp/ccFoGsdT.o(.text+0x30): undefined reference to
`MysqlConnection::MysqlConnection(char const *, char const *, char const

*, char const *, bool)'
/tmp/ccFoGsdT.o(.text+0x5bd): undefined reference to `operator<<(ostream

&, mysql_ColData<const_string> const &)'
/tmp/ccFoGsdT.o(.text+0x6a5): undefined reference to
`MysqlConnection::~MysqlConnection(void)'
/tmp/ccFoGsdT.o(.text+0x815): undefined reference to
`MysqlConnection::~MysqlConnection(void)'
/tmp/ccFoGsdT.o: In function `MysqlRes::~MysqlRes(void)':
/tmp/ccFoGsdT.o(.gnu.linkonce.t._._8MysqlRes+0x1d): undefined reference
to `MysqlResUse::~MysqlResUse(void)'
/tmp/ccFoGsdT.o: In function `MysqlQuery::preview(void)':
/tmp/ccFoGsdT.o(.MysqlQuery::gnu.linkonce.t.preview(void)+0x18):
undefined reference to `SQLQuery::str(SQLQueryParms const &) const'
/tmp/ccFoGsdT.o: In function `MysqlResUse::num_fields(void) const':
/tmp/ccFoGsdT.o(.MysqlResUse::gnu.linkonce.t.num_fields(void)
const+0x10): undefined reference to `mysql_num_fields'
/tmp/ccFoGsdT.o: In function `MysqlRes::num_rows(void) const':
/tmp/ccFoGsdT.o(.MysqlRes::gnu.linkonce.t.num_rows(void) const+0x10):
undefined reference to `mysql_num_rows'
/tmp/ccFoGsdT.o: In function `MysqlQuery::store(SQLQueryParms &,
query_reset)':
/tmp/ccFoGsdT.o(.MysqlQuery::gnu.linkonce.t.store(SQLQueryParms &,
query_reset) +0x42): undefined reference to `SQLQuery::str(SQLQueryParms

const &, query_reset)'
/tmp/ccFoGsdT.o: In function
`MysqlFieldNames::MysqlFieldNames(MysqlResUse const *)':
/tmp/ccFoGsdT.o(.MysqlFieldNames::gnu.linkonce.t.(MysqlResUse const
*)+0x42): undefined reference to `MysqlFieldNames::init(MysqlResUse
const *)'
/tmp/ccFoGsdT.o: In function `MysqlRes::fetch_row(void) const':
/tmp/ccFoGsdT.o(.MysqlRes::gnu.linkonce.t.fetch_row(void) const+0xba):
undefined reference to `mysql_fetch_row'
/tmp/ccFoGsdT.o(.MysqlRes::gnu.linkonce.t.fetch_row(void) const+0xce):
undefined reference to `mysql_fetch_lengths'
/tmp/ccFoGsdT.o: In function `MysqlRes::data_seek(unsigned int) const':
/tmp/ccFoGsdT.o(.MysqlRes::gnu.linkonce.t.data_seek(unsigned int)
const+0x1a): undefined reference to `mysql_data_seek'
/tmp/ccFoGsdT.o: In function `MysqlConnection::store(basic_string<char,
string_char_traits<char>, __default_alloc_template<true, 0> > const &)':

/tmp/ccFoGsdT.o(.MysqlConnection::gnu.linkonce.t.store(basic_string<char,

string_char_traits<char>, __default_alloc_template<true, 0> >
const &)+0x19): undefined reference to
`MysqlConnection::store(basic_string<char, string_char_traits<char>,
__default_alloc_template<true, 0> > const &, bool)'
/tmp/ccFoGsdT.o: In function `FieldTypes::FieldTypes(MysqlResUse const
*)':
/tmp/ccFoGsdT.o(.FieldTypes::gnu.linkonce.t.(MysqlResUse const *)+0x42):

undefined reference to `FieldTypes::init(MysqlResUse const *)'
collect2: ld returned 1 exit status
--------------------------------------------------------------------------------------------

if you can, help me.

thank you very much!

--

--

  :) cumprimentos
---------------------------------------
  Jose Luis Faria
  Tec. Superior Informatica - Administrador de Sistemas

   /\
  /\/\  Departamento de Informatica
  Universidade do Minho
  http://www.di.uminho.pt/jose


#include <iostream>
#include <iomanip>
#include <sqlplus.hh>
#include <define_short>

int main() {
  // 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..
  try {
                Connection con("ADMIN","127.0.0.1","jose","diogojose");
                Query query = con.query();
                // This creates a query object that is bound to con.

                query << "select * from testes";
                // 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(15) << "ip" 
                        << setw(5)  << "data"
                        << "descricao" << 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].c_str()
                                << setw(4)  << row[1].c_str()
                                << setw(7)  << row["weight"].c_str()
                                // you can use either the index number or column name 
when
                                // retrieving the colume data as demonstrated above.
                                << setw(7)  << row[3].c_str()
                                << row[4] << endl;
                }
  } catch (BadQuery &er) { // handle any connection or
                          // query errors that may come up
#ifdef USE_STANDARD_EXCEPTION
    cerr << "Error: " << er.what() << endl;
#else
    cerr << "Error: " << er.error << endl;
#endif
    return -1;
  } catch (BadConversion &er) { // handle bad conversions
#ifdef USE_STANDARD_EXCEPTION
    cerr << "Error: " << er.what() << "\"." << endl
         << "retrieved data size: " << er.retrieved
         << " actual data size: " << er.actual_size << endl;
#else
    cerr << "Error: Tried to convert \"" << er.data << "\" to a \""
         << er.type_name << "\"." << endl;
#endif
    return -1;
  } catch (exception &er) {
    cerr << "Error: " << er.what() << endl;
    return -1;
  }
        return 0;
}

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to