C++ MySQL Header files not found (Linux Application) - c++

I am trying to connect to my local MySQL database hosted via XAMPP.
I downloaded this .zip file https://cdn.mysql.com//Downloads/Connector-C++/mysql-connector-c++-8.0.20-winx64.zip and I added the include folder to the field in C/C++->General/Additional Includes and of course the lib64 folder to the field in Linker->Input->Additional dependencies + Linker->General->Additional Library Directories.
Shall I download the MySQL Server (I have only installed XAMPP with MySQL)?
This is a Linux Console Application and I am running this with gdb on my WSL and I am running it in release x64 mode!
Code:
#include <cstdio>
#include "mysql_connection.h"
#include "mysql_driver.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
int main()
{
try
{
sql::Driver* driver;
sql::Connection* con;
driver = get_driver_instance();
con = driver->connect("tcp://localhost:3306", "root", "");
con->setSchema("botcaptcha");
}
catch (sql::SQLException& err)
{
printf(err.what());
}
return 0;
}
Error:
1>C:\Users\JanDerZocker05\Desktop\ConsoleApplication2\ConsoleApplication2\main.cpp(2,10): error : mysql_connection.h: No such file or directory
1>C:\Users\JanDerZocker05\Desktop\ConsoleApplication2\ConsoleApplication2\main.cpp(2,10): error : 2 | #include "mysql_connection.h"
1>C:\Users\JanDerZocker05\Desktop\ConsoleApplication2\ConsoleApplication2\main.cpp(2,10): error : | ^~~~~~~~~~~~~~~~~~~~
1>C:\Users\JanDerZocker05\Desktop\ConsoleApplication2\ConsoleApplication2\main.cpp(2,10): error : compilation terminated.
1>Die Erstellung des Projekts "ConsoleApplication2.vcxproj" ist abgeschlossen -- FEHLER
includes:
library directories:
libraries:

Related

VULKAN fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory

I'm working on getting Vulkan installed and working functionally.
I keep running into the error
"fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory"
Here's the code I have so far:
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>
#include <iostream>
int main()
{
return 0;
}
I'm on Windows 11.
I'm using Visual Studio 2022.
I've set the project properties C++ language as "C++20".
I've also included the correct libraries that are also labeled lib-vc2022.

c++ mysql connection bad_alloc using c++ connector

Trying to build a simple mysql connection, but getting a bad_alloc and I can't figure out how to solve this, even looking at similar posts
here is my code
#include <iostream>
#include <stdlib.h>
#include <sstream>
#include <memory>
#include <string>
#include <stdexcept>
#include "mysql_connection.h"
#include "cppconn\driver.h"
#include "cppconn\statement.h"
#include "cppconn\connection.h"
#include "cppconn\exception.h"
#include "cppconn\prepared_statement.h"
#include "cppconn\statement.h"
using namespace std;
using namespace sql;
int main()
{
Driver *driver;
Connection *conn;
Statement *stmt;
driver = get_driver_instance();
conn = driver->connect("127.0.0.1:3306", "root", "root"); // breaks here
stmt = conn->createStatement();
stmt->execute("USE mydb");
return 0;
}
I'm using mysql-connector-c++-1.1.7
mysqlcppconn.lib is used as a dependencies
mysqlcppconn.dll is located in the same dir as the .exe is.
Here is the error Exception thrown at 0x000007FEFD39A06D in MysqlConn.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x000000000014F5D0.
Thanks
I also had this error. In my case I am compiling using VS2015 in Windows.
First time I choose compile static version of the MySQL lib. Then later I decided to compile the dynamic version. This time the error bad_alloc at memory went off.
The solution is rolling back the CPPCONN_PUBLIC_FUNC= configuration.
Go to project Property Pages, under C++ > Preprocessor > Preprocessor Definitions and remove the item CPPCONN_PUBLIC_FUNC=".
I had the same error on linux.
The error was : I was using g++-4.8 to build the project
The issue lies on the version of the build tools (gcc,msvs,clang) used to build the project

C++ Boost Link error

I am working on Windows 10 and I downloaded Boost 1.60 for Visual Studio 2015.
My first code snippet looks as:
#include <boost/thread.hpp>
#include <vector>
#include <iostream>
#include <sstream>
#include <cmath>
#include <iostream>
using namespace std;
void main()
{
std::cout << "Hello World";
}
I get the error:
>LINK : fatal error LNK1104: cannot open file 'libboost_thread-vc140-mt-gd-1_60.lib'
I have provided path for boost and also libraries as shown in pics:
You need to compile the library before using it. Here's how to compile it:
In your Windows Start menu open the "Developer Command Prompt for VS2015". Then inside the opened command prompt, execute those commands:
cd C:\boost_1_60_0
bootstrap.bat
.\b2 runtime-link=shared toolset=msvc-14.0
Wait for a couple of minutes, since compilation takes a while.
Specify in your project in Linker -> General, the Additional Library Directories path as C:\boost_1_60_0\stage\lib, and in C++ -> General the Additional Include Directories path as C:\boost_1_60_0
You should now be able to compile your code without problem.

Using MySQL Connector/C++ in Xcode: -libmysqlcppconn library not found

I'm trying to use MySQL Connector/C++ within Xcode. I have installed MySQL server. I also installed MySQL Connector/C++ and Boost using brew. I believe all files are where they should be.
I've included library search paths:
1) /usr/local/mysql-5.6.24-osx10.8-x86_64/lib
2) /usr/local/mysql/lib
I am just trying to get simple code to run before I dive a little deeper:
#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"
#include "mysql_driver.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
using namespace std;
int main(int argc, const char * argv[]) {
sql::mysql::MySQL_Driver *driver;
sql::Connection *con;
driver = sql::mysql::get_mysql_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "user", "password");
delete con;
return 0;
}
The error I'm getting is: ld: library not found for -libmysqlcppconn
Any help would be greatly appreciated!
If you are using the Static MySQL Connector/C++ Library, did you link both library files: libmysqlcppconn-static.a and libmysqlclient.a? Do that in Xcode in the "Build Phases" tab under "Link Binary With Libraries" section. After you add those files make sure that the library search paths you provided point to the file locations.
For Dynamic Library instead you link the libmysqlcppconn.so file.

Connecting VS Express 2013 to MySQL with Connector C++ 1.1.3 - error LNK2019: unresolved external symbol

Scroll down for (part of) the solution that I found:
I'm on a Windows 8.1, 64 bit laptop
It is my first time trying to connect C++ to MySQL using the mentioned connector.
The error is as follow:
Error 1 error LNK2019: unresolved external symbol "class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_driver_instance(void)" (?get_driver_instance#mysql#sql##YAPAVMySQL_Driver#12#XZ) referenced in function _main C:\Users\user\documents\visual studio 2013\Projects\Profile\Profile\Profile.obj Profile
This is my main code:
// Profile.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <string>
#include "mysql_connection.h"
#include "mysql_driver.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
#define dbHOST "tcp://127.0.0.1:3306"
#define dbUSER "root"
#define dbPASS "root"
#define dbDB "db_test"
using namespace std;
using namespace sql;
int main()
{
sql::mysql::MySQL_Driver *driver;
sql::Connection *con;
driver = sql::mysql::get_driver_instance();
con = driver->connect(dbHOST, dbUSER, dbPASS);
delete con;
system("pause");
return 0;
}
I have followed the instructions from this mysql site for the static installation.
I have also Google quite a lot with the error.
Some suggested it could be the connector files different for 64bit and 32bits - I've tried downloading both (they are installed in Program Files and Program Files (x86) accorindgly. but the error persists.
One thing to note, when I link it with the 32bit connector files, it will have a huge load more of errors.
Makes me wonder after all the search, is it that VS Express 2013 is not compatible to connect with MySQL thus far?
I heard ppl saying using the Qt would be easier, but I still want to try this out.
Please let me know if my question is vague or if you need more information.
Thanks in advance!
SOLUTION I FOUND
I don't want to add it as an answer because it does not remedy the question I asked.
Anyway, I found a link which gives fairly simple instructions which has got it to work. Would still appreciate if anyone is willing to look into my original issue.
:)