链接错误:未定义对"avahi_alternative_service_name"的引用

Linking error : undefined reference to `avahi_alternative_service_name'

本文关键字:alternative service name 引用 avahi 错误 未定义 链接      更新时间:2023-10-16

知道我需要在库中找到这个符号。我正在尝试编译基于 avahi 的测试代码以查看服务。但我越来越undefined reference to avahi_alternative_service_name''。我不知道哪个库包含这个,我正在运行 UBUNTU 12.04。我尝试安装几个软件包,但没有成功。任何想法谢谢。。

我安装了以下软件包

dpkg --get-selections | grep avahi
avahi-autoipd                   install
avahi-daemon                    install
avahi-utils                     install
libavahi-cil-dev                install
libavahi-client-dev             install
libavahi-client3                install
libavahi-client3:i386           install
libavahi-common-data            install
libavahi-common-data:i386       install
libavahi-common-dev             install
libavahi-common3                install
libavahi-common3:i386           install
libavahi-core7                  install
libavahi-glib-dev               install
libavahi-glib1                  install
libavahi-gobject0               install
libavahi-ui-dev                 install
libavahi-ui-gtk3-0              install
libavahi-ui0                    install
libavahi1.0-cil                 install

命令
gcc -fpermissive testAvahi.c -o testAvahi

实际上需要找到库,然后需要将它们传递给链接器,所以 follwing 命令确实对我
有用

gcc -fpermissive testAvahi.c -o testAvahi -L/usr/lib/x86_64-linux-gnu/ -lavahi-client -lavahi-common

如果你有一个放置 C++ 库的公共文件夹,你可以使用 nm 命令检查搜索函数类似的东西

cd /usr/lib

nm -AC * | grep avahi_alternative_service_name

nm 实用程序在 binutils(sudo apt-get install binutils) 中可用