dbTalk Databases Forums  

undefined reference error while compiling

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss undefined reference error while compiling in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jonas Jurczok
 
Posts: n/a

Default undefined reference error while compiling - 01-17-2006 , 06:03 AM






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:perator[](char const*) const'
/tmp/ccW796Nx.o(.text+0x1b8):mysqltest.cpp: undefined reference to
`mysqlpp::Row:perator[](char const*) const'
/tmp/ccW796Nx.o(.text+0x1fa):mysqltest.cpp: undefined reference to
`mysqlpp:perator<<(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:perator<<(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

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: undefined reference error while compiling - 01-17-2006 , 09:01 AM






Jonas Jurczok wrote:
Quote:
[root@localhost mysql]# c++ -o mysqltest -I /usr/include/mysql -I
/usr/include/mysql++/ mysqltest.cpp
You aren't linking to either the MySQL C API or the MySQL++ libraries
here. Please read the GCC documentation. This forum tasked with
teaching people how to use their build tools.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Warren Young
 
Posts: n/a

Default Re: undefined reference error while compiling - 01-17-2006 , 09:10 AM



Warren Young wrote:
Quote:
This forum tasked with
teaching people how to use their build tools.
Sorry, I meant to say, "This forum IS NOT tasked with teaching people
how to use their build tools."

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Jonas Jurczok
 
Posts: n/a

Default Re: undefined reference error while compiling - 01-17-2006 , 11:03 AM



It was not my goal to get anyone of you to explain gcc to me..

I just thought that it is a general mysql++ problem (old examples, wrong
funtion using).
but if you say it is a linking problem with the gcc...

I've read the gcc documentation and the problem still isnt solved..

even as i added -I .../mysql++/lib it didnt work..

thats why im out of ideas..



J. Jurczok

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #5  
Old   
Jonas Jurczok
 
Posts: n/a

Default Re: undefined reference error while compiling - 01-17-2006 , 12:04 PM



ok finally i got the clue what you wanted to say..

[root@localhost mysql]# c++ -I /usr/include/mysql -lmysqlpp
-lmysqlclient -o mysqltest mysql.cpp

result:
/usr/lib/gcc/i386-redhat-linux/4.0.2/../../../libmysqlpp.so: undefined
reference to `std::__default_alloc_template<true, 0>::allocate(unsigned
int)'
....

so now Im really out of Ideas..

yes I know, that this is not a real problem of mysql++ but to my mind
they are connected..
so i would __thank__ you very mutch if you please could give me a hint
what to do because im new to c++ and linux and have no idea what the
compiler wants..
I've looked up the gcc docu but didn't find anything...

sorry for my noob questions but I don't know it better..

thanks for help

J. Jurczok

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #6  
Old   
Jonas Jurczok
 
Posts: n/a

Default Re: undefined reference error while compiling - 01-17-2006 , 12:42 PM



ok i got further..

[root@localhost mysql]# c++ -I /usr/include/mysql -L /usr/include/mysql
/usr/local/lib/libmysqlpp.so -lmysqlclient mysql.cpp
mysql.cpp:86:2: warning: no newline at end of file
/usr/bin/ld: warning: libmysqlclient.so.14, needed by
/usr/local/lib/libmysqlpp.so, may conflict with libmysqlclient.so.10
[root@localhost mysql]# ./a.out
../a.out: symbol lookup error: /usr/lib/libmysqlpp.so.2: undefined
symbol: _ZNSt24__default_alloc_templateILb1ELi0EE12_S_free _listE
[root@localhost mysql]#

here we are back with an error connected to mysql++
i have no idea what that means...
but i would be thankfull if anyone could explain this to me!

J. Jurczok

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #7  
Old   
Tommy Apel
 
Posts: n/a

Default Re: undefined reference error while compiling - 01-17-2006 , 01:05 PM



It seem that you have 2 versions of the mysqlclient.lib try to only have one
version of mysql installed at one time
Quote:
ok i got further..

[root@localhost mysql]# c++ -I /usr/include/mysql -L /usr/include/mysql
/usr/local/lib/libmysqlpp.so -lmysqlclient mysql.cpp
mysql.cpp:86:2: warning: no newline at end of file
/usr/bin/ld: warning: libmysqlclient.so.14, needed by
/usr/local/lib/libmysqlpp.so, may conflict with libmysqlclient.so.10
[root@localhost mysql]# ./a.out
./a.out: symbol lookup error: /usr/lib/libmysqlpp.so.2: undefined
symbol: _ZNSt24__default_alloc_templateILb1ELi0EE12_S_free _listE
[root@localhost mysql]#

here we are back with an error connected to mysql++
i have no idea what that means...
but i would be thankfull if anyone could explain this to me!

J. Jurczok
--
Tommy Apel
Software Developer

Fax : (+371) 7 473 607
Cell : (+371) 8 293 490
VoIP DK : (+45) 46 96 81 61
VoIP ES : (+45) 46 96 81 60
E-Mail : root (AT) cargoa2b (DOT) com

SIA "Cargo A2B"
Liepezera iela 1,
Liepezeras ciemats,
Babites pagasts
LV-2101 Riga, Latvia

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #8  
Old   
Jonas Jurczok
 
Posts: n/a

Default Re: undefined reference error while compiling - 01-17-2006 , 01:20 PM



ok works..

I added the libary path in /etc/dl.so.conf
and now it works..
I don't know why but it works so.. never touch a running system

thanks for all the help

J. Jurczok

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.