On 3/21/11, Peter Rosin <p...@lysator.liu.se> wrote:
> Den 2011-03-21 07:36 skrev Satz Klauer:
>> Hi,
>>
>> I try to use libtool to limit the number of symbols exported by a
>> shared library. My previous call to create this library looked like
>> this and worked fine:
>>
>> g++ -shared   -o ../libmylib.so libmylib.o -pthread -ldl
>>
>> Now I modified it so that my resulting libmylib.so only exports
>> symbols that start with mylib_ :
>>
>> libtool --mode=link g++ -shared   -o ../libmylib.so libmylib.o
>> -pthread -ldl -export-symbols-regex mylib_
>>
>> But despite the keyword "shared" now libtool complains about a missing
>> function main(), means it tries to create an executable program
>> instead of a shared library.
>>
>> What am I doing wrong here?
>
> -shared is not how you tell libtool to build a shared library (and you do
> not want to build a shared library behind the back of libtool by manually
> passing -shared to g++, that would defeat the purpose of libtool). You need
> to specify "-rpath /where/to/install" to make libtool build what is called
> a "libtool library".  If a "libtool library" ends up shared, static or
> both depends on the system and on how libtool was configured (see
> configure options --disable-shared and --disable-static).  You also want
> to link with .lo files instead of .o files, i.e. "libtool objects" instead
> of ordinary plain old objects.  "Libtool objects" are created with e.g.
> "libtool --mode=compile g++ -o foo.lo foo.cpp" instead of plain old
> "g++ -o foo.o foo.cpp"
>
> So,
>
> libtool --mode=compile g++ -o libmylib.lo libmylib.cpp
> libtool --mode=link g++ -o ../libmylib.la libmylib.lo -pthread -ldl
> -export-symbols-regex mylib_ -rpath /usr/local/lib
>
> might work better (untested)

That works a bit better - so at least I get a shared library now.

Unfortunately the -export-symbols-regex  seem not to work, it still
exports all symbols, not only the ones that start with/contain
"mylib_".

Elmi

_______________________________________________
http://lists.gnu.org/mailman/listinfo/libtool

Reply via email to