2

There is a question about this already, but the asker was either doing some more complicated then me, or the posted answer assumed too much background knowledge for me to understand.

I am trying to use the following library: https://github.com/samehkamaleldin/socket.cpp .

I downloaded the library from github and built it. I then placed the resulting .so file in the same directory as main.cpp, like this:

Screenshot

However, I'm not sure what to do from here, from my research, I need to use the command target_link_libraries, but I'm not sure what to pass in for each parameter.

Foobar
  • 7,458
  • 16
  • 81
  • 161
  • Not sure what CLion uses for it's working directory when executing code, but it is probably not the same directory as the source code. The location of a library with respect to the executable requiring it, or any other file-based resource for that matter, can get annoying as the program may be run from anywhere, leaving the executable unable to find the resource unless you have nailed down where the executable needs to look or added the resource to the path. Search term: Working Directory. – user4581301 Aug 09 '18 at 17:37
  • `add_target_library(target_name, library_name)` I would paste the names, but you posted an image instead of text. – stark Aug 09 '18 at 17:41
  • @stark. I assume your solution requires me to install the library in my system somehow. Does that just involve moving the `.so` file to the current directory. – Foobar Aug 09 '18 at 19:43
  • Libraries do not have to be installed to build a C++ project with cmake. You do need the devel information (header files), so you may also need to add include directories for the libraries. – stark Aug 09 '18 at 19:48
  • The github link contains the full source of the library - so I do have access to the `.hpp` files, I'm not quite sure what to do with them though. – Foobar Aug 09 '18 at 19:56

1 Answers1

1

In order to use the library, there are few approaches, I suggest you read this post: Correct way to use third-party libraries in cmake project

J-Christophe
  • 1,975
  • 15
  • 13