gpt4 book ai didi

c++ - 编译libfluid示例 Controller 时未定义对 'event_base_del_virtual'的引用

转载 作者:行者123 更新时间:2023-12-02 10:39:15 24 4
gpt4 key购买 nike

我正在尝试使用libfluid来编码我自己的OpenFlow Controller 。但是首先,我想构建sample controller以了解其工作原理。
编译样本 Controller 时出现以下错误:(这是我尝试make msg_controller时遇到的错误)

c++ msg/MsgController.cc -lfluid_msg -lfluid_base -I. -O3 -std=c++0x -o msg_controller
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libfluid_base.so: undefined reference to `event_base_del_virtual'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libfluid_base.so: undefined reference to `event_base_add_virtual'
collect2: error: ld returned 1 exit status
Makefile:10: recipe for target 'msg_controller' failed
make: *** [msg_controller] Error 1

在构建样本 Controller 之前,我遵循 steps来构建 libfluid_baselibfluid_msg。构建这两个库时,出现以下提示,我认为这可能有助于解决我的问题

If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the '-LLIBDIR' flag during linking and do at least one of the following:

  • add LIBDIR to the 'LD_LIBRARY_PATH' environment variable during execution
  • add LIBDIR to the 'LD_RUN_PATH' environment variable during linking
  • use the '-Wl,-rpath -Wl,LIBDIR' linker flag
  • have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages.



库未正确链接,是否存在 undefined 的引用错误?
我需要对c++命令进行一些更改吗?

我尝试了命令 grep -rn "event_base_del" /usr/libgrep -rn "event_base_add" /usr/lib event_base_del的输出如下( event_base_add相同)
Binary file /usr/lib/libfluid_base.a matches
Binary file /usr/lib/libfluid_base.so.0.0.0 matches
Binary file /usr/lib/x86_64-linux-gnu/libevent.a matches
Binary file /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6.0.2 matches
Binary file /usr/lib/x86_64-linux-gnu/libevent_core.a matches
Binary file /usr/lib/x86_64-linux-gnu/libevent_core-2.1.so.6.0.2 matches

这是否意味着链接正确?因为 libfluid_base.so只是 libfluid_base.so.0.0.0的链接
lrwxrwxrwx  1 root root       22 Oct  8 09:36 libfluid_base.so -> libfluid_base.so.0.0.0

那么我该如何解决呢?

在尝试使用-levent_core或-levnet使示例代码链接到libevent之后。该错误继续存在,可能是因为我现在使用的libevent版本与当前版本的libfluid不兼容。通过我使用Ubuntu18.04的方式。

我将尝试使用旧版本的libevent在ubuntu16.04上构建它,以查看它是否有效。

最佳答案

event_base_del_virtual来自libevent library。将其与-levent_core链接。

关于c++ - 编译libfluid示例 Controller 时未定义对 'event_base_del_virtual'的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52704269/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com