Well done, sir!
I did not try to declare gethostname, but upon closer inspection I saw that
foo.c was not #including winsock.h directly or indirectly via other headers.
So the compiler must have been supplying the default int gethostname(...)
prototype (without warning me... I must not have sufficient warnings turned
on or something).
From: Luke Dunstan [mailto:coder_infidel@...]
Sent: Saturday, September 21, 2002 6:00 AM
To: MCNUTT,GORDON (HP-Boise,ex1); mingw-users@...
Subject: Re: [Mingw-users] gethostname in wsock32?
If you use "nm libwsock32.a" instead, you will see that the symbol is
gethostname@... because it is a stdcall function. If you tried to declare the
gethostname() function yourself, #include winsock.h instead.
----- Original Message -----
From: "MCNUTT,GORDON (HP-Boise,ex1)" <gordon.james.mcnutt@...>
Sent: Saturday, September 21, 2002 7:17 AM
Subject: [Mingw-users] gethostname in wsock32?
> Can anyone tell me why this is happening:
> gcc -o foo foo.o libmine.a -lwsock32 -liberty
> foo.o(.text+0x697):foo.c: undefined reference to 'gethostname'
> If I do a 'strings libwsock32.a' I see gethostname -- why can't the linker
> find it?