CMakeFiles/yolov5_tph_topic.dir/src/yolov5_tph/yolov5trt_tph.cpp.o: In function `cmp(Yolo::Detection const&, Yolo::Detection const&)': /home/nvidia/object_detection/src/detect/include/../tensorrtx_tph/yolov5-tph/common.hpp:56: multiple definition of `cmp(Yolo::Detection const&, Yolo::Detection const&)' CMakeFiles/yolov5_tph_topic.dir/src/yolov5_tph/yolov5_topic_tph.cpp.o:/home/nvidia/object_detection/src/detect/include/../tensorrtx_tph/yolov5-tph/common.hpp:56: first defined here
时间: 2023-07-31 07:04:57 浏览: 61
这个错误提示显示在两个不同的目标文件中都存在相同的函数定义。具体来说,函数 `cmp(Yolo::Detection const&, Yolo::Detection const&)` 在两个文件中都被定义了一次。这种情况会导致重复定义错误。
要解决这个问题,您可以采取以下几个步骤:
1. 确保只有一个文件中定义了 `cmp` 函数。您可以查看这两个文件 `yolov5trt_tph.cpp` 和 `yolov5_topic_tph.cpp`,然后删除其中一个文件中的函数定义。
2. 如果这两个文件中都需要使用 `cmp` 函数,那么您可以将其定义为 `static` 函数,这样它们将成为内部链接,不会导致重复定义错误。
```cpp
static cmp(Yolo::Detection const&, Yolo::Detection const&)
{
// 函数实现
}
```
3. 如果函数需要在多个文件之间共享,您可以将函数定义移到一个单独的源文件中,并在需要使用该函数的文件中引用它。
在一个新的源文件(例如 `common.cpp`)中定义函数:
```cpp
#include "common.hpp"
cmp(Yolo::Detection const&, Yolo::Detection const&)
{
// 函数实现
}
```
在需要使用该函数的文件中,包含头文件 `common.hpp`:
```cpp
#include "common.hpp"
// 使用 cmp 函数
```
希望这些步骤能帮助您解决问题。如果您需要更多帮助,请提供更多上下文或相关代码。