0

I have been trying to employ SOCI library for the c++ project I am working on as I needed to access MySQL databases. I have been wrapping my head around how exactly this library works in terms of installing. I have windows 11 and want to use the library on eclipse. What I've done so far:

-Downloaded soci-4.0.3 in C:\

-Made an empty "build" file inside "C:\soci-4.0.3"

-Accessed the build file using Command Prompt

-Wrote 'cmake -G "MinGW Makefiles" ..'"(as I will use it for Eclipse)

-Then 'cmake --build . '

-In "soci-4.0.3\build\include" there is only "soci-config.h"

-In "soci-4.0.3\build\lib" .a and .dll.a files are present.

Then I included the "include" file in the gcc++ compiler include section and "lib" file in the MinGW Linker (-L)

When I compile my code in main.cpp trying to make a connection, it keeps saying that certain .cpp files(ex.soci\soci-platform.h) are missing.

I realize that there is a lot of ambiguity in the formulation of the steps that I took, as I don't have much experience using libraries and cmake, let alone the SOCI library. but I was wondering if there is any obvious step that I missed.

Thank you so much!

Evank800
  • 17
  • 3
  • 1
    Why not just use a package manager like [vcpkg](https://github.com/microsoft/vcpkg)? Make your life much eaiser. – WBuck Mar 02 '23 at 16:01
  • @WBuck I thought that was only available for visual studio and not for eclipse. Can it handle any C++ libraries on any editor? – Evank800 Mar 02 '23 at 16:07
  • 2
    Directory `soci-4.0.3\build\include` contains only those headers, which are **generated** during the building. Headers, which existed in the source directory, remains in that directory (under `include`). You are better to **install** the project (`cmake --install . `), so all its headers will be copied into the single place. You may choose any installation directory as you want. That directory is specified in `-DCMAKE_INSTALL_PREFIX=<..>` option when configure the project. – Tsyvarev Mar 02 '23 at 16:07
  • 1
    It'll work anywhere. It's not tied to a specific IDE or OS. You can use it from the command line. `vcpkg install soci`. After using a package manager I never went back.. – WBuck Mar 02 '23 at 16:11
  • @Tsyvarev Thank you for the helpful comment. I have just used the "cmake --install ." inside the build directory. and it gives out the following error: CMake Error at cmake_install.cmake:41 (file): file INSTALL cannot make directory "C:/Program Files (x86)/SOCI/include/soci": No such file or directory. Does the soci-X.Y.Z file need to be in Program Files? – Evank800 Mar 02 '23 at 16:33
  • 1
    "Does the soci-X.Y.Z file need to be in Program Files?" - As I said in my previous comment, you may specify installation prefix via `-DCMAKE_INSTALL_PREFIX` option. – Tsyvarev Mar 02 '23 at 16:55
  • you can also use [`--prefix`](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake--install-0) – starball Mar 02 '23 at 22:44

0 Answers0