LDADD和LIBADD有什么区别? [英] What is the difference between LDADD and LIBADD?

查看:968
本文介绍了LDADD和LIBADD有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个混合使用libtool库和可执行文件的自动制作项目,而我很难查找自动制作文档,尤其是.与告诉编译器进行链接有关.

I'm trying to setup an automake project that uses a mix of libtool libraries and exectuables, and I'm having a hard time grokking the automake documentation, esp. as relates to telling the compiler to link against.

那么有人可以解释LDADDLIBADD之间的区别吗?

So can someone explain the differences between LDADD and LIBADD?

类似的东西

  • 什么时候被另一个使用了
  • 采用-lname_of_library样式值与直接文件名的情况, 等
  • when is one used over the other,
  • which one takes -lname_of_library style values vs. direct filenames, etc.

每当我尝试阅读相关文档时,似乎都假定我知道我不知道的东西.

Whenever I try to read the relevant documentation, it seems like it assumes that I know things that I don't.

推荐答案

对库使用LIBADD主库,对可执行文件使用LDADD.如果要构建依赖于另一个库libbar.la的libtool库libfoo.la,则可以使用:

Use the LIBADD primary for libraries, and LDADD for executables. If you were building a libtool library libfoo.la, that depended on another library libbar.la, you would use:

libfoo_la_LIBADD = libbar.la

如果您还有其他非libtool库,也可以使用-L-l选项添加它们:

If you had other non-libtool libraries, you would also add these with -L and -l options:

libfoo_la_LIBADD = libbar.la -L/opt/local/lib -lpng

通常,您将使用configure脚本查找这些额外的库,并使用AC_SUBST将它们传递给:

Typically, you would use the configure script to find these extra libraries, and use AC_SUBST to pass them with:

libfoo_la_LIBADD = libbar.la $(EXTRA_FOO_LIBS)

对于程序,只需使用LDADD:

myprog_LDADD = libfoo.la # links libfoo, libbar, and libpng to myprog.

有时边界有些模糊. $(EXTRA_FOO_LIBS)可能已添加到myprog_LDADD.通常,最好的方法是将依赖项添加到libtool(.la)库,并使用libtool来完成所有特定于平台的链接器魔术.它将所有链接器元数据都放在一个地方.

Sometimes the boundaries are a bit vague. $(EXTRA_FOO_LIBS) could have been added to myprog_LDADD. Adding dependencies to a libtool (.la) library, and using libtool do all the platform-specific linker magic, is usually the best approach. It keeps all the linker metadata in the one place.

这篇关于LDADD和LIBADD有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆