Subject: Re: mingw32
From: [email-masked] (Mumit Khan)

13 Jan 1998 17:50:52 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
To: Narayan Natarajan <[email-masked]>
Cc: [email-masked]

Narayan Natarajan <[email-masked]> writes:
> Does mingw32 have getopt in its libraries? I am having trouble compiling
> code using getopt with mingw32.

yes, and no. The GNU getopt (as well as getopt_long) is part of the 
libiberty library, which should have been in the distribution (see the
<root>/lib directory), unless I missed it somehow. Unfortunately, the
getopt.h is not installed by default, which provides the prototypes and
some of the definitions needed for getopt_long. Let me know if you can't
find it in some other GNU package and I'll email it to you.

fyi, getopt is not ANSI, hence not guaranteed to be in an ANSI-only runtime;
it is however in the POSIX.1 specs, so most real systems provide it. My 
own code uses getopt that is built along with the package, so it's not an 
issue (and that's why I didn't miss the missing getopt prototype).

As a quick hack:

  extern int getopt(int argc, char * const argv[], const char *optstring);
  extern char *optarg;
  extern int optind, opterr, optopt;

  int main (int argc, char *argv[]) {
    /* use getopt */
  
  }

Now link -liberty as well.

  % cc -o getopt_test.exe getopt_test.c -liberty.

and see what happens.

Mumit
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".