Trying to build the workspace CMake fails to build OpenCV and I see the following errors (and many more of the same kind):
/usr/bin/ld: /usr/include/c++/11/bits/basic_string.tcc:212: undefined reference to `std::__throw_logic_error(char const*)'
/usr/include/c++/11/ext/new_allocator.h:145: undefined reference to `operator delete(void*, unsigned long)'
/usr/include/c++/11/bits/basic_ios.h:462: undefined reference to `std::ios_base::ios_base()'
Checking Bazel's build log I noticed that in the CMake configuration both the C and the C++ compiler point to /usr/bin/gcc and I tried to change that by not relying on the default CMake configuration but by directly setting the C++ compiler to use g++. While setting the CMAKE_CXX_STANDARD changed the CMake output from 11 to 17 setting CMAKE_CXX_COMPILER does not change the CMake configuration at all.
I was able to reproduce this issue building OpenCV only using CMake without Bazel and setting the CMAKE_CXX_COMPILER to gcc.
I am trying to build OpenCV on a Ubuntu 22.04 machine running Bazel 6.1.1. My workspace is setup as follows:
WORKSPACE:
opencv.BUILD:
Trying to build the workspace CMake fails to build OpenCV and I see the following errors (and many more of the same kind):
Checking Bazel's build log I noticed that in the CMake configuration both the C and the C++ compiler point to
/usr/bin/gcc
and I tried to change that by not relying on the default CMake configuration but by directly setting the C++ compiler to useg++
. While setting theCMAKE_CXX_STANDARD
changed the CMake output from11
to17
settingCMAKE_CXX_COMPILER
does not change the CMake configuration at all.I was able to reproduce this issue building OpenCV only using CMake without Bazel and setting the
CMAKE_CXX_COMPILER
togcc
.