libtool:我的模块的路径是什么?

时间:2016-10-25 12:34:29

标签: automake libtool

我正在从autotools + libtool项目创建一个模块: Makefile.am如下所示

#the module:                                                     
lib_LTLIBRARIES = mmmm.la                                        
mmmm_la_SOURCES = mmmm.c                                 
mmmm_la_LDFLAGS = $(AM_LDFLAGS) -module -shared

现在,我想为我的模块编写一个C测试。测试应该开始加载共享对象mmmm.xx(其中.xx是.so.la

我应该在C测试中给dlopen()lt_dlopen()提供什么路径?:我的模块(与测试程序相比)的相对位置因我是否进行检查而有所不同, out of tree make check,或make installcheck ...

我尝试使用lt_dlopen()希望测试-dlopen上传递的Makefile.am选项可以帮助autotools在调用lt_dlopen()时找到lib,但似乎不是帮助:lt_dlopen()确实可以打开.la文件,但是仍然必须告诉该文件的位置(可能省略.libs目录)

使用ltdl lib:

进行测试时,我的测试makefile看起来像这样
#the module test (tests are also installed, hence the "test" prefix)
test_PROGRAMS = tttt
tttt_SOURCES = tttt.c
tttt_LDADD = "-dlopen" mmmm.la
tttt_DEPENDENCIES = mmmm.la

有什么好的暗示吗?

1 个答案:

答案 0 :(得分:0)

您可以处理的一种方法是将LD_LIBRARY_PATH env变量设置为库的安装位置。

但是,由于您需要测试,我会说从configure.ac导出变量到config.h。因此,包含config.h的任何文件都会有#define your_variable,可用于设置dlopen的路径。