Page 1 of 2

need help with cygwin -l option

Posted: Tue Jan 26, 2010 2:01 am
by mcheung63
Hi
I have a elf386 gcc in cygwin(not cygwin built-int gcc). I have an error while compile, please help

Image

thanks
from Peter ([email protected])

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 2:05 am
by Combuster
mcheung63 wrote:I have a elf386 gcc in cygwin(not cygwin built-int gcc)
No you haven't, or at least, you are not using it.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 2:07 am
by qw

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 2:35 am
by Solar
Hmmm... I remember having a similar problem... will look it up, stand by.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 3:10 am
by Solar
Can't really point a finger at it, but it has something to do with the order of the options on the command line. Try shuffling around the input file, -lmean, and the -o dynamically_linked. And yes, Cygwin GCC is (for some reason) touchy about this.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 3:28 am
by AJ
Hi,

I had a similar problem a while ago with ld. This was resolved by using the --start-group and --end-group flags around the library options. I realise that this is only meant to make LD search libraries multiple times (and can therefore slow linking), but it fixed a very similar problem to yours. It may simply be that this rearranged the command line options in to a way that the linker liked (as per Solar's suggestion).

This may not be relevant because you are getting gcc to link for you and I'm unsure if it accepts these parameters, but just in case...

Cheers,
Adam

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 3:39 am
by Solar
I found it again. The error message was a different one, but here's the story (for completeness' sake):

It was a prototype app I wrote that used libcrypto (from the OpenSSL package). This line:

Code: Select all

$ gcc -lcrypto crypttool.c -o crypttool
Worked beautifully under Linux, gave a bunch of undefined references on Cygwin.

Code: Select all

$ gcc crypttool.c -lcrypto -o crypttool
Worked under both Linux and Cygwin.

That's why I remembered "Cygwin GCC is touchy about parameter ordering". As I said, not quite like your case, but perhaps reordering helps you, too.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 3:57 am
by Combuster
uhm, I don't see undefined references, in the screenshot it claims it can't find the library itself...

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 4:12 am
by Solar
I know; but my case makes me suspect that shuffling around the command line parameters might actually help in this case too.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 4:48 am
by qw
My guess is that there is no libmean.a in the standard library directories.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 4:53 am
by AJ
Hobbes wrote:My guess is that there is no libmean.a in the standard library directories.
mcheung63 wrote:-L.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 5:21 am
by Combuster
I don't think the location of -o should matter, as I never knowingly had problems with that. The rest is in the expected order so...

What concerns me more is that he is using cygwin's gcc, thinking it's a elf crosscompiler, and then trying to link .so's with it, which is definately not what it was intended to do...:
not cygwin built-int gcc
(...)
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld
You see the contradiction?

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 5:41 am
by Solar
Combuster wrote:I don't think the location of -o should matter, as I never knowingly had problems with that. The rest is in the expected order so...
That's why I mentioned that instance where options in the expected order didn't work for me on Cygwin once before.
You see the contradiction?
I see it, but that shouldn't matter either. The linker can't see libmean.a...

Wait. You're right, of course!

Cygwin 'ld' links against .a files, which provide the "handles" for DLLs if necessary. In any case, the Cygwin 'ld' (which you are using) doesn't know about .so files AFAIK.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 6:15 am
by qw
Yes, libmean.so is not libmean.a.

Re: need help with cygwin -l option

Posted: Tue Jan 26, 2010 10:32 am
by mcheung63
If I have libmean.a , the -lmean work
i found that I can compile my file like this in cygwin

gcc mysource.c libmean.so

:(