How to correctly use class in external header files with C++ in Visual studio 2019?

Viewed 17

I referenced the header file where the class is located and put its location in the additional include Directories, but it still reports an error LNK2019, I don't know what I did wrong? I've tried multiple methods of this, but none of them seem to work. Any ideas? The code is as follows and the head files are attached. Thanks in advance.[enter image description here][1] The header files are in the trng folder in this link https://github.com/rabauke/trng4

#include <cstdlib>
#include <iostream>
#include <omp.h>
#include <trng/yarn2.hpp>
#include <trng/uniform01_dist.hpp>

int main() {
    const long samples = 1000000l;          // total number of points in square
    long in = 0l;                           // no points in circle
    // distribute workload over all processes and make a global reduction 
#pragma omp parallel reduction(+:in)
    {
        trng::yarn2 rx, ry;                 // random number engines for x- and y-coordinates
        int size = omp_get_num_threads();     // get total number of processes
        int rank = omp_get_thread_num();      // get rank of current process
        // split PRN sequences by leapfrog method
        rx.split(2, 0);                     // choose sub-stream no. 0 out of 2 streams
        ry.split(2, 1);                     // choose sub-stream no. 1 out of 2 streams
        rx.split(size, rank);               // choose sub-stream no. rank out of size streams
        ry.split(size, rank);               // choose sub-stream no. rank out of size streams
        trng::uniform01_dist<> u;           // random number distribution
        // throw random points into square 
        for (long i = rank; i < samples; i += size) {
            double x = u(rx), y = u(ry);          // choose random x- and y-coordinates
            if (x * x + y * y <= 1.0)                 // is point in circle?
                ++in;                           // increase thread-local counter
        }
    }
    // print result
    std::cout << "pi = " << 4.0 * in / samples << std::endl;
    return EXIT_SUCCESS;
}



  [1]: https://i.stack.imgur.com/eTKlU.png


0 Answers
Related