Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
problem compiling program using mysql++

problem compiling program using mysql++

2007-07-23       - By Brian Davis

 Back
Reply:     1     2     3  

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>

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;
}


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=mysql@(protected)