[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lt_dlopen an uninstalled library

From: ilya Basin
Subject: lt_dlopen an uninstalled library
Date: Mon, 22 Nov 2021 23:33:14 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2

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` 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("") fails with "File not found". It 
only succeeds if the filename contains "./.libs/". What am I doing wrong?

    bin_PROGRAMS = purplecat
    purplecat_SOURCES = main.c
    purplecat_LDADD = \
        -dlopen \
        -lltdl \
    libpurplecat_la_SOURCES = \
        purplecat.h \
        purplecat.c \
    libpurplecat_la_LDFLAGS = -module


    int main(int argc, char *argv[]) {
        static const char *filename = "libpurplecat";
        static int (*p_pcat_main)(int argc, char *argv[]);
        int res;
        lt_dlhandle handle = lt_dlopenext(filename);
        if (!handle) {
                fprintf(stderr, "Failed to load '%s': %s\n", filename, 
                return 1;
        p_pcat_main = lt_dlsym(handle, "pcat_main");
        res = p_pcat_main(argc, argv);
        return res;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]