Undefined symbols for architecture x86_64 with OS Monterey

  c++, clang, macos-monterey

I just reinstall my system from OS HighSierra to OS Monterey and restart my system from scratch. I reinstall XCode to from AppleStore, But after that when I try to compile C++ and there is class in the code ; the compiler don’t have access to the function of class himself and the console return message like

Undefined symbols for architecture x86_64:
  "random_double(double, double, std::__1::linear_congruential_engine<unsigned int, 48271u, 0u, 2147483647u>&)", referenced from:
      vec2<double>::rand(double const&, double const&, double const&, double const&, std::__1::linear_congruential_engine<unsigned int, 48271u, 0u, 2147483647u>&) in test_random-9ab46f.o
  "random(float, float, std::__1::linear_congruential_engine<unsigned int, 48271u, 0u, 2147483647u>&)", referenced from:
      vec2<float>::rand(float const&, float const&, float const&, float const&, std::__1::linear_congruential_engine<unsigned int, 48271u, 0u, 2147483647u>&) in test_random-9ab46f.o
      vec3<float>::rand(float const&, float const&, float const&, float const&, float const&, float const&, std::__1::linear_congruential_engine<unsigned int, 48271u, 0u, 2147483647u>&) in test_random-9ab46f.o
      vec4<float>::rand(float const&, float const&, float const&, float const&, float const&, float const&, float const&, float const&, std::__1::linear_congruential_engine<unsigned int, 48271u, 0u, 2147483647u>&) in test_random-9ab46f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

for information, my script is

path_test="../test/"
path="../rope/"
path_template="../rope/template/"
path_class="../rope/class/"
path_function="../rope/function/"
clang++ -std=c++11 
${path_test}main.cpp 
${path}*.cpp ${path}*.hpp 
${path_template}utils/*.hpp 
&& ./a.out 100 10 
&& rm ${path}*.gch ${path_template}utils/*.gch

I’m not sure the C++ code is important but in case the code can be available here : https://github.com/StanLepunK/Rope_cpp/tree/master/rope

Source: Windows Questions C++

LEAVE A COMMENT