lt_dlopen an uninstalled library

ilya Basin <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
Hi List.
I'm making a program with plugins as shared libraries and when I run `make check` I want my program to load the uninstalled plugins using lt_dlopen().

I expected that passing `-dlopen libname.la` to libtool would force the generation of a wrapper script setting the proper LD_LIBRARY_PATH (just like regular linking with a shared .la does). However, an ELF binary is generated and and attempt to call lt_dlopen("libname.la") fails with "File not found". It only succeeds if the filename contains "./.libs/". What am I doing wrong?

Makefile.am:

    bin_PROGRAMS = purplecat
    purplecat_SOURCES = main.c
    
    purplecat_LDADD = \
    	-dlopen libpurplecat.la \
    	-lltdl \
    	$(MY_NULL)
    
    lib_LTLIBRARIES = libpurplecat.la
    
    libpurplecat_la_SOURCES = \
    	purplecat.h \
    	purplecat.c \
    	$(MY_NULL)
    
    libpurplecat_la_LDFLAGS = -module


main.c:

    int main(int argc, char *argv[]) {
    	static const char *filename = "libpurplecat";
    	static int (*p_pcat_main)(int argc, char *argv[]);
    	int res;
    	lt_dlinit();
    	lt_dlhandle handle = lt_dlopenext(filename);
    	if (!handle) {
    		fprintf(stderr, "Failed to load '%s': %s\n", filename, lt_dlerror());
    		return 1;
    	}
    	p_pcat_main = lt_dlsym(handle, "pcat_main");
    	res = p_pcat_main(argc, argv);
    	lt_dlclose(handle);
    	return res;
    }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.