help-gplusplus
[Top][All Lists]
Advanced

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

Re: -output-def, -soname using gcc


From: Guy Harrison
Subject: Re: -output-def, -soname using gcc
Date: Tue, 05 Oct 2004 21:00:00 GMT
User-agent: KNode/0.7.7

Ernesto wrote:

> I am developing a library using mingw (windows).
> 
> I created my binary files (.dll), my library file (.a) and my def file
> (.def) using
> 
> g++ -shared -o XXX.so -Wl,--output-def=XXX.def -Wl,--soname=XXX
> -W1,--out-implib=XXX.lib
> 
> The problem happens when I ported my library to linux and tried to
> compile using g++. The .a and the .def file are missing because g++ is
> ignoring my -Wl,* arguments.
> 
> Am I right or am I doing something wrong?

Building a portable DLL/shared lib can be tricky. You'll have to construct
your makefile(s) carefully. If you've no reason not to do so then I'd
suggest you first build a static lib (that at least is common to both
platforms) then proceed to use it to produce the DLL/shared lib. Having
built libXXX.a your command could be reduced to...

<windows>
$(CXX) -shared -o XXX.dll \
 -Wl,-whole-archive libXXX.a -Wl,-no-whole-archive \
 -Wl,-outimplib,libXXX.dll.a
</windows>

<unix>
$(CXX) -shared -o libXXX.so \
 -Wl,-whole-archive libXXX.a -Wl,-no-whole-archive
</unix>

See also "man ldconfig" and "man ld" (look for -rpath) for further insight.
Both your application link command and "install/uninstall" will need to
cater for those differences as well.




reply via email to

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