简体   繁体   English

设置自动工具库文件名,以后再引用

[英]Set autotools library filename and reference it later on

I'm using autotools to build a library which will later be loaded by another program. 我正在使用autotools来构建一个库,以后将由另一个程序加载该库。 This library has to have a .so extension to it regardless of the platform I'm on (this is a requirement imposed by the program loading it), and I'd also like it to not have a version specifier. 无论我在什么平台上,该库都必须具有.so扩展名(这是加载该程序的要求),并且我也希望它没有版本说明符。 How can I set the output name of such a library? 如何设置此类库的输出名称?

This is what Makefile.am looks like 这就是Makefile.am样子

lib_LTLIBRARIES = mylib.la
mylib_la_SOURCES = mylib.c
mylib_la_CPPFLAGS = $(LTDLINCL)
mylib_la_CFLAGS = $(CFLAGS) $(LIBFFI_CFLAGS)
LDADD = $(LIBLTDL) -dlopen self

Reading through the libtool manpage, it seems I need to set -install_name , but I don't see it referenced in the generated Makefile anywhere. libtool阅读libtool联机帮助页,似乎我需要设置-install_name ,但是我看不到它在生成的Makefile任何地方被引用。

I also need to be able to reference this library's output directory elsewhere in the Makefiles (for testing purposes), is there a variable containing its basename or full path? 我还需要能够在Makefiles其他地方引用该库的输出目录(出于测试目的),是否存在一个包含其基名或完整路径的变量?

How can I set the output name of such a library? 如何设置此类库的输出名称?

The output name of the library will be the name given in lib_LTLIBRARIES without the suffix .a . 库的输出名称将是lib_LTLIBRARIES给定的名称,不带后缀.a It will generate by default a shared library - .so . 默认情况下,它将生成一个共享库.so Thus, you do not need to specify anything else. 因此,您无需指定其他任何内容。

I also need to be able to reference this library's output directory elsewhere in the Makefiles (for testing purposes), is there a variable containing its basename or full path? 我还需要能够在Makefiles的其他地方引用该库的输出目录(出于测试目的),是否存在一个包含其基名或完整路径的变量?

The variable $(libdir) or @libdir@ in the Makefile will point to the full path of the library directory. Makefile中的变量$(libdir)@libdir@将指向库目录的完整路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM