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: Using h_errno, errno etc Cygwin DLL globals [Re: Making wget]
@ 2000-01-27  9:38 Fifer, Eric
  0 siblings, 0 replies; 9+ messages in thread
From: Fifer, Eric @ 2000-01-27  9:38 UTC (permalink / raw)
  To: 'Chris Faylor'; +Cc: cygwin

>Care to submit a patch?

Actually, I'm not sure which style is the correct fix.

I think I would favor "__declspec(dllimport) h_errno"
(nowhere else in Cygwin does exported data use #define
with an __imp_ prefix, although mingw does).  But, I've seen some
code (in perl) which does a "#if !defined(h_errno)", so maybe
there are good portability reasons for a #define.  I'll defer
to someone who knows.

Also, something recently changed in the development snapshots
with respect to h_errno.  Because, I just noticed this problem
when I updated my snapshot this week.

Eric 

--
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-27  5:06 Fifer, Eric
@ 2000-01-27  8:11 ` Chris Faylor
  0 siblings, 0 replies; 9+ messages in thread
From: Chris Faylor @ 2000-01-27  8:11 UTC (permalink / raw)
  To: Fifer, Eric; +Cc: cygwin

On Thu, Jan 27, 2000 at 01:03:31PM -0000, Fifer, Eric wrote:
>
>Since we're on the topic of netdb.h and h_errno, has anyone
>noticed that in the recent snapshots the symbol that appears
>in libcygwin.a doesn't agree with the definition in netdb.h:
>
>  nm libcygwin.a | grep h_errno
>
>    00000000 ? __imp__h_errno
>  
>  netdb.h
>
>    extern int * __imp_h_errno;
>    #define h_errno (*__imp_h_errno)
>                 
>I think it should be (s/_h/__h/):
>
>    extern int * __imp__h_errno;
>    #define h_errno (*__imp__h_errno)
>
>or reworked as:
>
>    extern int __declspec(dllimport) h_errno;

Care to submit a patch?

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-27  5:06 Fifer, Eric
  2000-01-27  8:11 ` Chris Faylor
  0 siblings, 1 reply; 9+ messages in thread
From: Fifer, Eric @ 2000-01-27  5:06 UTC (permalink / raw)
  To: cygwin

Since we're on the topic of netdb.h and h_errno, has anyone
noticed that in the recent snapshots the symbol that appears
in libcygwin.a doesn't agree with the definition in netdb.h:

  nm libcygwin.a | grep h_errno

    00000000 ? __imp__h_errno
  
  netdb.h

    extern int * __imp_h_errno;
    #define h_errno (*__imp_h_errno)
                 
I think it should be (s/_h/__h/):

    extern int * __imp__h_errno;
    #define h_errno (*__imp__h_errno)

or reworked as:

    extern int __declspec(dllimport) h_errno;

Eric Fifer

--
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-27  9:38 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-27  5:06 Fifer, Eric
2000-01-27  8:11 ` Chris Faylor
2000-01-27  9:38 Fifer, Eric

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).