在编译Fast_DDS : colcon build --packages-up-to fastdds
的时候,可能会出现与asio
库相关的错误,二进制安装或者源代码安装的参考链接见下:
https://blog.csdn.net/u012327735/article/details/124251305
https://blog.csdn.net/SMILY12138/article/details/130348448
此时可能还会有某些错误,如:
leg_ctrl@legctrl-NUC12WSHi7:~/Fast-DDS$ colcon build --packages-up-to fastdds
Starting >>> fastcdr
Starting >>> foonathan_memory_vendor
Finished <<< fastcdr [0.04s]
[Processing: foonathan_memory_vendor]
--- stderr: foonathan_memory_vendor
Cloning into 'foo_mem-ext'...
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Cloning into 'foo_mem-ext'...
HEAD is now at 0f07757 Release 0.7-3
---
Finished <<< foonathan_memory_vendor [52.0s]
Starting >>> fastdds
--- stderr: fastdds
In file included from /home/leg_ctrl/Fast-DDS/src/fastdds/src/cpp/fastdds/domain/DomainParticipantImpl.cpp:25:
/usr/local/include/asio.hpp:62:10: fatal error: asio/cancel_after.hpp: No such file or directory
62 | #include "asio/cancel_after.hpp"
| ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [src/cpp/CMakeFiles/fastdds.dir/build.make:440: src/cpp/CMakeFiles/fastdds.dir/fastdds/domain/DomainParticipantImpl.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:976: src/cpp/CMakeFiles/fastdds.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
---
Failed <<< fastdds [7.61s, exited with code 2]
Summary: 2 packages finished [59.7s]
1 package failed: fastdds
2 packages had stderr output: fastdds foonathan_memory_vendor
问题是由于 asio/cancel_after.hpp
文件无法找到导致的。
首先,确认 Asio
已正确安装。你可以通过查看 Asio
的安装路径来确认:
ls /usr/local/include/asio
如果你能看到 cancel_after.hpp
文件,说明 Asio
已正确安装。
如果此路径下没有cancel_after.hpp
文件,可以在系统中搜索这个文件,找到后复制到 /usr/local/include/asio
下。
重新编译,上述问题能够解决,但可能会出现新的文件找不到的情况,解决方法同上。