need help with cygwin -l option

Programming, for all ages and all languages.
User avatar
mcheung63
Member
Member
Posts: 175
Joined: Thu Jun 22, 2006 8:33 am
Location: Hong Kong
Contact:

need help with cygwin -l option

Post 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])
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: need help with cygwin -l option

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: need help with cygwin -l option

Post by qw »

User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: need help with cygwin -l option

Post by Solar »

Hmmm... I remember having a similar problem... will look it up, stand by.
Every good solution is obvious once you've found it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: need help with cygwin -l option

Post 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.
Every good solution is obvious once you've found it.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: need help with cygwin -l option

Post 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
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: need help with cygwin -l option

Post 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.
Every good solution is obvious once you've found it.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: need help with cygwin -l option

Post by Combuster »

uhm, I don't see undefined references, in the screenshot it claims it can't find the library itself...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: need help with cygwin -l option

Post by Solar »

I know; but my case makes me suspect that shuffling around the command line parameters might actually help in this case too.
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: need help with cygwin -l option

Post by qw »

My guess is that there is no libmean.a in the standard library directories.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: need help with cygwin -l option

Post by AJ »

Hobbes wrote:My guess is that there is no libmean.a in the standard library directories.
mcheung63 wrote:-L.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: need help with cygwin -l option

Post 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?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: need help with cygwin -l option

Post 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.
Every good solution is obvious once you've found it.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: need help with cygwin -l option

Post by qw »

Yes, libmean.so is not libmean.a.
User avatar
mcheung63
Member
Member
Posts: 175
Joined: Thu Jun 22, 2006 8:33 am
Location: Hong Kong
Contact:

Re: need help with cygwin -l option

Post 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

:(
Post Reply