在 Solaris 网络库中进行 autoconf 链接的规范方法是什么?
在 Solaris 上,当编译使用套接字的程序时,需要使用 -lnsl -lsocket
链接它。许多此类程序最初是为 Linux 编写的(不需要额外的库),因此不在其配置脚本中检查这些库,即使这是一个相当简单的添加。像这样的东西(未经测试):
AC_SEARCH_LIBS(gethostbyname, nsl, , AC_MSG_ERROR([gethostbyname not found]))
AC_SEARCH_LIBS(connect, socket, , AC_MSG_ERROR([connect not found]))
有没有规范的方法来进行此检查?甚至可能包含在 autoconf 发行版中?你可能会想象这有相当广泛的需求,但谷歌不会告诉我。
On Solaris, when you compile a program that uses sockets, you need to link it with -lnsl -lsocket
. Many such programs were originally written for Linux (where no extra libraries are needed), and therefore do not check for these libraries in their configure scripts, even though that is a rather simple addition. Something like this (untested):
AC_SEARCH_LIBS(gethostbyname, nsl, , AC_MSG_ERROR([gethostbyname not found]))
AC_SEARCH_LIBS(connect, socket, , AC_MSG_ERROR([connect not found]))
Is there a canonical way to do this check? Maybe even included in the autoconf distribution? You would imagine that there is a rather widespread need for that, but Google wouldn't tell me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为最接近检查这一点的规范方法是<来自 Autoconf 存档 的代码>AX_LIB_SOCKET_NSL 宏:
i think the closest to a canonical way to check this is the
AX_LIB_SOCKET_NSL
macro from the Autoconf Archive:我记不起任何完成的代码,但您通常想检查是否可以先链接一个调用
gethostbyname()
函数的程序,而无需任何额外的库。仅当失败时,您才需要尝试nsl
库。类似的事情也适用于例如
m
库。I can't remember any finished code off the top of my head, but you usually want to check whether you can link a program calling the
gethostbyname()
function without any extra libs first. Only if that fails, you want to try thensl
library.Similar things apply e.g. for the
m
library.