Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hello, please help, it's been 4 days since i'm trying to work it out, after all the hours i spent on trying to link the libraries i'm honestly begging for help. First of all, what i did to install libraries:
1.) downloaded mysql-connector-c++-noinstall-1.1.0-win32 libraries from here: http://download.softagency.net/MySQL/Downloads/Connector-C++/[^] as they contain sqlstring dir.
2.) dowloaded boost libraries 1_49_0

Setting up the VS 2010:
1.) in properties -> general i set multi-byte char.
2.) in prop. -> C/C++ -> general i add paths to boost 1_49_0, connector folder ,,include" and connector folder ,,cppconn"
3.5.)i've added also the path to the C:\Program Files\MySQL\MySQL Server 5.5\lib, where libmysql.lib is-
3.) in prop. -> C/C++ -> preprocessor def. i added CPPCONN_PUBLIC_FUNC=
HAVE_INT8_T=1
4.) in prop. -> Linker -> i added path to the connector folder to the ,,lib" dir.
5.) in the Linker -> input i added additional dependencies: mysqlcppconn-static.lib
and libmysql.lib

In VS i'm running a new empty project - > C++ :

/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <winsock.h>

/*
Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!
*/
#include "mysql_connection.h"

#include
#include
#include
#include

using namespace std;

int main(void)
{
cout << endl;
cout << "Running 'SELECT 'Hello World!' »
AS _message'..." << endl;


try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;

/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
/* Connect to the MySQL test database */
con->setSchema("test");

stmt = con->createStatement();
res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
while (res->next()) {
cout << "\t... MySQL replies: ";
/* Access column data by alias or column name */
cout << res->getString("_message") << endl;
cout << "\t... MySQL says it again: ";
/* Access column fata by numeric offset, 1 is the first column */
cout << res->getString(1) << endl;
}
delete res;
delete stmt;
delete con;

} catch (sql::SQLException &e) {
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " »
<< __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
}

cout << endl;

return EXIT_SUCCESS;
}


The errors i'm getting are:

Error 1 error C2001: newline in constant c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 24
Error 2 error C2146: syntax error : missing ';' before identifier 'AS' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 3 error C2001: newline in constant c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 4 error C2015: too many characters in constant c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 5 error C2065: 'AS' : undeclared identifier c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 6 error C2146: syntax error : missing ';' before identifier '_message' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 7 error C2065: '_message' : undeclared identifier c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 8 error C2143: syntax error : missing ';' before 'constant' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
Error 9 error C2143: syntax error : missing ';' before 'try' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 28
Error 10 error C2146: syntax error : missing ';' before identifier '»' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 57
Error 11 error C2065: '»' : undeclared identifier c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 57
12 IntelliSense: missing closing quote c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 24
13 IntelliSense: expected a ';' c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
14 IntelliSense: missing closing quote c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 25
15 IntelliSense: identifier "stmt" is undefined c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 51
16 IntelliSense: identifier "con" is undefined c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 52


Please help me, what am i doing wrong, i've tried so many ways to figure it out but it is still not working :/
Posted

1 solution

Read the first error messages:
Error 1 error C2001: newline in constant c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 24

12 IntelliSense: missing closing quote c:\users\patrick\documents\visual studio 2010\projects\sklep_rowerowy\sklep_rowerowy\sklep_rowerowy.cpp 24

Then go to line 24 and fix it.

I assume you should rewrite lines 24 and 25 to be:
C++
cout << "Running ''SELECT Hello World!' AS _message'..." << endl;
 
Share this answer
 
Comments
Member 9152265 21-Jun-12 11:07am    
When i do the debug i works but yet i get an error massage saying(translating to english):

application wasn't started properly error (0xc000007b) Click OK to stop the application. Any clues on that :/ ?

Also had to copy libmysql.dll to the project folder: C:\Users\Patrick\Documents\Visual Studio 2010\Projects\sklep_rowerowy\Release, did same to the debug folder but in both modes getting error massage :/

The program '[6704] sklep_rowerowy.exe: Native' has exited with code -1073741701 (0xc000007b).
Jochen Arndt 21-Jun-12 11:31am    
I don't know what's the source for that error. When googling that code, possible sources are:
- Mixed 32/64 bit environment (e.g. 32bit app tries to load 64bit DLL)
- Corrupted registry
- Devices (hard disk); check device manager
- .Net / VisualStudio; try updating / re-install
- Virus

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900