libtool
[Top][All Lists]
Advanced

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

Re: ltdl and C++


From: Alessandro Candini
Subject: Re: ltdl and C++
Date: Fri, 23 Sep 2011 10:45:14 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13

On 21/09/11 10:14, Alessandro Candini wrote:
On 20/09/11 17:04, Nick Bowler wrote:
On 2011-09-19 15:34 +0200, Alessandro Candini wrote:
Configure and make works but I do not produce a dynamic linked
executable, unlike the original John's example:
../src $ ldd hello
      not a dynamic executable
This is normal.  When libtool creates an executable that links against
other libtool libraries in your source tree, it creates a shell script
to run the program in-place so that you don't need to install it.  You
haven't shown us your Makefile.am, but I assume it contains something
like hello_LDFLAGS = -dlopen plugin.la.

You appear to be running ldd on that shell script, so of course it's
"not a dynamic executable".  The actual binary that gets installed is
located in .libs/.

If you want to run ldd on an uninstalled executable, do it through
libtool:

   libtool --mode=execute ldd hello

Hope that helps,
Thank you Nick, I didn't get that those file were not binary executable files, but shell scripts:

Working example:
$ book/jupiter-libtool-ch7/src $ file jupiter
jupiter: Bourne-Again shell script text executable

My not working example:
$ hello_chap7/src $ file hello
hello: Bourne-Again shell script text executable

But the problem remains: the original one can load and use the dynamic library but my example doesn't. And if I look at the make output, the only difference I can notice is the presence in my example of the -fPIC -DPIC flags.

Build on working example:
make  all-recursive
make[1]: Entering directory `jupiter-libtool-ch7'
Making all in common
make[2]: Entering directory `jupiter-libtool-ch7/common'
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT print.lo -MD -MP -MF .deps/print.Tpo -c -o print.lo print.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT print.lo -MD -MP -MF .deps/print.Tpo -c print.c -fPIC -DPIC -o .libs/print.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT print.lo -MD -MP -MF .deps/print.Tpo -c print.c -o print.o >/dev/null 2>&1
mv -f .deps/print.Tpo .deps/print.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -o libjupcommon.la print.lo -lltdl -lpthread
libtool: link: ar cru .libs/libjupcommon.a .libs/print.o
libtool: link: ranlib .libs/libjupcommon.a
libtool: link: ( cd ".libs" && rm -f "libjupcommon.la" && ln -s "../libjupcommon.la" "libjupcommon.la" )
make[2]: Leaving directory `jupiter-libtool-ch7/common'
Making all in include
make[2]: Entering directory `jupiter-libtool-ch7/include'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `jupiter-libtool-ch7/include'
Making all in libjup
make[2]: Entering directory `jupiter-libtool-ch7/libjup'
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I../common -g -O2 -MT libjupiter_la-jup_print.lo -MD -MP -MF .deps/libjupiter_la-jup_print.Tpo -c -o libjupiter_la-jup_print.lo `test -f 'jup_print.c' || echo './'`jup_print.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I../common -g -O2 -MT libjupiter_la-jup_print.lo -MD -MP -MF .deps/libjupiter_la-jup_print.Tpo -c jup_print.c -fPIC -DPIC -o .libs/libjupiter_la-jup_print.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I../common -g -O2 -MT libjupiter_la-jup_print.lo -MD -MP -MF .deps/libjupiter_la-jup_print.Tpo -c jup_print.c -o libjupiter_la-jup_print.o >/dev/null 2>&1
mv -f .deps/libjupiter_la-jup_print.Tpo .deps/libjupiter_la-jup_print.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -o libjupiter.la -rpath /usr/local/lib libjupiter_la-jup_print.lo ../common/libjupcommon.la -lltdl -lpthread libtool: link: gcc -shared .libs/libjupiter_la-jup_print.o -Wl,--whole-archive ../common/.libs/libjupcommon.a -Wl,--no-whole-archive -ldl /usr/lib/libltdl.so -lpthread -Wl,-soname -Wl,libjupiter.so.0 -o .libs/libjupiter.so.0.0.0 libtool: link: (cd ".libs" && rm -f "libjupiter.so.0" && ln -s "libjupiter.so.0.0.0" "libjupiter.so.0") libtool: link: (cd ".libs" && rm -f "libjupiter.so" && ln -s "libjupiter.so.0.0.0" "libjupiter.so") libtool: link: (cd .libs/libjupiter.lax/libjupcommon.a && ar x "jupiter-libtool-ch7/libjup/../common/.libs/libjupcommon.a") libtool: link: ar cru .libs/libjupiter.a libjupiter_la-jup_print.o .libs/libjupiter.lax/libjupcommon.a/print.o
libtool: link: ranlib .libs/libjupiter.a
libtool: link: rm -fr .libs/libjupiter.lax
libtool: link: ( cd ".libs" && rm -f "libjupiter.la" && ln -s "../libjupiter.la" "libjupiter.la" )
make[2]: Leaving directory `jupiter-libtool-ch7/libjup'
Making all in src
make[2]: Entering directory `jupiter-libtool-ch7/src'
Making all in modules/hithere
make[3]: Entering directory `jupiter-libtool-ch7/src/modules/hithere'
/bin/bash ../../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../.. -g -O2 -MT hithere.lo -MD -MP -MF .deps/hithere.Tpo -c -o hithere.lo hithere.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -g -O2 -MT hithere.lo -MD -MP -MF .deps/hithere.Tpo -c hithere.c -fPIC -DPIC -o .libs/hithere.o libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../.. -g -O2 -MT hithere.lo -MD -MP -MF .deps/hithere.Tpo -c hithere.c -o hithere.o >/dev/null 2>&1
mv -f .deps/hithere.Tpo .deps/hithere.Plo
/bin/bash ../../../libtool --tag=CC --mode=link gcc -g -O2 -module -avoid-version -o hithere.la -rpath /usr/local/lib/jupiter hithere.lo -lltdl -lpthread libtool: link: gcc -shared .libs/hithere.o /usr/lib/libltdl.so -lpthread -Wl,-soname -Wl,hithere.so -o .libs/hithere.so
libtool: link: ar cru .libs/hithere.a  hithere.o
libtool: link: ranlib .libs/hithere.a
libtool: link: ( cd ".libs" && rm -f "hithere.la" && ln -s "../hithere.la" "hithere.la" )
make[3]: Leaving directory `jupiter-libtool-ch7/src/modules/hithere'
make[3]: Entering directory `jupiter-libtool-ch7/src'
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT jupiter-main.o -MD -MP -MF .deps/jupiter-main.Tpo -c -o jupiter-main.o `test -f 'main.c' || echo './'`main.c
mv -f .deps/jupiter-main.Tpo .deps/jupiter-main.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -o jupiter jupiter-main.o ../libjup/libjupiter.la -dlopen modules/hithere/hithere.la -lltdl -lpthread
libtool: link: rm -f .libs/jupiter.nm .libs/jupiter.nmS .libs/jupiter.nmT
libtool: link: (cd .libs && gcc -g -O2 -c -fno-builtin "jupiterS.c")
libtool: link: rm -f ".libs/jupiterS.c" ".libs/jupiter.nm" ".libs/jupiter.nmS" ".libs/jupiter.nmT" libtool: link: gcc -g -O2 -o .libs/jupiter jupiter-main.o .libs/jupiterS.o ../libjup/.libs/libjupiter.so /usr/lib/libltdl.so -lpthread
make[3]: Leaving directory `jupiter-libtool-ch7/src'
make[2]: Leaving directory `jupiter-libtool-ch7/src'
make[2]: Entering directory `jupiter-libtool-ch7'
make[2]: Leaving directory `jupiter-libtool-ch7'
make[1]: Leaving directory `jupiter-libtool-ch7'

Build on my not working example:
make  all-recursive
make[1]: Entering directory `hello_chap7'
Making all in common
make[2]: Entering directory `hello_chap7/common'
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -MT print.lo -MD -MP -MF .deps/print.Tpo -c -o print.lo print.cpp libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -MT print.lo -MD -MP -MF .deps/print.Tpo -c print.cpp -fPIC -DPIC -o .libs/print.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -MT print.lo -MD -MP -MF .deps/print.Tpo -c print.cpp -o print.o >/dev/null 2>&1
mv -f .deps/print.Tpo .deps/print.Plo
/bin/bash ../libtool --tag=CXX --mode=link g++ -Wall -g -O2 -o libhellocommon.la print.lo -lltdl -lpthread
libtool: link: ar cru .libs/libhellocommon.a .libs/print.o
libtool: link: ranlib .libs/libhellocommon.a
libtool: link: ( cd ".libs" && rm -f "libhellocommon.la" && ln -s "../libhellocommon.la" "libhellocommon.la" )
make[2]: Leaving directory `hello_chap7/common'
Making all in include
make[2]: Entering directory `hello_chap7/include'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `hello_chap7/include'
Making all in libhello
make[2]: Entering directory `hello_chap7/libhello'
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I../common -Wall -g -O2 -MT libhello_la-hello_print.lo -MD -MP -MF .deps/libhello_la-hello_print.Tpo -c -o libhello_la-hello_print.lo `test -f 'hello_print.cpp' || echo './'`hello_print.cpp libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I../common -Wall -g -O2 -MT libhello_la-hello_print.lo -MD -MP -MF .deps/libhello_la-hello_print.Tpo -c hello_print.cpp -fPIC -DPIC -o .libs/libhello_la-hello_print.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I../common -Wall -g -O2 -MT libhello_la-hello_print.lo -MD -MP -MF .deps/libhello_la-hello_print.Tpo -c hello_print.cpp -o libhello_la-hello_print.o >/dev/null 2>&1
mv -f .deps/libhello_la-hello_print.Tpo .deps/libhello_la-hello_print.Plo
/bin/bash ../libtool --tag=CXX --mode=link g++ -Wall -g -O2 -o libhello.la -rpath /usr/local/lib libhello_la-hello_print.lo ../common/libhellocommon.la -lltdl -lpthread libtool: link: g++ -shared -nostdlib /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crti.o /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/crtbeginS.o .libs/libhello_la-hello_print.o -Wl,--whole-archive ../common/.libs/libhellocommon.a -Wl,--no-whole-archive -ldl /usr/lib/libltdl.so -lpthread -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../.. -L/usr/lib/x86_64-linux-gnu -lstdc++ -lm -lc -lgcc_s /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/crtendS.o /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crtn.o -Wl,-soname -Wl,libhello.so.0 -o .libs/libhello.so.0.0.0 libtool: link: (cd ".libs" && rm -f "libhello.so.0" && ln -s "libhello.so.0.0.0" "libhello.so.0") libtool: link: (cd ".libs" && rm -f "libhello.so" && ln -s "libhello.so.0.0.0" "libhello.so") libtool: link: (cd .libs/libhello.lax/libhellocommon.a && ar x "hello_chap7/libhello/../common/.libs/libhellocommon.a") libtool: link: ar cru .libs/libhello.a libhello_la-hello_print.o .libs/libhello.lax/libhellocommon.a/print.o
libtool: link: ranlib .libs/libhello.a
libtool: link: rm -fr .libs/libhello.lax
libtool: link: ( cd ".libs" && rm -f "libhello.la" && ln -s "../libhello.la" "libhello.la" )
make[2]: Leaving directory `hello_chap7/libhello'
Making all in src
make[2]: Entering directory `hello_chap7/src'
Making all in modules/hithere
make[3]: Entering directory `hello_chap7/src/modules/hithere'
/bin/bash ../../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../.. -Wall -g -O2 -MT hithere.lo -MD -MP -MF .deps/hithere.Tpo -c -o hithere.lo hithere.cpp libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../.. -Wall -g -O2 -MT hithere.lo -MD -MP -MF .deps/hithere.Tpo -c hithere.cpp -fPIC -DPIC -o .libs/hithere.o libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../.. -Wall -g -O2 -MT hithere.lo -MD -MP -MF .deps/hithere.Tpo -c hithere.cpp -o hithere.o >/dev/null 2>&1
mv -f .deps/hithere.Tpo .deps/hithere.Plo
/bin/bash ../../../libtool --tag=CXX --mode=link g++ -Wall -g -O2 -module -avoid-version -o hithere.la -rpath /usr/local/lib/hello hithere.lo -lltdl -lpthread libtool: link: g++ -shared -nostdlib /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crti.o /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/crtbeginS.o .libs/hithere.o /usr/lib/libltdl.so -lpthread -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../.. -L/usr/lib/x86_64-linux-gnu -lstdc++ -lm -lc -lgcc_s /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/crtendS.o /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../crtn.o -Wl,-soname -Wl,hithere.so -o .libs/hithere.so
libtool: link: ar cru .libs/hithere.a  hithere.o
libtool: link: ranlib .libs/hithere.a
libtool: link: ( cd ".libs" && rm -f "hithere.la" && ln -s "../hithere.la" "hithere.la" )
make[3]: Leaving directory `hello_chap7/src/modules/hithere'
make[3]: Entering directory `hello_chap7/src'
g++ -DHAVE_CONFIG_H -I. -I.. -I../include -Wall -g -O2 -MT hello-hello.o -MD -MP -MF .deps/hello-hello.Tpo -c -o hello-hello.o `test -f 'hello.cpp' || echo './'`hello.cpp
mv -f .deps/hello-hello.Tpo .deps/hello-hello.Po
/bin/bash ../libtool --tag=CXX --mode=link g++ -Wall -g -O2 -o hello hello-hello.o ../libhello/libhello.la -dlopen modules/hithere/hithere.la -lltdl -lpthread
libtool: link: rm -f .libs/hello.nm .libs/hello.nmS .libs/hello.nmT
libtool: link: (cd .libs && gcc -g -O2 -c -fno-builtin "helloS.c")
libtool: link: rm -f ".libs/helloS.c" ".libs/hello.nm" ".libs/hello.nmS" ".libs/hello.nmT" libtool: link: g++ -Wall -g -O2 -o .libs/hello hello-hello.o .libs/helloS.o ../libhello/.libs/libhello.so /usr/lib/libltdl.so -lpthread
make[3]: Leaving directory `hello_chap7/src'
make[2]: Leaving directory `hello_chap7/src'
make[2]: Entering directory `hello_chap7'
make[2]: Leaving directory `hello_chap7'
make[1]: Leaving directory `hello_chap7'

The main function of both example is:
int main(int argc, char * argv[])
{
   const char * salutation = DEFAULT_SALUTATION;

#if HAVE_LTDL_H
    int ltdl;
    lt_dlhandle module;
    get_salutation_t * get_salutation_fp = 0;

    LTDL_SET_PRELOADED_SYMBOLS();

    ltdl = lt_dlinit();
    if (ltdl == 0)
    {
        module = lt_dlopen("modules/hithere/hithere.la");
        if (module != 0)
        {
get_salutation_fp = (get_salutation_t *) lt_dlsym(module, GET_SALUTATION_SYM);
            if (get_salutation_fp != 0)
                salutation = get_salutation_fp();
        }
    }
#endif

// ...other code

    return 0;
}

And I saw that in the working example get_salutation_fp is != 0, in my example is not!

Any ideas?


No hints?

--
Alessandro Candini

MEEO S.r.l.
Via Saragat 9
I-44122 Ferrara, Italy
Tel: +39 0532 1861501
Fax: +39 0532 1861637
http://www.meeo.it

========================================
"ATTENZIONE:le informazioni contenute in questo messaggio sono
da considerarsi confidenziali ed il loro utilizzo è riservato unicamente
al destinatario sopra indicato. Chi dovesse ricevere questo messaggio
per errore è tenuto ad informare il mittente ed a rimuoverlo
definitivamente da ogni supporto elettronico o cartaceo."

"WARNING:This message contains confidential and/or proprietary
information which may be subject to privilege or immunity and which
is intended for use of its addressee only. Should you receive this
message in error, you are kindly requested to inform the sender and
to definitively remove it from any paper or electronic format."




reply via email to

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