在 Raspberry Pi 4 上构建 OSDK 时,类型 `std::string' 不完整

问题描述 投票:0回答:1

我正在尝试在 Raspberry Pi 4 上构建 DJI Onboard-SDK,并且遇到了缺少不同库的错误,我已通过安装这些库设法解决了这些错误。我现在收到一条错误消息,指出 std::string 是不完整类型并且 printf 未声明。我发现的唯一建议是安装 build-essentials,我已经安装了它并且是最新的。有人能给我下一步该去哪里看的建议吗?

我尝试重新安装 g++ 并确保所有软件包都是最新的。我的 make 输出中仍然出现以下错误;


[ 26%] Building CXX object osdk-core/CMakeFiles/djiosdk-core.dir/modules/src/filemgr/impl/mmap_file_buffer.cpp.o
In file included from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:4:
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/inc/filemgr/impl/mmap_file_buffer.hpp:23:15: error: field ‘currentLogFilePath’ has incomplete type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
   23 |   std::string currentLogFilePath;
      |               ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/memory:74,
                 from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/inc/filemgr/impl/mmap_file_buffer.hpp:13,
                 from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:4:
/usr/include/c++/10/bits/stringfwd.h:74:11: note: declaration of ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’}
   74 |     class basic_string;
      |           ^~~~~~~~~~~~
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:15:39: error: ‘path’ has incomplete type
   15 | bool MmapFileBuffer::init(std::string path, uint64_t fileSize) {
      |                           ~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/memory:74,
                 from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/inc/filemgr/impl/mmap_file_buffer.hpp:13,
                 from /home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:4:
/usr/include/c++/10/bits/stringfwd.h:74:11: note: declaration of ‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’}
   74 |     class basic_string;
      |           ^~~~~~~~~~~~
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp: In member function ‘bool DJI::OSDK::MmapFileBuffer::init(std::string, uint64_t)’:
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:19:3: error: ‘printf’ was not declared in this scope
   19 |   printf("Preparing File : %s\n", this->currentLogFilePath.c_str());
      |   ^~~~~~
/home/pi/catkin_ws/src/Onboard-SDK/osdk-core/modules/src/filemgr/impl/mmap_file_buffer.cpp:7:1: note: ‘printf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
    6 | #include <string.h>
  +++ |+#include <cstdio>
    7 |
make[2]: *** [osdk-core/CMakeFiles/djiosdk-core.dir/build.make:524: osdk-core/CMakeFiles/djiosdk-core.dir/modules/src/filemgr/impl/mmap_file_buffer.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:580: osdk-core/CMakeFiles/djiosdk-core.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
cmake raspberry-pi dji-sdk
1个回答
0
投票

检查错误所在的源文件mmap_file_buffer.cpp,看看是否包含了字符串头文件?

#包括

如果没有,则将其添加到包含 mmap_file_buffer.hpp 的第 4 行之前,因为这是定义变量且未找到 std::string 的地方。

© www.soinside.com 2019 - 2024. All rights reserved.