C++ 2010: using #include <mysql.h> - c++

I have searched like crazy and cant find an answer. I am trying to use mysql in my c++ project and have #include mysql.h but I need that directory file. Does one exist? I got all my code set up but zilions of errors because the file is missing. I'm following a tutorial but they dont explain where to get that directory. Any help would be great. Thanks!!

I know that that I am too late to post the answer, but just documentation purposes and for those who search for the same error.
Download the mysql server. You can download it from here: http://www.mysql.com/downloads/
Downloading the community server is just enough. Note: choose the zip file. Choose the x32 since the compiler is automatically configured to build with x32 configuration. If you intend to change the compilation configuration to x64, then go ahead and download the x64 zip file.
After download the zip file, create your new blank project. If you are using MSVC++Express2010, Open the project properties | C/C++ | Additional Include Directories. Add the path to the include folder found in the extracted folder.
Copy the library files found in lib folder in the extracted folder to the project directory where you can find your *.cpp files.
Add the following lines to your code:
#include <my_global.h>
#include <mysql.h>
#pragma comment(lib, "libmysql.lib")
Now you are ready to go :)
You can try the code found here to see if things went right or not.

Related

How to use jsoncpp with Visual Studio 2022

I need my project to be able to use json format.
I was suggested this github : https://github.com/open-source-parsers/jsoncpp
I have been trying to integrate it to my project for multiple hours and still cant find the issue.
I still get these errors on my include :
#include <jsoncpp/json/json.h>
E1696 cannot open source file "jsoncpp/json/json.h"
C1083 Cannot open include file: 'jsoncpp/json/json.h'
I tried to go to C/C++ General->Additional Include Directories>
to add the "jsoncpp-master\include" directory
also tried "jsoncpp-master\include\json" directory
also tried to add the .h and .cpp found in the repository directly.
I have also tried a multitude of other things but I'm not sure it would be relevant to list them all here.
I was not able to find instructions to use it with Visual Studio 2022 on their github either.
Safest and most convenient way to use third party libraries is to use package manager like vcpkg
https://vcpkg.io/en/index.html
https://github.com/microsoft/vcpkg
Choose what build you want x86 or x64 and set default triplet in your environment variables
VCPKG_DEFAULT_TRIPLET
x64-windows - DLL Build 64-bit windows
x86-windows - DLL Build 32-bit windows
x64-windows-static - Static Build 64-bit windows
x86-windows-static - Static Build 32-bit windows
If you have added jsoncpp-master\include to C/C++ General->Additional Include Directories then you should use #include <json/json.h> instead of #include <jsoncpp/json/json.h>
Explanation : The compiler is looking inside the include directory. If you observer the file structure you can see json folder is located in the include directory and not jsoncpp.

how can I link mysql in dev-c++?

I tried a lot of solutions on google and baidu but none of them work. I downloaded and installed the 'MySQL.DevPak' file but still got the error 'mysql.h: No such file or directory'. Is there anybody done this before?
You probably have to declare the package to dev-c++. Look in the project configuration for 'Add an external library' and declare it there. DevC++ needs this to know where to look for 1) the header file, and 2) the actual library. And that is has to link the library into the executable.
Also, you might have to use #include <mysql/mysql.h>. At least in Linux, there's a mysql directory containing the actual mysql.h

No such directory or file in C++ [Codeblocks/Visual Studio]

I'm currently working on a project that will download a file from a website using the cURL library, but I'm currently getting an error when the compiler reaches the #include "curlpp/cURLpp.hpp" line. The IDE I'm using is Codeblocks with MinGW gcc compiler but I've also tried Visual Studio and I'm running into the same problem. The curl folder is located in the same folder as the source code.
Thanks in advance!
I had similar "path" issue. Try to change from:
#include "curlpp/cURLpp.hpp"
to:
#include "./curlpp/cURLpp.hpp"
In Visual Studio is also sometimes issue if your include directory is specified in VC++ Directories, put it rather into C++ -> General -> Additional Include Directories.

OpenCV using Eclipse with CDT

I was always using QtCreator for OpenCV but a new project started with a friend needs to be done with eclipse.
I did all things I usually do with QtCreator but I am facing a strange problem. Although I did set the include path (/home/opencv/include) when I try to compile I get errors for missing headers (i.e opencv2/core/core.hpp). In the project explorer under include tag the only headers appear are the ones in the first level of the included directory. This means that cdt does not include headers recursively.
Is this a bug or I have to include every single directory?
I had the same problem yesterday. It searched all around forums but nobody could answer me. Finally I realized that I was doing the include for the whole project and including files for the project is not the same as including files for the source file "source.cpp" (for eclipse, because for VisualStudio it is the same).
So try to rightclick on the .cpp file and include the directories for it. Anyway, if you tell me which version of OpenCV you're using I can tell you more aspects of how to include files in case you keep having troubles.
I hope it helps. When you get errors about missing headers is always related to include. At least it happened to be like this in my case.
If the include path in Eclipse is /home/opencv/include , we assume that inside this directory you have 2 folders: opencv and opencv2.
On your source code you must reference the headers as:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
Does that makes sense to you?
Nevertheless, there are several tutorials that can help you configure Eclipse.
I had this problem, too. I think what you need to do is to include the path opencv/build/include, not opencv/include. That's where all the header files are.

How do I add curlpp to my project?

I'm trying to make a transition from vb.net to C++ and I'm stuck on this. I downloaded curlpp from here which got me a .dll, .exp and .lib file. I added the directory that contains those 3 files to "Additional Library Directories" in the project properties (Linker -> General).
Next, I added ws2_32.lib and Wldap32.lib to "Additional Dependencies", also in the project properties (Linker -> Input) because this question stated I should.
Now I'm trying to get Example 00 to work, but
#include <curlpp/curlpp.hpp>
#include <curlpp/Easy.hpp>
#include <curlpp/Options.hpp>
States "cannot open source file curlpp/curlpp.hpp" etc. which makes sense because I have never even seen those files. What am I doing wrong? This is quite different from vb.net and I can't seem to figure it out.
UPDATE:
I did what Mat said, but it didn't work, so I added all relevent folders to be sure.
But VS still states the files can't be found.
You should download the full source package (.tar.gz in the downloads section) to get the headers, code, samples and documentation.
You'll need to add the base directory where the include files reside on your machine (after unpacking the archive) to the list of include directories for your project.