Compilation¶
Once an application has been written, it can be compiled and linked to NVPL RAND with a supported compiler.
NVPL RAND library installation consists of two directories, lib
and include
. The lib
directory contains
shared library libnvpl_rand.so
and libnvpl_rand_mt.so
. The include
directory contains nvpl_rand.h
.
An example given in the previous session can be compiled and dynamically linked with NVPL RAND MT library using the
following command, assuming the library installation path is nvpl_ROOT
.
# NVPL RAND
g++ -I${nvpl_ROOT}/include example.cpp -L${nvpl_ROOT}/lib -lnvpl_rand
# NVPL RAND MT
g++ -I${nvpl_ROOT}/include example_mt.cpp -L${nvpl_ROOT}/lib -lnvpl_rand_mt
CMake Usage¶
The NVPL package provides configuration files that simplify using NVPL RAND in CMake projects.
Ensure
nvpl_ROOT
is set to the install location. This may be an environment variable or passed to cmake during the configuration (see CMake: Config Mode Search Procedure).To find the NVPL package use:
find_package(nvpl REQUIRED COMPONENTS rand)
Link your target to NVPL RAND library:
# NVPL RAND
target_link_libraries(your_target PUBLIC nvpl::rand)
# or for NVPL RAND MT
target_link_libraries(your_target PUBLIC nvpl::rand_mt)