List:MySQL++« Previous MessageNext Message »
From:Jonas Jurczok Date:January 17 2006 12:03pm
Subject:undefined reference error while compiling
View as plain text  
hi

so that i finally got the examples working I wanted to write an own 
snippet about mysql++ connection..

as long as i just have one error everything is ok..
but when i correct the error I get a bunch of undefined reference errors..

[root@localhost mysql]# c++ -o mysqltest -I /usr/include/mysql -I 
/usr/include/mysql++/ mysqltest.cpp
mysqltest.cpp:89:2: warning: no newline at end of file
/tmp/ccW796Nx.o(.text+0x7b): In function `main':
mysqltest.cpp: undefined reference to 
`mysqlpp::Connection::Connection(bool)'
/tmp/ccW796Nx.o(.text+0xab):mysqltest.cpp: undefined reference to 
`mysqlpp::Connection::connect(char const*, char const*, char const*, 
char const*, unsigned int, char, unsigned int, char const*, unsigned int)'
/tmp/ccW796Nx.o(.text+0xc4):mysqltest.cpp: undefined reference to 
`mysqlpp::Connection::query()'
/tmp/ccW796Nx.o(.text+0x180):mysqltest.cpp: undefined reference to 
`mysqlpp::Row::operator[](char const*) const'
/tmp/ccW796Nx.o(.text+0x1b8):mysqltest.cpp: undefined reference to 
`mysqlpp::Row::operator[](char const*) const'
/tmp/ccW796Nx.o(.text+0x1fa):mysqltest.cpp: undefined reference to 
`mysqlpp::operator<<(std::basic_ostream<char, std::char_traits<char>
>&, 
mysqlpp::ColData_Tmpl<mysqlpp::const_string> const&)'
/tmp/ccW796Nx.o(.text+0x22c):mysqltest.cpp: undefined reference to 
`mysqlpp::operator<<(std::basic_ostream<char, std::char_traits<char>
>&, 
mysqlpp::ColData_Tmpl<mysqlpp::const_string> const&)'
/tmp/ccW796Nx.o(.text+0x2f8):mysqltest.cpp: undefined reference to 
`mysqlpp::Row::~Row()'
/tmp/ccW796Nx.o(.text+0x315):mysqltest.cpp: undefined reference to 
`mysqlpp::Row::~Row()'
/tmp/ccW796Nx.o(.text+0x354):mysqltest.cpp: undefined reference to 
`mysqlpp::Row::~Row()'
/tmp/ccW796Nx.o(.text+0x371):mysqltest.cpp: undefined reference to 
`mysqlpp::Row::~Row()'
/tmp/ccW796Nx.o(.text+0x3a3):mysqltest.cpp: undefined reference to 
`mysqlpp::Query::error()'
/tmp/ccW796Nx.o(.text+0x439):mysqltest.cpp: undefined reference to 
`mysqlpp::ResUse::~ResUse()'
/tmp/ccW796Nx.o(.text+0x453):mysqltest.cpp: undefined reference to 
`mysqlpp::ResUse::~ResUse()'
/tmp/ccW796Nx.o(.text+0x49f):mysqltest.cpp: undefined reference to 
`mysqlpp::Connection::~Connection()'
/tmp/ccW796Nx.o(.text+0x4cb):mysqltest.cpp: undefined reference to 
`mysqlpp::Connection::~Connection()'


the code i used is copied from the examples..
i just changed some constants so that it will fit to my db..

code:
//#include "/usr/src/mysql++/examples/util.h"

#include "/usr/include/mysql++/mysql++.h"


#include <iostream>
#include <iomanip>

/*
#include <fstream>
#include <stdlib.h>
#include <sys/stat.h>
*/

using namespace std;
//using namespace mysqlpp;


const char db_name[] = "owigen";
const char db_host[] = "localhost";
const char db_user[] = "owiger";
const char db_psswd[] = <psswd>;



int main(int argc, char *argv[]) {

 //establish connection
 mysqlpp::Connection con(mysqlpp::use_exceptions);
 con.connect(db_name,db_host,db_user,db_psswd);

/*
 if (!connect_to_db(argc,argv,con)) {
  cout << "connection failed!\n";
  return 1;
 }
*/

 //create query
 mysqlpp::Query query = con.query();
 query << "SELECT * from `option`";
 //Result res = query.store();
 mysqlpp::ResUse res = query.use();

 //display result
 cout << "Option contains following data:\n";
 cout << "Name:        Value\n\n";

//functions found in SIMPLE 3
 if (res) {
  mysqlpp::Row row;

  while (row = res.fetch_row()) {
   cout << setw(20) << row["name"] << "=" << setw(20) <<
row["value"] << 
endl;

   return 0;
  }
 }





/*
functions found in SIMPLE 1

 if (res) {
 
  char buf[100];
  Row row;
  Row::size_type i;

  for (i = 0; row = res.at(i); i++) {
   //cout <<'\t' << utf8trans(row.at(0),buf,sizeof(buf)) << endl;
   //cout <<'\t' << strncpy(buf, row.at(0), sizeof(buf)) << endl;
   cout << '\t' << row.at(0) << endl;
  }
 }


*/

 else {
  cout << "no datas found: " << query.error() << endl;
  return 1;
 }

 return 0;
}


has anyone an idea why i get these undefined reference errors?
i recreated the file but nothing helped..
Im so confused because the examples work.. without error..

thx 4 help

J. Jurczok
Thread
undefined reference error while compilingJonas Jurczok17 Jan
  • Re: undefined reference error while compilingWarren Young17 Jan
    • Re: undefined reference error while compilingWarren Young17 Jan
      • Re: undefined reference error while compilingJonas Jurczok17 Jan
      • Re: undefined reference error while compilingJonas Jurczok17 Jan
      • Re: undefined reference error while compilingJonas Jurczok17 Jan
        • Re: undefined reference error while compilingTommy Apel17 Jan
      • Re: undefined reference error while compilingJonas Jurczok17 Jan