After installing Boost via HomeBrew and writing the following code :
#include "Common.hpp"
/* ----- B00ST ----- */
#include <boost/random/random_device.hpp>
#include <boost/random/uniform_int_distribution.hpp>
void Common::generate_random_password(std::string* password, int length) {
/*
* INPUTS :
* Pointer to store the generated password
*
* OUTPUTS :
* None
*
* RAISES :
* None
*/
std::string chars(
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"1234567890"
"!@#$%^&*()"
"`~-_=+[{]}\\|;:'\",<.>/? ");
boost::random::random_device rng;
boost::random::uniform_int_distribution<> index_dist(0, chars.size() - 1);
for (int i = 0; i < length; ++i)
password->append(&chars[index_dist(rng)]);
} // generate_random_password(const std::string* password)
CLion's coming up with this error :
Undefined symbols for architecture arm64:
"boost::random::random_device::random_device()", referenced from:
Common::generate_random_password(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, int) in Common.cpp.o
"boost::random::random_device::~random_device()", referenced from:
Common::generate_random_password(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, int) in Common.cpp.o
"boost::random::random_device::operator()()", referenced from:
int boost::random::detail::generate_uniform_int<boost::random::random_device, int>(boost::random::random_device&, int, int, boost::integral_constant<bool, true>) in Common.cpp.o
unsigned int boost::random::detail::generate_uniform_int<boost::random::random_device, unsigned int>(boost::random::random_device&, unsigned int, unsigned int, boost::integral_constant<bool, true>) in Common.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
I've tried to reinstall Boost, double checked my CMake file but I see nothing wrong with my actual building configuration...
In case, here's my CMakeLists.txt file :
cmake_minimum_required(VERSION 3.23)
project(Banko)
set(CMAKE_CXX_STANDARD 23)
add_executable(Banko main.cpp Common.cpp Common.hpp)
find_package(Boost 1.80.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(Banko ${Boost_LIBRARIES})
Thanks for your time !
Unguest