[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

./lib/getopt.h:197: error: redefinition of `struct option'

From: Mark R Bannister
Subject: ./lib/getopt.h:197: error: redefinition of `struct option'
Date: Tue, 6 Dec 2011 11:58:35 +0000


I'm banging my head against a wall here trying to port nss_db to Solaris 10.

It includes a source file called makedb.c that requires argp.h and error.h. 
Incidentally it also requires a Berkeley database which I have in

I thought the easiest thing was to use gnulib to provide the missing argp and
error functionality.  I couldn't get the git repo (firewall restrictions), so 
to grab the latest package from here: http://erislabs.net/ianb/projects/gnulib/

Unfortunately, by importing these gnulib modules I get a new unistd.h that
includes getopt.h.  The Solaris package SUNWhea also has getopt.h, and now the
problems really start.

I imported:
./gnulib-tool --import argp error
and set-up the pre-requisites in configure.in and Makefile.am.

Here is a very simple test file:

#include <db.h>

int main(int argc, char **argv)
    return 0;

The following works fine:

$ gcc -I/opt/csw/bdb48/include testme.c

But if the 'lib' directory is included, it breaks:

$ gcc -I./lib -I/opt/csw/bdb48/include testme.c
In file included from ./lib/unistd.h:112,
                 from /opt/csw/bdb48/include/db.h:29,
                 from testme.c:1:
./lib/getopt.h:197: error: redefinition of `struct option'

I can only assume that the redefinition of struct option comes from the other
getopt.h, but maybe I'm barking up the wrong tree here because I can't figure 
how that would be included in my build anyway:

$ grep getopt.h /usr/include/*.h /usr/include/*/*.h
/usr/include/getopt.h:#pragma ident     "@(#)getopt.h   1.1     04/03/29 SMI"

Can someone advise?  How do I get rid of this error?

Thanks in advance,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]