0

I want to use this library in my c++/test.cpp file.

    #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
    }

I downloaded the source code from github and placed into the OMPEval folder. After make the ompeval.a library appeared.

Here is the folder structure:

enter image description here

Now I try to build it:

projects/c++$ g++ -Wall -g -L /home/a/projects/c++/OMPEval/lib/ -l ompeval -I /home/a/projects/c++/OMPEval/  test.cpp  -v

but the linker has error:

/usr/bin/ld: cannot find -lompeval collect2: error: ld returned 1 exit status

Here is the whole build log:

Paolo
  • 117
  • 8
  • Can you try `-lompeval`, that is, no spaces between `l` and the library name? – rturrado May 08 '21 at 15:30
  • Same result, it is just syntax difference. Interestingly it works if I first compile it and for linking I use the absolute path to the static library. – Paolo May 08 '21 at 15:38
  • Hm... Other things I would check with your original command: 1) remove the space after `-L`, and/or 2) copy `c++` to `cpp`. I think Linux handles correctly these paths with characters like `+` so you don't have to escape them, but... (although if that were the problem the solution you mention just wouldn't work either) – rturrado May 08 '21 at 15:51
  • I think I know now what the problem is. Usually, library names start with `lib`. When you write commands like `-l ompeval`, the library name that is searched for is `libompeval` (.so, or .a). It may just work fine if you just change your command to `g++ -Wall -g lib/ompeval.a -I /home/a/projects/c++/OMPEval/ test.cpp -v`. See this other question: https://stackoverflow.com/a/39182948/260313 – rturrado May 08 '21 at 16:55
  • Or, as it says in that other response, you could also keep your command as it is and create a symbolic link `libompeval.a` to your `ompeval.a` (with `ln -s ompeval.a libompeval.a`) – rturrado May 08 '21 at 17:01

0 Answers0