[Top][All Lists]

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

Re: Libtool is looking for main() when linking shared library

From: Peter Rosin
Subject: Re: Libtool is looking for main() when linking shared library
Date: Mon, 21 Mar 2011 09:26:22 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20110303 Thunderbird/3.1.9

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.o -pthread -ldl
> Now I modified it so that my resulting only exports
> symbols that start with mylib_ :
> libtool --mode=link g++ -shared   -o ../ 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"


libtool --mode=compile g++ -o libmylib.lo libmylib.cpp
libtool --mode=link g++ -o ../ libmylib.lo -pthread -ldl 
-export-symbols-regex mylib_ -rpath /usr/local/lib

might work better (untested)


reply via email to

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