public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Making wget
@ 2000-01-26  1:39 Norling, Gunnar
  2000-01-26  7:29 ` Chris Faylor
  2000-01-26 10:37 ` Glenn Spell
  0 siblings, 2 replies; 9+ messages in thread
From: Norling, Gunnar @ 2000-01-26  1:39 UTC (permalink / raw)
  To: cygwin

Hi,
Some days ago there where a discussion involving the wget program. One of
the mails (sorry, I've already deleted it) described the build process for
it. I followed it, but in the end of the process I receive the following
errors:

$ make
:
.
gcc -O2 -Wall -Wno-implicit  -o wget.exe  cmpt.o connect.o fnmatch.o ftp.o
ftp-basi
ers.o host.o html.o http.o init.o log.o main.o md5.o netrc.o rbuf.o recur.o
retr.o
ftp.o(.text+0x848):ftp.c: undefined reference to `h_errno'
ftp.o(.text+0x1378):ftp.c: undefined reference to `h_errno'
ftp.o(.text+0x1808):ftp.c: undefined reference to `h_errno'
http.o(.text+0x750):http.c: undefined reference to `h_errno'
collect2: ld returned 1 exit status
make[1]: *** [wget.exe] Error 1
make[1]: Leaving directory
`/cygdrive/v/Cygnus/cygwin-b20/local/src/wget-1.5.3/src'
make: *** [src] Error 2

For some reason the "h_errno' is not defined. Could there be some problems
with my include libraries. I use a standard installation (using the snapshot
cygwin-inst-20000119.tar.gz), with no include variable set.

In the ftp.c file the following is defined:

---<start snip>---
#include <config.h>

#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#include <ctype.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include <assert.h>
#include <errno.h>

#include "wget.h"
#include "utils.h"
#include "url.h"
#include "rbuf.h"
#include "retr.h"
#include "ftp.h"
#include "html.h"
#include "connect.h"
#include "host.h"
#include "fnmatch.h"
#include "netrc.h"

#ifndef errno
extern int errno;
#endif
#ifndef h_errno
extern int h_errno;
#endif
---<end snip>---



This is my versions:
gcc --version: 2.95.2
uname -a: CYGWIN_NT-4.0 <machine> 1.1.0(0.16/3/2) 2000-01-20 00:22:41 i686
unknown




/Gunnar Norling 

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Making wget
  2000-01-26  1:39 Making wget Norling, Gunnar
@ 2000-01-26  7:29 ` Chris Faylor
  2000-01-26 10:37 ` Glenn Spell
  1 sibling, 0 replies; 9+ messages in thread
From: Chris Faylor @ 2000-01-26  7:29 UTC (permalink / raw)
  To: Norling, Gunnar; +Cc: cygwin

On Wed, Jan 26, 2000 at 09:38:59AM -0000, Norling, Gunnar wrote:
>Some days ago there where a discussion involving the wget program. One of
>the mails (sorry, I've already deleted it) described the build process for
>it. I followed it, but in the end of the process I receive the following
>errors:

Why not just download one of the prebuilt versions???

The cygwin web site is your friend:  http://sourceware.cygnus.com/cygwin/

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Making wget
  2000-01-26  1:39 Making wget Norling, Gunnar
  2000-01-26  7:29 ` Chris Faylor
@ 2000-01-26 10:37 ` Glenn Spell
  2000-01-26 16:18   ` Using h_errno, errno etc Cygwin DLL globals [Re: Making wget] Mumit Khan
  1 sibling, 1 reply; 9+ messages in thread
From: Glenn Spell @ 2000-01-26 10:37 UTC (permalink / raw)
  To: cygwin

On 26 Jan 2000 around 9:38AM (-0000) Norling,
Gunnar wrote:
> Some days ago there where a discussion involving the wget program.
>
> ftp.o(.text+0x848):ftp.c: undefined reference to `h_errno'
> http.o(.text+0x750):http.c: undefined reference to `h_errno'
>
> This is my versions:
> gcc --version: 2.95.2
> uname -a: CYGWIN_NT-4.0 <machine> 1.1.0(0.16/3/2) 2000-01-20
> 00:22:41 i686 unknown

I get the same results. I'm using gcc-2.95 with the 1999-12-05
dll (the newer dlls crash on me) on Win95.

The following patch worked for me. I gleaned the information
from /usr/include/netdb.h.

I have no idea why this is necessary for some and not for others.

-------------------------------------------------
--- src/ftp.c.orig       Thu Sep 10 09:21:36 1998
+++ src/ftp.c            Wed Jan 26 12:39:46 2000
@@ -52,3 +52,8 @@
 #ifndef h_errno
+# ifdef __CYGWIN__
+extern int * __imp_h_errno;
+#  define h_errno (*__imp_h_errno)
+# else
 extern int h_errno;
+# endif
 #endif
--- src/http.c.orig      Thu Sep 10 10:14:44 1998
+++ src/http.c           Wed Jan 26 12:40:30 2000
@@ -70,3 +70,8 @@
 #ifndef h_errno
+# ifdef __CYGWIN__
+extern int * __imp_h_errno;
+#  define h_errno (*__imp_h_errno)
+# else
 extern int h_errno;
+# endif
 #endif
-------------------------------------------------

-glenn

-- 
  ________________________________________      _       _____
 )                                        )_ _ (__\____o /_/_ |
 )    Glenn Spell <glenn@gs.fay.nc.us>    )     >-----._/_/__]>
 )________________________________________)               `0  |

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Using h_errno, errno etc Cygwin DLL globals [Re: Making wget]
  2000-01-26 10:37 ` Glenn Spell
@ 2000-01-26 16:18   ` Mumit Khan
  2000-01-26 17:27     ` Chris Faylor
  0 siblings, 1 reply; 9+ messages in thread
From: Mumit Khan @ 2000-01-26 16:18 UTC (permalink / raw)
  To: Glenn Spell; +Cc: cygwin

On Wed, 26 Jan 2000, Glenn Spell wrote:

> On 26 Jan 2000 around 9:38AM (-0000) Norling,
> Gunnar wrote:
> > Some days ago there where a discussion involving the wget program.
> >
> > ftp.o(.text+0x848):ftp.c: undefined reference to `h_errno'
> > http.o(.text+0x750):http.c: undefined reference to `h_errno'
> >
> > This is my versions:
> > gcc --version: 2.95.2
> > uname -a: CYGWIN_NT-4.0 <machine> 1.1.0(0.16/3/2) 2000-01-20
> > 00:22:41 i686 unknown
> 
> I get the same results. I'm using gcc-2.95 with the 1999-12-05
> dll (the newer dlls crash on me) on Win95.
> 
> The following patch worked for me. I gleaned the information
> from /usr/include/netdb.h.
> 
> I have no idea why this is necessary for some and not for others.

Here's why: older versions of Cygnus didn't add the DATA tag when
exporting h_errno, and so linking worked even for incorrect code;
however, you'll get an ACCESS_VIOLATION or segfault when you try
to access or assign to h_errno. Newer Cygwin snapshots enforce the
correct behaviour so that you have to import it explicitly. Consider
the following code:
  
  void
  foo ()
  {
    extern int h_errno;

    h_errno = 5;
  }

This code is incorrect, but would have linked correctly with older
versions of Cygwin (eg., b20.1), and you'll surely get a crash if
`foo' is ever called.

The correct way:
  
  #include <netdb.h>

  void
  foo ()
  {
    h_errno = 5;
  }

The same thing applies to all the other imported data symbols (ie.,
global variables) from Cygwin DLL, such as errno, etc.

> 
> -------------------------------------------------
> --- src/ftp.c.orig       Thu Sep 10 09:21:36 1998
> +++ src/ftp.c            Wed Jan 26 12:39:46 2000
> @@ -52,3 +52,8 @@
>  #ifndef h_errno
> +# ifdef __CYGWIN__
> +extern int * __imp_h_errno;
> +#  define h_errno (*__imp_h_errno)
> +# else
>  extern int h_errno;
> +# endif
>  #endif

If <netdb.h> is not included for some reason, the better way is to 
do the following:
  
  #ifdef __CYGWIN__
    __declspec(dllimport) int h_errno;
  #endif

But of course, one should be including <netdb.h> instead. Ah, the joys
of choosing among so many Unix misfeatures -- some don't declare it, 
some do and so on ;-)

Regards,
Mumit



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using h_errno, errno etc Cygwin DLL globals [Re: Making wget]
  2000-01-26 16:18   ` Using h_errno, errno etc Cygwin DLL globals [Re: Making wget] Mumit Khan
@ 2000-01-26 17:27     ` Chris Faylor
  2000-01-26 20:14       ` Mumit Khan
  0 siblings, 1 reply; 9+ messages in thread
From: Chris Faylor @ 2000-01-26 17:27 UTC (permalink / raw)
  To: Mumit Khan; +Cc: Glenn Spell, cygwin

On Wed, Jan 26, 2000 at 06:14:48PM -0600, Mumit Khan wrote:
>But of course, one should be including <netdb.h> instead. Ah, the joys
>of choosing among so many Unix misfeatures -- some don't declare it, 
>some do and so on ;-)

Bug report:

When compiling using gcc 2.97.43 and the Cygwin snapshot from 1999-8-31
I get an incorrect success when building code which contains both
h_errno and netdb.h.  My program compiles and links perfectly rather
than giving me the correct error!!!!

What the heck is the deal here???  This failed to compile perfectly on
Ultrix 4.2!!!  Has anyone else seen this problem??

Help!

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Using h_errno, errno etc Cygwin DLL globals [Re: Making wget]
  2000-01-26 17:27     ` Chris Faylor
@ 2000-01-26 20:14       ` Mumit Khan
  0 siblings, 0 replies; 9+ messages in thread
From: Mumit Khan @ 2000-01-26 20:14 UTC (permalink / raw)
  To: Chris Faylor; +Cc: Glenn Spell, cygwin

On Wed, 26 Jan 2000, Chris Faylor wrote:

> Bug report:
> 
> When compiling using gcc 2.97.43 and the Cygwin snapshot from 1999-8-31
> I get an incorrect success when building code which contains both
> h_errno and netdb.h.  My program compiles and links perfectly rather
> than giving me the correct error!!!!

I don't know what 1999-08-31 did with h_errno, and how it exported it. If
it was a "statically linked" global variable, much like what sys_errlist
used to be, then it's expected to work.

  $ nm libcygwin.a | grep h_errno

If you see _h_errno (no sign of 'imp' in the name), it's case 1 below
and it's an application-space global variable; if you see both _h_errno 
and _imp_ versions, then it's case 2 below; if you see *only* the _imp_ 
versions, it's case 3 below.

> What the heck is the deal here???  This failed to compile perfectly on
> Ultrix 4.2!!!  Has anyone else seen this problem??

I don't see a problem ;-)

Note the the version of gcc is irrelevant here, the only relevant items
are (1) if h_errno came from the DLL or came from the "static" part of
libcygwin.a, and (2) if former, whether the DEF file used the DATA tag
or not when exporting h_errno. 

Here're the scenarios:
 
1. h_errno is in the static part of libcygwin.a: in this case, it's just
   like any other application-space global variable, and you can safely
   declare it in your code as `extern int h_errno', and it'll work as
   expected.

2. h_errno comes from DLL, *and* cygwin.def did not use a DATA tag.
   In this case, the following code is will link correctly, but in all 
   likelihood crash:
     
     int
     main ()
     {
       extern int h_errno;
       h_errno = 5;
     }

3. h_errno comes from DLL, *and* cygwin.def DID use a DATA tag. In this,
   the code above will not even link.

Regards,
Mumit



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Making wget
@ 2000-01-26 12:31 David Robinow
  0 siblings, 0 replies; 9+ messages in thread
From: David Robinow @ 2000-01-26 12:31 UTC (permalink / raw)
  To: cygwin

--- Glenn Spell <glenn@gs.fay.nc.us> wrote:
> On 26 Jan 2000 around 9:38AM (-0000) Norling,
> Gunnar wrote:
> > Some days ago there where a discussion involving
> the wget program.
> >
> > ftp.o(.text+0x848):ftp.c: undefined reference to
> `h_errno'
> > http.o(.text+0x750):http.c: undefined reference to
> `h_errno'
> >
> > This is my versions:
> > gcc --version: 2.95.2
> > uname -a: CYGWIN_NT-4.0 <machine> 1.1.0(0.16/3/2)
> 2000-01-20
> > 00:22:41 i686 unknown
> 
> I get the same results. I'm using gcc-2.95 with the
> 1999-12-05
> dll (the newer dlls crash on me) on Win95.
> 
> The following patch worked for me. I gleaned the
> information
> from /usr/include/netdb.h.
> 
> I have no idea why this is necessary for some and
> not for others.
> 
 I've investigated a bit. Later snapshots have the
line
     h_errno DATA
in winsup.din, whereas 19990115 snapshot has
     h_errno

 I don't know what this means, but I'm guessing it has
something to do with why it seems to link with the old
snapshot but not the newer ones.
 Although the program seems to work for me, I haven't
tested it enough to tell if the part of the code that
uses h_errno is broken (i.e. links but doesn't work)
or not.
  Apparently Glenn's patch solves the problem, but I'm
wondering if this is a case like many old programs
declaring
  int errno
when they should use
 #include <errno.h>

 In other words, perhaps the code should just
 #include <netdb.h>

(Note that the last few lines above are off-topic for
Cygwin)

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Making wget
  2000-01-26  8:47 Making wget David Robinow
@ 2000-01-26 10:22 ` Chris Faylor
  0 siblings, 0 replies; 9+ messages in thread
From: Chris Faylor @ 2000-01-26 10:22 UTC (permalink / raw)
  To: David Robinow; +Cc: cygwin

On Wed, Jan 26, 2000 at 08:47:08AM -0800, David Robinow wrote:
>--- Chris Faylor <cgf@cygnus.com> wrote:
>> On Wed, Jan 26, 2000 at 09:38:59AM -0000, Norling, Gunnar wrote:
>>>Some days ago there where a discussion involving the wget program.  ...
>
>>Why not just download one of the prebuilt versions???
>
>I find this strange, especially considering the source.  Isn't Cygwin
>supposed to be a development environment?

Sure.  Are you a developer?  If so, then these problems are not
insurmountable and probably only require some investigation of the
source.  Feel free to offer him some advice.

I didn't want to take time to figure out what was going on and suggested
a much faster way of getting wget on his system than doing a

1. configure
2. make
3. What???  HELP!!!!
4. Wait for someone on the mailing list to look at the source and figure
   out what was going wrong.

cgf

> As I reported Monday
>./configure; make
>worked for me. (make install did not but I don't expect that)
>
>I'm running gcc-2.95 with the 1/15/99 snapshot on NT 4.0

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Making wget
@ 2000-01-26  8:47 David Robinow
  2000-01-26 10:22 ` Chris Faylor
  0 siblings, 1 reply; 9+ messages in thread
From: David Robinow @ 2000-01-26  8:47 UTC (permalink / raw)
  To: cygwin

--- Chris Faylor <cgf@cygnus.com> wrote:
> On Wed, Jan 26, 2000 at 09:38:59AM -0000, Norling,
> Gunnar wrote:
> >Some days ago there where a discussion involving
> the wget program. ...

> Why not just download one of the prebuilt
> versions???
 I find this strange, especially considering the
source.  Isn't Cygwin supposed to be a development
environment?

 As I reported Monday
./configure; make
worked for me. (make install did not but I don't
expect that)

I'm running gcc-2.95 with the 1/15/99 snapshot on NT 4.0
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2000-01-26 20:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-26  1:39 Making wget Norling, Gunnar
2000-01-26  7:29 ` Chris Faylor
2000-01-26 10:37 ` Glenn Spell
2000-01-26 16:18   ` Using h_errno, errno etc Cygwin DLL globals [Re: Making wget] Mumit Khan
2000-01-26 17:27     ` Chris Faylor
2000-01-26 20:14       ` Mumit Khan
2000-01-26  8:47 Making wget David Robinow
2000-01-26 10:22 ` Chris Faylor
2000-01-26 12:31 David Robinow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).