Solaris 2.7 make won't make at getopt.cpp

Help
2001-03-22
2001-04-03
  • Brian Tingle
    Brian Tingle
    2001-03-22

    [lots of make output deleted]
    make[1]: Entering directory `/tmp/gsdl/src/mgpp'
    for subdir in lib text; do \   echo making all in $subdir; \   (cd $subdir && make  all) || exit 1; \ done
    making all in lib
    make[2]: Entering directory `/tmp/gsdl/src/mgpp/lib'
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus mgheap.cpp
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus memlib.cpp
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus huffman.cpp
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus messages.cpp
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus bitio_gen.cpp
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus perf_hash.cpp
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus getopt.cpp
    gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus getopt1.cpp
    getopt1.cpp: In function `int getopt_long(int, char *const *, const char *, const option *, int)':
    getopt1.cpp:58: passing `int' to argument 5 of `_getopt_internal(int, char *const *, const char *, const option *, int *, int)' lacks a cast
    make[2]: *** [getopt1.o] Error 1
    make[2]: Leaving directory `/tmp/gsdl/src/mgpp/lib'
    make[1]: *** [all] Error 1
    make[1]: Leaving directory `/tmp/gsdl/src/mgpp'
    make: *** [all] Error 1

    akkri 194: gcc -v
    Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.3/specs
    gcc version 2.95.3 20010315 (release)

    Any ideas??

    -- Brian Tingle
       Development Programmer, California Digital Library
       brian.tingle@ucop.edu
       (510)987-0443

     
    • Brian Tingle
      Brian Tingle
      2001-03-23

      I changed src/mgpp/lib/getopt1.cpp line 56 from:
                   const struct option *long_options, int opt_index)
      to:
                   const struct option *long_options, int *opt_index)

      and the cast error went away, now I'm getting

      [stuff deleted]
      making all in text
      make[2]: Entering directory `/tmp/gsdl/src/mgpp/text'
      c++ -c -DHAVE_CONFIG_H   -I../../.. -I../lib -I. -ansi -Wall -Wunused -pedantic -W -Woverloaded-virtual -g -DSILENT -DSHORT_SUFFIX -O2 -ansi -Wall -Wunused -pedantic -W -Woverloaded-virtual -g  -DSILENT -DSHORT_SUFFIX -D__cplusplus mg_passes.cpp
      In file included from mg_passes.cpp:34:
      ../lib/longlong.h:62: warning: ANSI C++ does not support `long long'
      ../lib/longlong.h:63: warning: ANSI C++ does not support `long long'
      mg_passes.cpp: In function `int main(int, char **)':
      ../lib/getopt.h:105: too many arguments to function `int getopt()'
      mg_passes.cpp:214: at this point in file

       
      • John McPherson
        John McPherson
        2001-03-23

        The first problem looks like a typo. Updated.

        I'm not too sure about the 2nd. We are using a GNU getopt.h - if you're not using the GNU C library,
        it just prototypes with "int getopt()", which might be conflicting with your system header. I would have
        thought that gcc would be backwards compatible, although I noticed you're using the newest 2.95-3.

        Could you please send the output of the command
        "gcc -dM -xc -E /dev/null" (this just lists all the predefined macros)

        Does /usr/include/features.h exist, and define __GNU_LIBRARY__ ? I suspect not if it is Sun's headers. The file  src/mgpp/lib/sysfuncs.h includes
        <getopt.h>, so you could try renaming our getopt.h out of the way, and see if it includes your system getopt.h instead.

        Let us know how you get on...

        John McPherson.

         
        • Brian Tingle
          Brian Tingle
          2001-03-23

          Answers to your questions:

          akkri 34: gcc -dM -xc -E /dev/null
          #define __GCC_NEW_VARARGS__ 1
          #define __sparc 1
          #define __svr4__ 1
          #define __GNUC_MINOR__ 95
          #define __sun 1
          #define sparc 1
          #define __sun__ 1
          #define __unix 1
          #define __unix__ 1
          #define __SVR4 1
          #define sun 1
          #define __GNUC__ 2
          #define __sparc__ 1
          #define unix 1

          /usr/include/features.h does not exist.

          with getopt.h mv'ed out of the way
          [...]
          make[1]: Entering directory `/tmp/gsdl/src/mgpp'
          for subdir in lib text; do \   echo making all in $subdir; \   (cd $subdir && make  all) || exit 1; \ done
          making all in lib
          make[2]: Entering directory `/tmp/gsdl/src/mgpp/lib'
          gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus mgheap.cpp
          gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus memlib.cpp
          In file included from memlib.cpp:49:
          sysfuncs.h:302: getopt.h: No such file or directory
          make[2]: *** [memlib.o] Error 1
          make[2]: Leaving directory `/tmp/gsdl/src/mgpp/lib'
          make[1]: *** [all] Error 1
          make[1]: Leaving directory `/tmp/gsdl/src/mgpp'
          make: *** [all] Error 1

          I installed the glib-1.2.3-sol7-sparc-local package from sunfreeware.com before I
          got your answer because I saw the bit about __GNU_LIBRARY__ in getopt.h and it
          did not make a difference.

          from man -s 3c getopt, it looks like its header file is stdlib.h, and there does not seem to be another getopt.h on my machine.

          I removed getopt.h from src/mgpp/lib/sysfuncs.h
          [...]
          gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus messages.cpp
          gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus bitio_gen.cpp
          gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus perf_hash.cpp
          gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus getopt.cpp
          getopt.cpp:76: getopt.h: No such file or directory
          make[2]: *** [getopt.o] Error 1
          make[2]: Leaving directory `/tmp/gsdl/src/mgpp/lib'
          make[1]: *** [all] Error 1
          make[1]: Leaving directory `/tmp/gsdl/src/mgpp'
          make: *** [all] Error 1

          I removed getopt.h from src/mgpp/lib/getopt.cpp
          making all in lib
          make[2]: Entering directory `/tmp/gsdl/src/mgpp/lib'
          gcc -c -DHAVE_CONFIG_H -I../../.. -I.  -O2 -ansi -D__cplusplus getopt.cpp
          getopt.cpp: In function `int _getopt_internal(int, char *const *, const char *, const option *, int *, int)':
          getopt.cpp:457: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:458: cannot increment a pointer to incomplete type `const option'
          getopt.cpp:459: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:461: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:498: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:508: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:513: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:519: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:535: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:537: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:537: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          getopt.cpp:540: invalid use of undefined type `struct option'
          getopt.cpp:324: forward declaration of `struct option'
          make[2]: *** [getopt.o] Error 1
          make[2]: Leaving directory `/tmp/gsdl/src/mgpp/lib'
          make[1]: *** [all] Error 1
          make[1]: Leaving directory `/tmp/gsdl/src/mgpp'
          make: *** [all] Error 1

          Thanks for your quick responce.  Please let me know if you have any other ideas of
          things to try.  Maybe my gcc does not know I have the gnu library installed?

           
          • John McPherson
            John McPherson
            2001-03-23

            Re-reading the docs, it looks like including unistd.h defines getopt,
            if posix.2 functions are used.

            On linux, the headers files are split up, so there is a separate getopt.h,
            but this gets included if you include unistd.h, which is where getopt
            should be defined.

            Anyway, if you modify our getopt.h file at around 105 so that the
            prototype is something like:
            extern int getopt (int argc, char *const argv[], const char *optstring);
            or whatever man -s 3c getopt says the function is.

            I think the problem is actually that gcc-2.95.3 is assuming that
            our forward prototype getopt() implies getopt(void), which older
            versions of gcc didn't assume. (This is a guess).

            Let me know if this doesn't fix your compilation problem.

            John

             
    • Brian Tingle
      Brian Tingle
      2001-03-23

      copying the getopt bit from man -3c getopt to your getopt.h solved the last problem;

      now,
      [...]
      c++ -c  -O2 -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DHAVE_CONFIG_H -I../../lib -I. -I../colservr -I../../packages/mg -I../../packages/mg/lib -I../../packages/mg/src/text -I../mgpp/lib -I../mgpp/text historydb.cpp
      c++ -c  -O2 -DNZDL -DQUIET -DSHORT_SUFFIX -DPARADOCNUM -DHAVE_CONFIG_H -I../../lib -I. -I../colservr -I../../packages/mg -I../../packages/mg/lib -I../../packages/mg/src/text -I../mgpp/lib -I../mgpp/text collectoraction.cpp
      collectoraction.cpp: In method `bool collectoraction::init(ostream &)':
      collectoraction.cpp:255: `buf' undeclared (first use this function)
      collectoraction.cpp:255: (Each undeclared identifier is reported only once
      collectoraction.cpp:255: for each function it appears in.)
      collectoraction.cpp:255: parse error before `('
      make[1]: *** [collectoraction.o] Error 1
      make[1]: Leaving directory `/tmp/gsdl/src/recpt'
      make: *** [all] Error 1

         251  #if defined (__WIN32__)
         252    gsdlos = "windows";
         253    path_separator = ';';
         254  #else
         255    utsname *buf = new utsname();
         256    int i = uname (buf);
         257    if (i == -1) gsdlos = "linux"; // uname failed
         258    else gsdlos.setcstr (buf->sysname);
         259    delete buf;
         260    lc (gsdlos);
         261  #endif

       
      • Brian Tingle
        Brian Tingle
        2001-04-03

        okay, no responce to the above, so I just commented out all the
        utsname uname junk and said
        gsdlos = "SunOS";

        now,

        making all in src/getpw
        make[1]: Entering directory `/tmp/gsdl/src/getpw'
        gcc -c -DHAVE_CONFIG_H  -Wall -O2  getpw.cpp
        getpw.cpp: In function `int main(int, char **)':
        getpw.cpp:53: implicit declaration of function `int getpass(...)'
        getpw.cpp:53: initialization to `char *' from `int' lacks a cast
        getpw.cpp:60: initialization to `char *' from `int' lacks a cast
        getpw.cpp:66: implicit declaration of function `int crypt(...)'
        getpw.cpp:66: initialization to `char *' from `int' lacks a cast
        make[1]: *** [getpw.o] Error 1
        make[1]: Leaving directory `/tmp/gsdl/src/getpw'
        make: *** [all] Error 1

         
        • John McPherson
          John McPherson
          2001-04-03

          I don't know about the utsname stuff, I might look into it when I have some more spare time, but
          try setting gsdlos = "sunos" (lowercase).

          Anyway, the problem with getpass/crypt seems to be with the header files on solaris. I thought
          defining _XOPEN_SOURCE was enough, but the header file also checks the version as well. So, ...

          under Solaris, we need to have both _XOPEN_SOURCE defined, and _XOPEN_SOURCE_EXTENDED (which I missed),
          so add "#define _XOPEN_SOURCE_EXTENDED 1" to the getpw.cpp file. If that doesn't work, try
          commenting out the lines
          /*
          #if defined(HAVE_CRYPT_H)
          #include <crypt.h>
          #else
          */
          and the first /* #endif */ as well.

          Let me know if this doesn't fix it.
          John.
          jrm21@cs.waikato.ac.nz

           
        • Brian Tingle
          Brian Tingle
          2001-04-03

          in gsdl/src/getpw/getpw.cpp,

          I deleted the first chuck of
          #if stuff, up to #endif\n#endif, and put in

          #include <crypt.h>
          #inculde <stdlib.h>

          and it all compiles now!