Re: lt_dlopen an uninstalled library

Luke Mewburn <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
On 21-11-22 23:33, ilya Basin wrote:
  | 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?


I think you'll find it's less hassle to extend your testsuite setup to
install the library into the testsuite working area before performing
other tests, using a "make DESTDIR=working/area/some/subdir install".
I do this for other components too, such as python extension shared
libraries.

Then just set your LD_LIBRARY_PATH, PYTHONPATH (etc) to the
relevant testsuite working area, before running the other tests.


  | 
  | 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;
  |     }
  | 



regards,
Luke.
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.