Compiling MariaDB C/C++ Connector on Windows - c++

I am trying to use MariaDB in my visual studio project, so after looking at the documentation, I installed MariaDB and downloaded the source code for the C/C++ connector.
I got the include folder linked to the project, so I am able to make calls to the functions there, but it won't build because the linker fails to find the function definitions (obviously). I have looked all over and cannot find any solid directions on building the .lib files I need. I have found two sources that say that I need to just build the mariadb_connector_c.sln, but that file does not exist in the source code that I got, nor does it exist on their Git repo: https://github.com/MariaDB/mariadb-connector-c
The closest thing that I have found is the appveyor.yml file they provided, which contains the following: Contents of YML File
Is there anybody out there who has done this before? I can't find anything online or in the files they provided pertaining to this.
UPDATE:
I found the answer thanks to some of the replies. I needed to run the source code through cmake in order to get the .sln that I could then build to get the .lib files I need to link to the project.

The answer is a generic answer for any cmake project
Install CMake. make sure cmake.exe is in PATH (Windows installer offers this option). Install Visual Studio, and make sure C/C++ compiler is installed
start command line prompt
Execute "cmake . && cmake --build ." in the command line prompt.
That#s it.

Related

Compiling and Linking to Visual Studio 2022 using OpenCV source code built as Win32 from CMake C++

I'm trying to use OpenCV with Dear ImGui in Visual Studio 2022. I'm new to C/C++ libraries and building in general, so I'm unsure if I'm doing anything right. ImGui uses 32-bit architecture and I've used Cmake gui to compile the source code as Win32. I think I have the compiled source code, but it seems to be different than downloading the pre-built libraries. File Explorer Screenshot. I've added the bin to PATH environmental variable, and in Visual Studio tried adding \include to Include Directories, \lib or \lib\Debug to Library Directories, and opencv_world460d.lib to Additional Dependencies. The program still runs, but it doesn't seem to include anything related to OpenCV in the #include files. I found a few .dll files in bin\Debug, but I'm not sure if I should bother with that. I think I could move the source code into the project, but I'm fairly certain that isn't the proper way to do it. Any help would be appreciated.
I needed to run the install target:
You may have built the project, but probably you didn't run the install target. Try running cmake --build <build_dir> --config Release and then cmake --install <build_dir> --config Release, where <build_dir> is a placeholder for the path to the build dir shown in the screenshot. The latter command probably requires admin privileges. Probably best to check the docs of the lib, if there's a step by step instruction for building & installing the whole thing. –
fabian

"CMakeLists.txt" seems to be missing

I was trying to build SFML in order to start developing 2d-games in c++. I put the source-code directory inside C: (the directory itself is called 'SFML'). while trying to generate .cbp files using CMake, I ran into an error:
"The source directory "C:/SFML" does not appear to contain CMakeLists.txt"
It seems like there is a missing file that CMake didn't create.
I am using Cmake 3.10.1, the installation file can be found in https://cmake.org/download/ under the title:"Windows win32-x86 Installer".
I tried to build SFML 2.4.2, using the generator of Codeblocks - MinGW makefiles. The version of codeblocks used is: codeblocks-16.01mingw-setup.exe, found in http://www.codeblocks.org/downloads/26
Did someone encounter the same problem before and knows how to overcome it? If not -
Is there an already-built, ready to use, libray of this version? (2.4.2)
If not.. do you know about a version of SFML that is usable in visual studio 2017?
And another question (That is the last one, I promise...) - maybe you can recommend me about another library for c++, that is usable to develop 2d-games?
edt:
note: I am completely new to all this building thing
the containments of SFML:
maybe it's the binary version?
lib contains some static libraries, bin contains some .dll s
You probably downloaded something wrong or potentially extracted the SFML source into a sub folder or something like that.
Since you've mentioned Visual Studio: SFML is 100% compatible with Visual Studio and you can build it from source any time without having to worry about dependencies (everything included in the repository).
The steps to compile are pretty easy. I'd recommend you install Git to clone the latest source from the SFML repository. In addition you'll need CMake, which you obviously got already.
Open a Command Prompt and change your directory to C:\SFML.
Clone the official repository using Git: git clone https://github.com/SFML/SFML.git source (note the trailing .)
Wait for the source to be checked out to the source sub directory.
Create a new directory called build: md build && cd build
Now invoke CMake, pointing to the source directory and also defining your install path: cmake -DCMAKE_INSTALL_PREFIX=C:/SFML ../source
Build and install a debug build of SFML: cmake --build . --target install --config debug
Build and install a release build of SFML: cmake --build . --target install --config release
Alternatively you can just open the generated Visual Studio solution and build the INSTALL project on your own.
(You shouldn't have to define a build tool or anything; CMake should notice Visual Studio being installed and pick it up automatically.)
I have experienced this using cmake version 3.10 when using the -S command line option. On cmake version 3.15.4 it behaves as expected - so if you update cmake then it might just work.
Note that the -S command line option was not supported before version 3.13:
https://cmake.org/cmake/help/v3.13/release/3.13.html#command-line
Normally cmake is called from a "build" subdirectory of a project root, the project root contains CMakelists.txt. So you would create a "build" directory, change to it, and submit "cmake ..". This would pull in CMakelists.txt from the project root, and use the "build" subdirectory that you are in as the build directory. We say "build", what it actually does is generate makefiles which can then used by the "native" build system (e.g. "make" or Visual Studio) to perform the actual compilation and linking. This arrangement is not always convenient, hence the introduction of the -S and -B command line options.

Compile libssh with msvc for x64

First of all, I’m not an expert in build libraries from the source with cmake and all this stuff. But unfortunately I have to. I followed up the steps mention in the INSTALL document of the libssh and read a few archived mails but nothing helps me out. It sounds so easy on the web, but I didn’t bring it to work. Here is what I’ve done so far:
Download source from (Version 0.7.5) from libssh git
As mentioned in INSTALL file, download and install cmake (Version 3.9.1)
As mentioned in INSTALL file, download and install OpenSSL (Version 1.0.2)
Ignore zlib, because its optional
Everything is installed in the default paths. Now starts cmake-gui.exe and set source code to …/src folder and binaries to …/build folder, press ‘Configure’ button, with Visual Studio 12 2013 Win64.
Now the first error is generated: install Library TARGETS given no DESTINATION. Okay, checks make file which use variable LIB_INSTALL_DIR to set the path, in my case the path is empty. Add item to cmake-gui named LIB_INSTALL_DIR with path to ../build dir.
Fine, configuration works, generate works, open project works. Try to build ‘ALL_BUILD’ ends up in error: C1083: Cannot open include file: 'config.h': No such file or directory. Searched my whole disk for the file, nothing found. I believe cmake have to generate this file, guessing right? Or is this file missing? Hope someone can help me out! Or maybe have a link to an already compiled lib? Doesn’t understand why libssh doesn’t offers a download, x64 is quite normal today.
Initial inspiration is often the right one, the missing config.h is normally generated by cmake.
If you using cmake-gui.exe, it expects an path to the source, heading is ‘Where is the source code:’. I thought this means the path to the source code files, which are located under …/src, but this is wrong. I need to the set the path to the root folder, in my case … and everything works like a charm.
Also need to change back to OpenSSL version 1.0.2, because somewhere around 30 function declarations has changed.

How to install dxflib [a C++ library] on Windows 8.1?

So I want to install the dxflibn (it allows for the program to read and write .dxf files). You can find the files here. I found, on there site, this Programmer's guide. If you go to page 3, it says how to install the library. It says to use cygwin and MinGW32. I have not used this tools before so need some help.
From what I read (when I was researching these tools), the MinGW32 is used to install the compiler needed and the Cygwin can emulate the Unix system. I do have some experience with Unix command line but limited.
Back to the instruction on page 3, it says to run two commands. The first command is for executable but from the file I downloaded (the dxflib zip) there is no "configure" file to execute. While searching even more, I found the the .pro file that is in the folder of the library can produce a make file but not sure how.
Questions:
What exactly do I need to do to install the dxflib?
After I install it, for me to run it from my C++ code, what do I need to do? I read here that I need to:
A) put the header files in a location which your compiler is aware of
B) put the dll files in a location which your linker is aware of.
Any help would be amazing, tnx :)
I was able to find a solution after all.
For question 1:
I first went and installed qmake (from the Qt website).
After that, I needed to include in my "system parameters" the qmake.exe so I can run it from the Command Prompt line (like it says here).
And finally, I opened cmd, navigated to the library directory and run the command qmake -spec win32-g++ dxflib.pro (as suggested here). This created the make file.
Now run the command MinGW32-make. This will create a "release" folder with with a static library (that will be needed a the next step) and come .o files.
For question 2:
I used the Dev-C++ IDE. After I had created a project, I went to "project>project options".
Under "Directories>Include Directories" I added the path of the source code of the library (path_of_where_you_unziped_the_library\dxflib-3.7.5-src\src).
Also, under "Parameters>Linker" I added the .a file that is under the "release" folder (path_of_where_you_unziped_the_library\dxflib-3.7.5-src\release)
This worked for me :)

Using cmake on windows for c++

for around 5 consecutive days i have been trying to set up my computer with the c++ environment for programming with libraries such as sdl,glm,opengl. its important for us to be able to run it on unix machines on presentations so im running with cmake.
i finally got it to work with the cmake-gui, i wont even bother trying anymore with any IDE.
i specified my folder project and where to build the binaries, i got a folder "CMakeFiles" along with a txt "CMakeCache", a CMAKE file "cmake_install.cmake" and a file "Makefile". also in my folder "CMakeFiles" there are lots of other folders such as "CMakeTmp", "CompilerIdC", "CompilerIdCXX etc" and in both folders "Compiler*" has each an .exe which doesnt work! so where is my wanted executable?
i opened cmd and navigated to my folder and tried to write "make" as we are supposed to do according to the intruction. alas, it didnt work very well. hoping you could share your wisdom and help a newbie like me!
so what exactly is needed for compiling projects containing additional libraries? so far i have a compiler, Mingw32, the latest CMake and using the cmake-gui for extracting the binaries but gets makefiles.
EDIT:
hrrm. is it only me who gets these kind of problems? i can add that i have look thorough about 10 tutorials and 90% of the steps are similar (if compiling with VS which i tried at first):
Download latest SDL
Make a folder on e.g C:\SDL with two folders, include and lib
Copy the libs and includes from the downloaded SDL
Make new VS project, open VC++ directories and add lib/incl folder on e.g C:\SDL
Add to linker SDL.lib and SDLmain.lib (i made sure they got linked, no problem here)
Change system to WINDOWS (optional if you dont want two windows)
Added include to "additional libraries"
Put the SDL.dll file (which i got from the latest SDL) in my C:\windows\system32(64SysWoW)
and also in my project file.
so what i am actually looking for is gettning the CMake to work, since it generates and builds sources successfully (with the gui) and i feel im closing in. do i need to add any additional libraries from sdl to my compiler mingw32 and/or cmake?
if you run cmake by command:
cmake -G "Visual Studio 14 Win64" path\to\source\dir
you need to run this command to continue(in Visual Studio Command Prompt):
msbuild Project.sln
either if you run cmake:
cmake -G "NMake Makefiles" path\to\source\dir
you need to run this cmd to continue(in Visual Studio Command Prompt):
nmake
You were almost there with Visual Studio. Select Visual Studio as target. Open the generated project in Visual Studio, build it. (just like you alread did). Then, instead of trying to run BUILD_ALL, run a real project that creates an executable, it should also be in that list. Just right click it and 'play' it.
If you still get errors, post them in detail including what you did before the error. Note: a carefully configured cross platform CMake project (aka the CMakeLists.txt) should not require any fiddling with VC++ directories. It should work automagically, especially with well known libs such as SDL.
If I understood it correctly you want to use CMake in your project. I'm using CMake in all my projects. I won't give you exact step-by-step howto, since I use Arch Linux but I used it in Windows 7 too.
To make CMake find the libraries, it is often needed to set up the CMAKE_PREFIX_PATH environment variable so it points to the directories where dependencies of your project are installed.
Set you PATH environment varible so you can invoke you compiler and make just by calling by calling eg. make. I think you need to do than manually for Mingw32, for Visual Studio you can use the "Visual Studio Command Propt" which has these variables already set.
Run CMake with desired generator. To select the generator from command line use the -G switch. You will probably use one of the following (the ... means other options you want to pass to cmake)
For GNU make used in MinGW use cmake -G "MinGW Makefiles" ...
For NMake from visual studio use cmake -G "NMake Makefiles" ...
It is also possible to create a Visual Studio project but I do not recommend it, since it quite difficult to set up automatic builds then. I also had some problems with dependencies when I tried to use VS project.
change directory to your build directory (ie. the one where you called cmake, it contains the CMakeCache file) and run make or nmake
Quoting from "CMake support in Visual Studio":
Visual Studio 2017 introduces built-in support for handling CMake projects. This makes it a lot simpler to develop C++ projects built with CMake without the need to generate VS projects and solutions from the command line. This post gives you an overview of the CMake support, how to easily get started and stay productive in Visual Studio.