/workspace/ai_server/include/spdlog/fmt/bundled/core.h:1728: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt 1728 | formattable, | ^~~~~~~~~~~
时间: 2023-08-18 11:08:08 浏览: 229
这是一个编译错误,具体来说,它表示在使用 fmt 库格式化输出时,有一个类型无法被格式化。为了解决这个问题,你需要为这个类型提供一个自定义的格式化器。具体的做法是,根据编译器给出的错误提示,访问 https://fmt.dev/latest/api.html#udt,学习如何为自定义类型提供格式化器,并按照提示实现一个格式化器。然后将这个格式化器添加到你的代码中,重新编译即可。
相关问题
ubuntu16.04ros编译时报错home/bobac3/ros_workspace/src/multipoint_navigation/src/multipoint_nav.cpp:20:17: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 int cycle = 1; //巡航次数 ^ /home/bobac3/ros_workspace/src/multipoint_navigation/src/multipoint_nav.cpp: In member function ‘void Multipoint_Nav::move()’: /home/bobac3/ros_workspace/src/multipoint_navigation/src/multipoint_nav.cpp:90:26: error: ‘goal’ does not name a type for(auto goal:pose) //遍历导航点列表 ^ In file included from /opt/ros/kinetic/include/ros/ros.h:40:0, from /opt/ros/kinetic/include/actionlib/client/simple_action_client.h:45, from /home/bobac3/ros_workspace/src/multipoint_navigation/src/multipoint_nav.cpp:1: /opt/ros/kinetic/include/ros/console.h:373:3: error: expected ‘;’ before ‘do’ do \ ^ /opt/ros/kinetic/include/ros/console.h:561:35: note: in expansion of macro ‘ROS_LOG_COND’ #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__) ^ /opt/ros/kinetic/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’ #define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_ ^ /home/bobac3/ros_workspace/src/multipoint_navigation/src/multipoint_nav.cpp:152:17: note: in expansion of macro ‘ROS_INFO’ ROS_INFO("------------------loop ( %d ) termination!----------- ^ /opt/ros/kinetic/include/ros/console.h:373:3: error: expected primary-expression before ‘do’ do \ ^ /opt/ros/kinetic/include/ros/console.h:561:35: note: in expansion of macro ‘ROS_LOG_COND’ #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS__) ^ /opt/ros/kinetic/include/rosconsole/macros_generated.h:110:23: note: in expansion of macro ‘ROS_LOG’ #define ROS_INFO(...) ROS_LOG(::ros::console::levels::Info, ROSCONSOLE_DEFAULT_
这个错误的原因是代码中使用了 C++11 的特性,但是编译时没有开启 C++11 标准。你需要在编译时加上选项 -std=c++11 或者 -std=gnu++11 来开启 C++11 标准。
具体来说,在你的 CMakeLists.txt 文件中添加以下行:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
这将会把 C++11 标准的编译选项加入到编译命令中,从而解决这个问题。
另外,还有一个错误是 'goal' does not name a type,这可能是因为你没有在代码中定义 goal 变量的类型。你需要检查一下代码中是否有定义 goal 变量的类型,并且确保它在使用之前已经被定义。
[ 3%] Generating dynamic reconfigure files from cfg/Params_PID.cfg: /home/ubuntu/new_workspace/devel/include/simple_follower/Params_PIDConfig.h /home/ubuntu/new_workspace/devel/lib/python2.7/dist-packages/simple_follower/cfg/Params_PIDConfig.py Generating reconfiguration files for Params_PID in simple_follower Wrote header file in /home/ubuntu/new_workspace/devel/include/simple_follower/Params_PIDConfig.h In file included from /home/ubuntu/new_workspace/src/lsx10/lslidar_x10_driver/src/input.cc:18:0: /home/ubuntu/new_workspace/src/lsx10/lslidar_x10_driver/include/lslidar_x10_driver/input.h:35:10: fatal error: lslidar_x10_msgs/LslidarX10Packet.h: No such file or directory #include <lslidar_x10_msgs/LslidarX10Packet.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. lsx10/lslidar_x10_driver/CMakeFiles/lslidar_input_x10.dir/build.make:62: recipe for target 'lsx10/lslidar_x10_driver/CMakeFiles/lslidar_input_x10.dir/src/input.cc.o' failed make[2]: *** [lsx10/lslidar_x10_driver/CMakeFiles/lslidar_input_x10.dir/src/input.cc.o] Error 1 CMakeFiles/Makefile2:10548: recipe for target 'lsx10/lslidar_x10_driver/CMakeFiles/lslidar_input_x10.dir/all' failed make[1]: *** [lsx10/lslidar_x10_driver/CMakeFiles/lslidar_input_x10.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... Generating reconfiguration files for params in rplidar_ros Wrote header file in /home/ubuntu/new_workspace/devel/include/rplidar_ros/paramsConfig.h [ 3%] Built target simple_follower_gencfg [ 3%] Built target rplidar_ros_gencfg [ 3%] Linking CXX executable /home/ubuntu/new_workspace/devel/lib/rplidar_ros/rplidarNodeClient [ 3%] Built target rplidarNodeClient Makefile:140: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j4 -l4" failed
这段编译日志也出现了编译错误,错误提示为 "fatal error: lslidar_x10_msgs/LslidarX10Packet.h: No such file or directory"。这个错误提示表明编译器找不到 LslidarX10Packet.h 头文件。这有可能是因为 LslidarX10Packet.h 头文件没有正确包含进来或者路径设置有误导致的。
要解决这个问题,需要检查代码中是否正确包含了 LslidarX10Packet.h 头文件,并且路径是否正确。如果 LslidarX10Packet.h 头文件确实没有包含进来,可以在代码中添加包含语句,例如:
```
#include "lslidar_x10_msgs/LslidarX10Packet.h"
```
另外,也需要确保 LslidarX10Packet.h 头文件所在的路径已经正确设置。可以在 CMakeLists.txt 文件中添加如下的语句:
```
include_directories(${catkin_INCLUDE_DIRS})
```
其中 ${catkin_INCLUDE_DIRS} 是 ROS 中自动设置的包含路径,可以确保头文件能够被正确找到。如果还是编译失败,可以尝试在命令行中使用 "roscd lslidar_x10_msgs" 命令进入到 lslidar_x10_msgs 包所在的路径,然后使用 "pwd" 命令获取当前路径,并将其添加到 CMakeLists.txt 文件中的 include_directories() 函数中。这样,重新编译代码应该就能够成功了。
阅读全文