Bug #34094 Compile fails on Solaris 9 using gcc
Submitted: 27 Jan 2008 19:57 Modified: 5 May 2008 19:01
Reporter: Hakan Küçükyılmaz Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Archive storage engine Severity:S3 (Non-critical)
Version:mysql-6.0-falcon-team OS:Solaris (9)
Assigned to: Hakan Küçükyılmaz CPU Architecture:Any

[27 Jan 2008 19:57] Hakan Küçükyılmaz
Description:
Compile fails on Solaris 9 with latest mysql-6.0-falcon-team tree using gcc.

How to repeat:
BUILD/compile-solaris-sparc-debug

if gcc -DHAVE_CONFIG_H -I. -I. -I../../include -I../../include -I../../include -I../../regex -I../../sql -I.    -DHAVE_MYSQL_CONFIG_H  -g  -DSAFE_MUTEX -g -Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare -Wwrite-strings -Wunused  -O3 -fno-omit-frame-pointer   -D_FILE_OFFSET_BITS=64 -DHAVE_RWLOCK_T -DUNIV_SOLARIS -MT concurrency_test-concurrency_test.o -MD -MP -MF ".deps/concurrency_test-concurrency_test.Tpo" -c -o concurrency_test-concurrency_test.o `test -f 'concurrency_test.c' || echo './'`concurrency_test.c; \
then mv -f ".deps/concurrency_test-concurrency_test.Tpo" ".deps/concurrency_test-concurrency_test.Po"; else rm -f ".deps/concurrency_test-concurrency_test.Tpo"; exit 1; fi
concurrency_test.c:16:20: getopt.h: No such file or directory
make[2]: *** [concurrency_test-concurrency_test.o] Error 1
make[2]: Leaving directory `/home/hakan/work/mysql/wfto/mysql-6.0.5-alpha/storage/archive'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/hakan/work/mysql/wfto/mysql-6.0.5-alpha/storage'
make: *** [all-recursive] Error 1

Suggested fix:
getopt() is in stdio.h or unistd.h:

  SVID3, XPG3
     #include <stdio.h>

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

  POSIX.2, XPG4, SUS, SUSv2
     #include <unistd.h>

     int getopt(int argc, char * const argv[], const  char  *opt-
     string);
     extern char *optarg;
     extern int optind, opterr, optopt;
[2 Feb 2008 7:34] Hakan Küçükyılmaz
Fix is to remove #include <getopt.h> from storage/archive/concurrency_test.c. concurrency_test.c include my_getopt.h and getopt.h. One getopt should be enough.

/*
  Just a test application for threads.
  */
#include "azio.h"
#include <mysql.h>
#include <my_getopt.h>
#include <mysql_version.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/time.h>
#include <getopt.h>
[8 Apr 2008 15:35] Hakan Küçükyılmaz
Already fixed by

storage/archive/concurrency_test.c 1.1.1.1 2007/12/05 11:32:21 jperkin@mysql.com
  Do not include getopt.h
[9 Apr 2008 15:59] Jon Stephens
In which release(s) did the referenced fix become available; we need relevant 3-part version number(s) for the changelog. Thanks!
[17 Apr 2008 9:09] Hakan Küçükyılmaz
6.0.5
[5 May 2008 19:01] Paul DuBois
Noted in 6.0.5 changelog.

Compilation failed on Solaris for the ARCHIVE storage engine due to
inclusion of getopt.h in the ARCHIVE code.