List:MySQL++« Previous MessageNext Message »
From:Deepak Shrestha Date:August 12 2008 3:50pm
Subject:Undefined Reference Error
View as plain text  
Hi,

I am getting a strange "Undefined Reference Error" when trying to build 
a modified "Simple1.cpp" example file. Here is the code:

main.cpp
=================================
#include <iostream>
#include <mysql++.h>

using namespace std;


int main()
{
    const char *db = "mydb", *server = "mysrvr", *user = "deepak", *pass 
= "myapp";

    //connect to database
    mysqlpp::Connection conn(false); //<--- ERROR SHOWS UP HERE

    if (conn.connect(db, server, user, pass))
    {
        mysqlpp::Query query = conn.query("SELECT * FROM Category");
        if (mysqlpp::StoreQueryResult res = query.store())
        {
            cout << "Movie Categories are:" << endl;
            for (size_t i = 0; i < res.num_rows(); i++)
            {
                cout << '\t' << res[i][0] << endl;
            }
        }
        else
        {
            cerr << "Failed to get the Movie category list." << endl;
            return 1;
        }
        return 0;
    }
    else
    {
        cerr << "DB connection failed: " << conn.error() << endl;
        return 1;
    }

}
===============================


and the error message is:
===============================
||=== SimpleSQLPPTest, Debug ===|
obj\Debug\main.o||In function `main':|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|12|undefined reference 
to `_imp___ZN7mysqlpp10ConnectionC1Eb'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|14|undefined reference 
to `mysqlpp::Connection::connect(char const*, char const*, char const*, 
char const*, unsigned int)'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|16|undefined reference 
to `_imp___ZN7mysqlpp10Connection5queryEPKc'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|22|undefined reference 
to `_imp___ZN7mysqlpplsERSoRKNS_6StringE'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|28|undefined reference 
to `mysqlpp::Connection::~Connection()'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|30|undefined reference 
to `mysqlpp::Connection::~Connection()'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|34|undefined reference 
to `_imp___ZNK7mysqlpp10Connection5errorEv'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|35|undefined reference 
to `mysqlpp::Connection::~Connection()'|
D:\CODE_BLOCKS_WORKSPACE\SimpleSQLPPTest\main.cpp|35|undefined reference 
to `mysqlpp::Connection::~Connection()'|
obj\Debug\main.o||In function `ZTv0_n12_N7mysqlpp5QueryD0Ev':|
C:\MySQL++\include\result.h:(.text$_ZN7mysqlpp5Query5storeEv[mysqlpp::Query::store()]+0x4d)||undefined

reference to `_imp___ZN7mysqlpp5Query3strERNS_13SQLQueryParmsE'|
C:\MySQL++\include\result.h:(.text$_ZN7mysqlpp5Query5storeEv[mysqlpp::Query::store()]+0x73)||undefined

reference to `_imp___ZN7mysqlpp14SQLTypeAdapterC1ERKSsb'|
C:\MySQL++\include\result.h:(.text$_ZN7mysqlpp5Query5storeEv[mysqlpp::Query::store()]+0x95)||undefined

reference to `_imp___ZN7mysqlpp5Query5storeERKNS_14SQLTypeAdapterE'|
||=== Build finished: 12 errors, 0 warnings ===|

==================================

I can see that it successfully compiles but this error shows up during 
the linking process.

I am trying to use MySQL++ in WindowsXP-MingW environment. I am still 
catching up with the examples to be confident enough to do something 
using this API.

Any Suggestions? I am completely new in this topic.

Thanks!




Thread
Undefined Reference ErrorDeepak Shrestha12 Aug
  • Re: Undefined Reference ErrorDeepak Shrestha13 Aug
    • Re: Undefined Reference ErrorWarren Young13 Aug
      • Re: Undefined Reference ErrorDeepak Shrestha13 Aug
        • Re: Undefined Reference ErrorDeepak Shrestha13 Aug