Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

MySQL Connector/C++ 1.1.1: Microsoft Visual Studio 2017 - Why doesnt it work ? (no replies)

$
0
0
Hello all, I have this code, that is supposed to connect to MySQL and get some basic information from it. I pushed the cart as far as I could, but when I try to build the program, it simply doesnt work.

I am using Visual Studio 2017.


Additional info:

The project is attempted to be build in Release mode, because it said so in manual. The folder mysqlx is in the same folder as the project MyTry.vcxproj.

I made sure that the MySQL database is set up correctly, it does work through command line.

This code is straight from the xdevapi manual, it was just snippet, so I added main function and hopefully correct namespace.

#include <iostream>
#include <mysqlx/xdevapi.h>

using namespace mysqlx;

int main()
{


// Connecting to MySQL and working with a Session

// Connect to a dedicated MySQL server using a connection URI
string url = "mysqlx://localhost:3306/test?user=MY_USER_NAME&password=MY_PASSWORD";
{
Session mySession(url);

// Get a list of all available schemas

list<Schema> schemaList = mySession.getSchemas();

std::cout << "Available schemas in this session:";

// Loop over all available schemas and print their name
for (Schema schema : schemaList) {
std::cout << schema.getName();
}


}

return 0;
}


Here is the steps, I have done so far.

1. Set up the MYSQL database properly.

In VS2017:
2. Configuration Properties - Release mode

3.
Configuration Properties -> C/C++ -> General -> Additional Include Directories -> and I put the parent dir of mysqlx.

4.Configuration Properties -> Linker -> General -> Additional Library Directories -> (and I include parent directory of mysqlx, which is concidently the project folder)

Now, when I try to build this project in Release mode. I will get these errors:

1>------ Build started: Project: MyTry, Configuration: Release x64 ------
1>mytry.cpp
1>c:\users\uzivatel\source\repos\mytry\mytry\mytry.cpp(22): error C2065: 'list': undeclared identifier
1>c:\users\uzivatel\source\repos\mytry\mytry\mytry.cpp(22): error C2275: 'mysqlx::Schema': illegal use of this type as an expression
1>c:\users\uzivatel\source\repos\mytry\mytry\mysqlx\xdevapi.h(143): note: see declaration of 'mysqlx::Schema'
1>c:\users\uzivatel\source\repos\mytry\mytry\mytry.cpp(22): error C2065: 'schemaList': undeclared identifier
1>c:\users\uzivatel\source\repos\mytry\mytry\mytry.cpp(27): error C2065: 'schemaList': undeclared identifier
1>c:\users\uzivatel\source\repos\mytry\mytry\mytry.cpp(27): error C3312: no callable 'begin' function found for type 'unknown-type'
1>c:\users\uzivatel\source\repos\mytry\mytry\mytry.cpp(27): error C3312: no callable 'end' function found for type 'unknown-type'
1>c:\users\uzivatel\source\repos\mytry\mytry\mytry.cpp(28): error C2065: 'schema': undeclared identifier
1>Done building project "MyTry.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What am I doing wrong ? Thank you

Viewing all articles
Browse latest Browse all 527

Trending Articles