Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to propery install a third party library from github for a c++ project?

I want to use this library https://github.com/zekyll/OMPEval in my c++ project. I know I must clone the repo and then use make to compile the files. However, I don't know which directory to place it in order for it to function how the author demonstrated. The authors example:

#include <omp/HandEvaluator.h>
#include <iostream>
using namespace omp;
int main()
{
    HandEvaluator eval;
    Hand h = Hand::empty(); // Final hand must include empty() exactly once!
    h += Hand(51) + Hand(48) + Hand(0) + Hand(1) + Hand(2); // AdAs2s2h2c
    std::cout << eval.evaluate(h) << std::endl; // 28684 = 7 * 4096 + 12
}

How can I use the library as demonstrated?

like image 880
RoyGBivJr Avatar asked Nov 30 '25 02:11

RoyGBivJr


1 Answers

That's going to depend on how you compile your project, if you use Visual Studio, then you can simply add the .lib files to the linker settings in the project settings, and add the include directory to your additional include directories

If you use GCC/Clang or another compiler directly, you'll have to explicitly pass the arguments to the compiler,

clang++ main.cpp -I./path/to/include -llibrary_file

You can set the path to library files using -L./....

Since your question is marked ubuntu, you can usually install libraries through apt but it doesn't seem like OMPEval has an apt repository.

EDIT: Please note the ./ in both the -L and -I flag are RELATIVE paths, remove the . and you have an absolute path

like image 193
JohnkaS Avatar answered Dec 02 '25 16:12

JohnkaS