【问题标题】:Pcap functions undefined reference [closed]Pcap函数未定义参考[关闭]
【发布时间】:2021-04-29 00:33:57
【问题描述】:

我正在尝试将 pcap 函数添加到我在 Linux 上的 Clion 中的 C++ 项目中。

我的 h 文件包含:

#include <pcap/pcap.h> 

CMAKE 文件也更新了。

而不是使用下一个命令:

if (NOT MSVC)
    target_link_libraries(${TARGET} pthread)
endif()

现在是:

if (NOT MSVC)
    target_link_libraries(${TARGET} pthread pcap)
endif()

仍然出现下一个错误:

undefined reference to "pcap_open_dead"
undefined reference to "pcap_dump_open"
undefined reference to "pcap_dump_close"
undefined reference to "pcap_close"

有人知道怎么解决吗?

谢谢

【问题讨论】:

  • 你能在VERBOSE模式下编译并显示你得到的输出吗?
  • 请告诉我们 pcap 库的实际位置...

标签: c++ cmake clion pcap undefined-reference


【解决方案1】:

感谢您的帮助!

使用 VERBOSE 标志后,我能够看到问题。

我在另一个 CMAKE 文件中添加了 pcap 标志,现在它可以工作了 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-02
    • 2018-10-18
    • 2014-07-25
    • 2012-05-22
    • 2018-03-02
    • 2022-01-11
    • 1970-01-01
    相关资源
    最近更新 更多