0

im pretty much new to c++ and im currently making a project where i need to connect to a mariadb database, so I investigated and found the official mariadb connector/c++, but im not sure if this is the way most people go... so if you have a better aproach to conect to a mariadb server using c++, please tell me bellow. Im also using gradle for my project, so if you know how to solve my issue using gradle i'd be graceful. Anyway, the issue is that when i follow the official guide

https://mariadb.com/docs/clients/connector-cpp/#building-the-c-application

and compile with

g++ -o app.exe app.cpp -std=c++11 -lmariadbcpp

i get the following:

enter image description here

and got no idea what to do about it.

Again, maybe I'm going the official way, but also the dumb/bad way?, and if not, how could i do it using gradle?

Thank you for your time! ^-^

Mohamed Kamal
  • 2,377
  • 5
  • 32
  • 47
zark0
  • 101
  • 1
  • 6
  • _Install_ `mariadbcpp`. – KamilCuk May 08 '21 at 23:50
  • Probably you have to include the path where the library is located into your `g++` command with the [`-L` flag as described here](https://stackoverflow.com/a/6141166/9938686) as well. – 2b-t May 09 '21 at 00:53
  • hi [2b-t](https://stackoverflow.com/users/9938686/2b-t), looks like you are wright, but I still need the library, since i have no idea where is it or where i can download it from, maybe i could download it using gradle... but what link sould I put in the dependecy? i still need a way to download the library.... Still, you are wright -L should do the trick if I had the library locally – zark0 May 09 '21 at 17:37
  • [KamilCuk](https://stackoverflow.com/users/9072753/kamilcuk), i heve already installed the mariadb connector/c and the mariadb connector/c++ but that's not what you mean right?, i tryed apt to install it, but apt could nof locate the package, probably beacause either its not the way you install it, or i do not have the repo inluded in my repo list, but either way I do not know where to even download it... – zark0 May 09 '21 at 17:43
  • @zark0 What kind of Debian based operating system are you using? Ubuntu? In that case try `$ sudo apt install libmariadb3 libmariadb-dev`. – 2b-t May 09 '21 at 18:08
  • @2b-t Thank you, but i already did it from the beggining, on my troubleshooting i went crazy thinking i din't do that, and runt the command at least 5 times XD, btw i also tried reinstaling those packages... BTW. yes, im using ubuntu server on a raspberry pi, but ill try to compile the code on either my windows machine or pop os machine, also i have wsl installled... if theres an easy way... thought that – zark0 May 10 '21 at 19:24
  • @zark0 Have you followed [these steps](https://mariadb.com/docs/clients/connector-cpp/#installing-mariadb-connector-c-via-binary-tarball-linux) as well? I have just tried it on my Ubuntu 18.04 computer. After that inside `usr/lib` there is a file `libmariadbcpp.so`. Is this file present on your system? – 2b-t May 10 '21 at 20:28
  • @2b-t i have, I link to that exact same page on the question post, and unfortunately i can't see the file libmariadbcpp.so, it appears to not be there, if you know how to get it or what failed for that file to not be there i'd apreciate it to get a comment about that... – zark0 May 11 '21 at 21:59
  • @2b-t nevermind found the issue, the guide is deprecated and a few directory names changed, so when installing some of the commands failed (i din't give it much importance because thought that it was because of the fact of me trying to rerun the command or something...) – zark0 May 11 '21 at 22:09

1 Answers1

0

When compiling whith gcc or g++ for the missing library. You have to make shure every install command works from the mariadb official guide, since the guide is deprecated and some folders and/or files have changed names, which will cause your install commands to fail.

In my case was the fact that the downloaded file contained lib64 instead of lib as the guide suggests, but keep in mind there may be more...

zark0
  • 101
  • 1
  • 6