I have installed on MacOSX 10.15
boost using brew, all working fine, beside random_device.
This is what i have written:
#include <iostream>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp>
#include <boost/random/random_device.hpp>
int main() {
boost::random::random_device rand_dev;
boost::mt19937 gen(rand_dev());
double probabilities[]{0, 0.99, 0.01, 0};
boost::random::discrete_distribution<> dist(probabilities);
std::cout << dist(gen);
return 0;
}
And this is what i have got from compiler:
Undefined symbols for architecture x86_64:
"boost::random::random_device::random_device()", referenced from: _main in main.cpp.o
"boost::random::random_device::~random_device()", referenced from: _main in main.cpp.o
"boost::random::random_device::operator()()", referenced from: _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am linking it using CMake. And also i have installed it on the Ubuntu 18
and got same linking errors.
This is a part of my CMake:
find_package(Boost 1.72)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(test_boost ${Boost_LIBRARY_DIR})
endif()
Ubuntu 18
and got same linking errors. This is a part of my CMake:find_package(Boost 1.72) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) target_link_libraries(test_boost ${Boost_LIBRARY_DIR}) endif()
– dikiidog