Menu

#161 FreeBSD getopt() prototype not detected by configure

open
5
2005-02-26
2005-02-26
No

When building the GTK+ user interface on FreeBSD, you
get the following error:

if g++ -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\"
-DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"VisualBoyAdvance\"
-DVERSION=\"1.8.0\" -DYYTEXT_POINTER=1 -DHAVE_LIBZ=1
-DHAVE_LIBPTHREAD=1 -DSTDC_HEADERS=1
-DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRINGS_H=1
-DHAVE_UNISTD_H=1 -DHAVE_ARPA_INET_H=1
-DHAVE_NETINET_IN_H=1 -I. -I.
-DPKGDATADIR=\"/usr/X11R6/share/VisualBoyAdvance\"
-DLOCALEDIR=\"/usr/X11R6/share/locale\"
-DGETTEXT_PACKAGE=\"vba-1.8.0\" -DGTKMM20
-I/usr/local/include/libpng -DXTHREADS
-DXUSE_MTSAFE_API -I/usr/local/lib/sigc++-1.2/include
-I/usr/local/include/sigc++-1.2
-I/usr/local/include/glib-2.0
-I/usr/local/lib/glib-2.0/include
-I/usr/local/include/atk-1.0
-I/usr/local/include/libxml2 -I/usr/local/include
-I/usr/X11R6/include/gtkmm-2.0
-I/usr/X11R6/lib/gtkmm-2.0/include
-I/usr/X11R6/include/gtk-2.0
-I/usr/X11R6/lib/gtk-2.0/include -I/usr/X11R6/include
-I/usr/X11R6/include/pango-1.0
-I/usr/local/include/freetype2
-I/usr/X11R6/include/libglademm-2.0
-I/usr/X11R6/lib/libglademm-2.0/include
-I/usr/X11R6/include/libglade-2.0
-I/usr/local/include/SDL11 -I/usr/local/include
-D_REENTRANT -I/usr/local/include -I/usr/X11R6/include
-DPROFILING -DMMX -MT gvba-main.o -MD -MP -MF
".deps/gvba-main.Tpo" \ -c -o gvba-main.o `test -f 'main.cpp' || echo
'./'`main.cpp; \ then mv -f ".deps/gvba-main.Tpo" ".deps/gvba-main.Po"; \ else rm -f ".deps/gvba-main.Tpo"; exit 1; \ fi
In file included from
/usr/include/c++/3.4/bits/gthr-default.h:44,
from /usr/include/c++/3.4/bits/gthr.h:96,
from /usr/include/c++/3.4/bits/c++io.h:37,
from /usr/include/c++/3.4/iosfwd:47,
from
/usr/include/c++/3.4/bits/stl_algobase.h:70,
from /usr/include/c++/3.4/list:67,
from main.cpp:23:
/usr/include/unistd.h:376: error: declaration of C
function `int getopt(int, char* const*, const char*)'
conflicts with
../getopt.h:115: error: previous declaration `int
getopt()' here

I assume that HAVE_DECL_GETOPT is set incorrectly and
further assume that configure is what should set it.

Discussion

  • Stephen James Hurd

    Logged In: YES
    user_id=168633

    Note: If prototype in getopt.h is commented out, it builds
    and runs.

     
  • Forgotten

    Forgotten - 2005-02-27

    Logged In: YES
    user_id=335241

    Try changing the code in gtk/main.cpp to:

    #ifdef HAVE_DECL_GETOPT
    #include <getopt.h>
    #else
    #include "../getopt.h"
    #endif

     
  • Stephen James Hurd

    Logged In: YES
    user_id=168633

    Yes, that change makes it build successfully.

     
  • Stephen James Hurd

    Logged In: YES
    user_id=168633

    Sorry, that does NOT fix it, I had left my kludge in-place.

     
  • Forgotten

    Forgotten - 2005-03-01

    Logged In: YES
    user_id=335241

    Try something like this:

    #ifdef HAVE_UNISTD_H
    #include <unistd.h>
    #else
    #include "../getopt.h"
    #endif

    It should be something like this. I cannot help you because
    that depends on your computer. See what fixes it like the
    above and let us know.

     
  • Stephen James Hurd

    Logged In: YES
    user_id=168633

    But that's just masking the problem, not fixing it... in
    getopt.h, it explains starting at line 103 that
    HAVE_DECL_GETOPT should be checked for by autoconf to
    support building on systems that don't use the GNU C
    library. Otherwise, a slightly less incorrect kludge would
    be to simply add -DHAVE_DECL_GETOPT=1 to CFLAGS in the
    makefile. A kludge that would be slight less incorrect that
    that would be to simply remove the getopt() declaration if
    it hasn't been checked for (ie: simply remove lines 114-116
    from src/getopt.h) or even make the declaration in there
    always happen... since without checking for it, the included
    getopt.c is always built for non GNU C library installs anyways.

     

Log in to post a comment.