libtool
[Top][All Lists]
Advanced

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

Question about static compile using libtldl for dlopen


From: Guylhem
Subject: Question about static compile using libtldl for dlopen
Date: Tue, 13 Mar 2012 14:26:04 -0300

Hello

(I hope it is the right place to ask this question, if it isn't suggestions are appreciated)

I am trying to compile a static binary for netatalk, which uses different libs. I tried and failed, so I make a test case of what does not work - it is the 2 Makefile attached. Just type make test to create the demo and compile, make vacuum to remove them

Basically, a function can be used either as a library (opposite: static) or dlopen. netatalk has various functions in many libs - refactoring all the code for a static compile doesn't seem like a good option. Figuring out how to dlopen in a static binary seems a better idea- so I did this testcase with a very simple mean() function.

dlopen with a static binary seems counterintuitive-  I must be missing something, but from what I read 
on http://www.gnu.org/software/libtool/manual/libtool.html#Dlpreopening libtool is the right tool for the job at hand:

> "Libtool emulates -dlopen on static platforms by linking objects into
> the program at compile time, and creating data structures that
> represent the program's symbol table. In order to use this feature,
> you must declare the objects you want your application to dlopen by
> using the -dlopen or -dlpreopen flags when you link your program (see
> Link mode)."

In the testcase, dlopenstatic has a dependency in the lib, while the other test case do not have them - so it fails, as planned.

dlopen.c:(.text+0x28): warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking

Yet in my try with libtool, but I can't even compile the dlopenstatic testcase :

libtool --mode=link gcc -lltdl -all-static dlopen.o -o dlopenstatic
-dlopen libmean.la
libtool: link: cannot -dlopen a convenience library: `libmean.la'
make: *** [dlopenstatic] Error 1

I have read http://www.gnu.org/s/libtool/manual/html_node/Modules-for-libltdl.html#Modules-for-libltdl
but adding #define mean mean_LTX_mean in mean.c does not help.

Yet in libmean.la 1st line  I see : "The name that we can dlopen"

What am I doing wrong?

Is there a working example I could study, or could someone fix my testcase??

Thanks in advance
Guylhem

Attachment: Makefile
Description: Binary data

Attachment: Makefile-ltdl
Description: Binary data


reply via email to

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