I have been looking at this problem for a few days now and cannot seem to find the answer in any online forums/ document.
This is what I’m doing: I have a RPi 3B connected via USB to a RPi Pico (actually it’s not connected yet but that’s irrelevant, I’m just building the binaries for now). I SSH with my computer to the 3B, and have all of the project stored in that device.
I’m using cmake to compile and run everything. After typing cmake ..
, I then type sudo make VERBOSE=1
Overview of file structure:
<code>PovGlobe
|--depes
|--build
|--cpp_src
|--...
</code>
PovGlobe
|--depes
|--build
|--cpp_src
|--...
Here is a snapshot of the CMakeLists.txt in the PovGlobe (parent) directory:
CMakeLists.text:
<code>cmake_minimum_required(VERSION 3.10)
set(PICO_SDK_FETCH_FROM_GIT on)
set(PICO_SDK_PATH "/home/nicoc/PovGlobe/depes/pico-sdk")
include(/home/nicoc/PovGlobe/depes/pico-sdk/pico_sdk_init.cmake)
set(PICO_SDK_FETCH_FROM_GIT on)
set(PYTHON_LIBRARIES "/usr/lib/aarch64-linux-gnu/libpython3.11.so")
set(PYTHON_INCLUDE_DIRS "/usr/include/python3.11")
set(CORE_LIB_NAME ${CMAKE_PROJECT_NAME}_core_lib)
set(HW_LIB_EXT_NAME ${CMAKE_PROJECT_NAME}_hw_lib_ext)
set(SIM_LIB_EXT_NAME ${CMAKE_PROJECT_NAME}_sim_lib_ext)
set(APPS_LIB_NAME ${CMAKE_PROJECT_NAME}_apps_lib)
set(PY_WRAPPER_LIB_NAME Py${CMAKE_PROJECT_NAME})
set(EXEC_MAIN_NAME ${CMAKE_PROJECT_NAME})
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
<code>cmake_minimum_required(VERSION 3.10)
set(PICO_SDK_FETCH_FROM_GIT on)
set(PICO_SDK_PATH "/home/nicoc/PovGlobe/depes/pico-sdk")
include(/home/nicoc/PovGlobe/depes/pico-sdk/pico_sdk_init.cmake)
project(PovGlobe)
set(EXT_DIR ./ext)
set(PICO_SDK_FETCH_FROM_GIT on)
set(PYTHON_LIBRARIES "/usr/lib/aarch64-linux-gnu/libpython3.11.so")
set(PYTHON_INCLUDE_DIRS "/usr/include/python3.11")
pico_sdk_init()
set(CORE_LIB_NAME ${CMAKE_PROJECT_NAME}_core_lib)
set(HW_LIB_EXT_NAME ${CMAKE_PROJECT_NAME}_hw_lib_ext)
set(SIM_LIB_EXT_NAME ${CMAKE_PROJECT_NAME}_sim_lib_ext)
set(APPS_LIB_NAME ${CMAKE_PROJECT_NAME}_apps_lib)
set(PY_WRAPPER_LIB_NAME Py${CMAKE_PROJECT_NAME})
set(EXEC_MAIN_NAME ${CMAKE_PROJECT_NAME})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
...
</code>
cmake_minimum_required(VERSION 3.10)
set(PICO_SDK_FETCH_FROM_GIT on)
set(PICO_SDK_PATH "/home/nicoc/PovGlobe/depes/pico-sdk")
include(/home/nicoc/PovGlobe/depes/pico-sdk/pico_sdk_init.cmake)
project(PovGlobe)
set(EXT_DIR ./ext)
set(PICO_SDK_FETCH_FROM_GIT on)
set(PYTHON_LIBRARIES "/usr/lib/aarch64-linux-gnu/libpython3.11.so")
set(PYTHON_INCLUDE_DIRS "/usr/include/python3.11")
pico_sdk_init()
set(CORE_LIB_NAME ${CMAKE_PROJECT_NAME}_core_lib)
set(HW_LIB_EXT_NAME ${CMAKE_PROJECT_NAME}_hw_lib_ext)
set(SIM_LIB_EXT_NAME ${CMAKE_PROJECT_NAME}_sim_lib_ext)
set(APPS_LIB_NAME ${CMAKE_PROJECT_NAME}_apps_lib)
set(PY_WRAPPER_LIB_NAME Py${CMAKE_PROJECT_NAME})
set(EXEC_MAIN_NAME ${CMAKE_PROJECT_NAME})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
...
(I excluded extra lines i think were not relevant)
After running the sudo make VERBOSE=1
, the compilator starts but ends with this error (mentions the error two times actually as I use mutex two times):
Console out:
<code>[ 50%] Building CXX object cpp_src/PovGlobe/sim/CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj
cd /home/nicoc/PovGlobe/build/cpp_src/PovGlobe/sim && /usr/bin/arm-none-eabi-g++ -DSIM_AVAILABLE -Wall -Wextra -O3 -std=gnu++14 -MD -MT cpp_src/PovGlobe/sim/CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj -MF CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj.d -o CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj -c /home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/renderer_sim.cpp
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:9:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
8 | #include "helper.hpp"
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:69:10: error: 'mutex' in namespace 'std' does not name a type
69 | std::mutex m_double_buffer_mutex;
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:69:5: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
69 | std::mutex m_double_buffer_mutex;
<code>[ 50%] Building CXX object cpp_src/PovGlobe/sim/CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj
cd /home/nicoc/PovGlobe/build/cpp_src/PovGlobe/sim && /usr/bin/arm-none-eabi-g++ -DSIM_AVAILABLE -Wall -Wextra -O3 -std=gnu++14 -MD -MT cpp_src/PovGlobe/sim/CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj -MF CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj.d -o CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj -c /home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/renderer_sim.cpp
(skipping warnings)
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:9:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
8 | #include "helper.hpp"
+++ |+#include <mutex>
9 | #include <mutex>
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:69:10: error: 'mutex' in namespace 'std' does not name a type
69 | std::mutex m_double_buffer_mutex;
| ^~~~~
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:69:5: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
69 | std::mutex m_double_buffer_mutex;
| ^~~
</code>
[ 50%] Building CXX object cpp_src/PovGlobe/sim/CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj
cd /home/nicoc/PovGlobe/build/cpp_src/PovGlobe/sim && /usr/bin/arm-none-eabi-g++ -DSIM_AVAILABLE -Wall -Wextra -O3 -std=gnu++14 -MD -MT cpp_src/PovGlobe/sim/CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj -MF CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj.d -o CMakeFiles/PovGlobe_sim_lib_ext.dir/renderer_sim.cpp.obj -c /home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/renderer_sim.cpp
(skipping warnings)
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:9:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
8 | #include "helper.hpp"
+++ |+#include <mutex>
9 | #include <mutex>
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:69:10: error: 'mutex' in namespace 'std' does not name a type
69 | std::mutex m_double_buffer_mutex;
| ^~~~~
/home/nicoc/PovGlobe/cpp_src/PovGlobe/sim/../core/globe.hpp:69:5: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
69 | std::mutex m_double_buffer_mutex;
| ^~~
You can even see during the traceback that mutex is already included (and even then it suggests including it again)
There are two hpp files that use sdt::mutex and both of them throw the error in almost the extact same way.
Is there a problem with my compiler? Should i add another library to the CMake file?
Thanks a lot everyone.
I investigated some time but I was not able to find any information regarding the subject.