This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: trouble converting libgsl.a -> libgsl.so on cygwin
- From: Brian Dessent <brian at dessent dot net>
- To: Mirko Vukovic <mirko dot vukovic at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 16 Feb 2008 19:43:43 -0800
- Subject: Re: trouble converting libgsl.a -> libgsl.so on cygwin
- References: <d990efca0802161916q1786c218r16b47f3b03812b69@mail.gmail.com>
- Reply-to: gcc-help at gcc dot gnu dot org
Mirko Vukovic wrote:
> But on cygwin, ld does not have the -h option, and following the
> suggested command thus:
> ld -shared -s -o libgsl.so -whole-archive libgsl.a
> gives a long listing of undefined references. And of course, no .so
> library at the end of the exercise.
I would take that entire page with a huge grain of salt. Anyone that
advocates the practice of putting non-PIC objects into a shared library
needs their head examined. Also, directly invoking ld to link is almost
always a bad idea.
The proper way is to rebuild the library. Forget this conversion
nonsense. With most things that use standard tools it's simply a matter
of using --enable-shared when configuring. Cygwin is similar to linux
here, each .c file gets compiled to an .o and then linked to a .dll with
"gcc -shared". There is no 'ld' invocation anywhere. Note that calling
a DLL a .so is possible but it doesn't make much sense, it's not
anything close to the same as a ELF .so. Also note that Cygwin (really,
PE) does not have a notion of PIC, however it does have a notion of
dllimport/dllexport and often times this means that code that will be
made into a DLL must be compiled with different options than code in a
static library, just as on ELF you must recompile with -fPIC.
Brian