Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

problem compiling program using mysql++

From: Brian Davis <bhd1(at)mindspring.com>
Date: Mon Jul 23 2007 - 23:37:28 EDT


Hello. I'm new to mysql and mysql++. I'm trying to compile the below program for use with mysql++:

#include 
#include 
#include 

int main(void)
{

// -> Create a connection to the database
        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;

}
Do you need help?X

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:\devcpp \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)
Do you need more help?X
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=lists@pantek.com
Received on Mon Jul 23 23:37:46 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