Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: problem compiling program using mysql++

From: Brian Davis <bhd1(at)mindspring.com>
Date: Tue Jul 24 2007 - 21:25:01 EDT


Thanks very much Drew! Your suggestions worked perfectly. I really appreciate the help.

Brian

-----Original Message-----
>From: "Drew M." <ghasatta@gmail.com>
>Sent: Jul 24, 2007 2:43 AM
>To: Brian Davis <bhd1@mindspring.com>
>Cc: plusplus@lists.mysql.com
>Subject: Re: problem compiling program using mysql++
>
>Looks like a scope/namespace issue, not a mysql++ issue. The mysql++ library
>uses the 'mysqlpp' namespace, so you can either add "using namespace
>mysqlpp;" to the beginning of your file, or add the appropriate namespace
>scope operators to your code.
>
>This is also why the compiler is complaining about cout - this isn't a
>mysql++ issue but another namespace issue (in this case, it's the 'std'
>namespace).
>
>Here's a reference page for your info:
>http://www.cplusplus.com/doc/tutorial/namespaces.html
>
>See your example below, with a few things added:
>
>On 7/23/07, Brian Davis <bhd1@mindspring.com> wrote:
>>
>> Hello. I'm new to mysql and mysql++. I'm trying to compile the below
>> program for use with mysql++:
>>
>> #include <iostream>
>> #include <iomanip>
>> #include <mysql++.h>
>
>
>// either this:
>using namespace mysqlpp;
>
>int main(void)
>> {
>> // -> Create a connection to the database
>>
>
>// or prepend any reference to a mysql++ symbol like so:
>mysqlpp::Connection con("gamedata","127.0.0.1");
>
>>
>> // -> Create a query object that is bound to our connection
>> Query query = con.query();
>>
>> // -> Assign the query to that object
>> query << "SELECT * FROM paymentinfo";
>>
>> // -> Store the results from then query
>> Result res = query.store();
>>
>> // -> Display the results to the console
>>
>>
>> // -> Show the Field Headings
>> cout.setf(ios::left);
>> cout << setw(6) << "id"
>> << setw(10) << "playerid"
>> << setw(20) << "datepaid"
>> << setw(20) << "type"
>> << setw(20) << "amount" << endl;
>>
>> Result::iterator i;
>> Row row;
>> // The Result class has a read-only Random Access Iterator
>> for (i = res.begin(); i != res.end(); i++)
>> {
>> row = *i;
>> cout << setw(6) << row["id"]
>> << setw(10) << row["playerid"]
>> << setw(20) << row["datepaid"]
>> << setw(20) << row["type"]
>> << setw(20) << row["amount"] << endl;
>> }
>>
>> return 1;
>> }
>>
>>
>> I'm using Mingw/GCC 3.4.2 on Windows XP SP2 with the following command to
>> compile:
>>
>> C:\Dev-Cpp\mysqlexample1devcpp>g++ -c main.cpp -o main.o-I"Z:\dev-cpp\include"
>> -lmysqlclient -lmysqlpp -lmysqlpp_util -lmysql -L"Z:\dev-
>> cpp\lib"
>>
>> and I get the below errors:
>>
>> main.cpp: In function `int main()':
>> main.cpp:10: error: `Connection' undeclared (first use this function)
>> main.cpp:10: error: (Each undeclared identifier is reported only once for
>> each f
>> unction it appears in.)
>> main.cpp:10: error: expected `;' before "con"
>> main.cpp:13: error: `Query' undeclared (first use this function)
>> main.cpp:13: error: expected `;' before "query"
>> main.cpp:16: error: `query' undeclared (first use this function)
>> main.cpp:19: error: `Result' undeclared (first use this function)
>> main.cpp:19: error: expected `;' before "res"
>> main.cpp:25: error: `cout' undeclared (first use this function)
>> main.cpp:25: error: `ios' has not been declared
>> main.cpp:25: error: `left' undeclared (first use this function)
>> main.cpp:26: error: `setw' undeclared (first use this function)
>> main.cpp:30: error: `endl' undeclared (first use this function)
>> main.cpp:32: error: `Result' has not been declared
>> main.cpp:32: error: `iterator' undeclared (first use this function)
>> main.cpp:32: error: expected `;' before "i"
>> main.cpp:33: error: `Row' undeclared (first use this function)
>> main.cpp:33: error: expected `;' before "row"
>> main.cpp:35: error: `i' undeclared (first use this function)
>> main.cpp:35: error: `res' undeclared (first use this function)
>> main.cpp:37: error: `row' undeclared (first use this function)
>>
>> It seems like I'm not including a header file or not linking to a
>> particular library, but I cannot figure it out. I'm hoping another pair of
>> eyes can help me. Anyone who has a suggestion and the time, I'd be most
>> grateful for your response. Thanks.
>>
>> Brian
>>
>>
>>
>> --
>> MySQL++ Mailing List
>> For list archives: http://lists.mysql.com/plusplus
>> To unsubscribe:
>> http://lists.mysql.com/plusplus?unsub=ghasatta@gmail.com
>>
>>

-- 
MySQL++ Mailing List
For list archives: 
http://lists.mysql.com/plusplus
To unsubscribe:    
http://lists.mysql.com/plusplus?unsub=lists@pantek.com
Received on Tue Jul 24 21:25:22 2007

This archive was generated by hypermail 2.1.8 : Thu Aug 09 2007 - 19:28:33 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library