Opened 15 years ago

Closed 15 years ago

#396 closed defect (fixed)

Build failure on Mac OS 10.6

Reported by: James Aylett Owned by: Olly Betts
Priority: normal Milestone: 1.0.16
Component: Build system Version: 1.0.15
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: Mac OS X

Description (last modified by Olly Betts)

xapian-core has the following build error on Mac OS 10.6 (Snow Leopard):

 g++ -DHAVE_CONFIG_H -I. -I./common -I./include -Wall -W -Wredundant-decls      
-Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wformat-security       
-fno-gnu-keywords -Woverloaded-virtual -Wundef -Wshadow                         
-Wstrict-null-sentinel -Wshadow -Wstrict-overflow=1 -fvisibility=hidden -g      
-O2 -MT common/getopt.lo -MD -MP -MF common/.deps/getopt.Tpo -c                 
common/getopt.cc  -fno-common -DPIC -o common/.libs/getopt.o                    
In file included from                                                           
/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/os_defines.h:61,         
                 from                                                           
/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64/bits/c++config.h:41,          
                 from /usr/include/c++/4.2.1/cstring:50,                        
                 from common/getopt.cc:164:                                     
common/getopt.cc:84: error: previous declaration of ‘char* optarg’ with         
‘C++’ linkage                                                                   
/usr/include/unistd.h:515: error: conflicts with new declaration with ‘C’       
linkage                                                                         
common/getopt.cc:99: error: previous declaration of ‘int optind’ with ‘C++’     
linkage                                                                         
/usr/include/unistd.h:516: error: conflicts with new declaration with ‘C’       
linkage                                                                         
common/getopt.cc:119: error: previous declaration of ‘int opterr’ with ‘C++’    
linkage                                                                         
/usr/include/unistd.h:516: error: conflicts with new declaration with ‘C’       
linkage                                                                         
common/getopt.cc:125: error: previous declaration of ‘int optopt’ with ‘C++’    
linkage                                                                         
/usr/include/unistd.h:516: error: conflicts with new declaration with ‘C’       
linkage                                                                         
make[2]: *** [common/getopt.lo] Error 1                                         
make[1]: *** [all-recursive] Error 1                                            
make: *** [all] Error 2                                                         

Change History (5)

comment:1 by gstar, 15 years ago

Same problem for me. I managed to make it build by playing around with getopt.cc. I placed an extern "C" block around the communication between getopt and the caller (lines 84-126 in 1.0.15).

Not sure how correct this is, but it works for me for now.

comment:2 by Olly Betts, 15 years ago

Component: OtherBuild system
Description: modified (diff)
Milestone: 1.0.16
Status: newassigned

It's better to put the extern "C" in the header as that will also work on platforms which don't declare optarg, etc in their system headers.

Fixed in trunk r13431, though not tested as I don't have OS X.

If someone can confirm that fix works for 1.0.x, I'll backport it - the patch to common/gnu_getopt.h applies cleanly to 1.0.x too.

comment:3 by Tom, 15 years ago

Tried to build this, but got an error running bootstrap: ... -n Generating src/lang_cfg.h...

echo "char versionString[]=\"1.5.9\";" > src/version.cpp /usr/bin/make -C qtools env TMAKEPATH=/Users/maky/src/build/xapian/BUILD/doxygen-1.5.9/tmake/lib/macosx-c++ /usr/bin/perl /Users/maky/src/build/xapian/BUILD/doxygen-1.5.9/tmake/bin/tmake qtools.pro >Makefile.qtools /usr/bin/make -f Makefile.qtools all c++ -c -pipe -DFreeBSD=6 -DQT_NO_CODECS -DQT_LITE_UNICODE -Wall -W -O2 -I. -o ../objects/qbuffer.o qbuffer.cpp In file included from qiodevice.h:42,

from qbuffer.h:42, from qbuffer.cpp:38:

qglobal.h:90:6: error: #error "This version of Mac OS X is unsupported" make[2]: * objects/qbuffer.o Error 1 make[1]: * [all] Error 2 make: * [all] Error 2 Bootstrap failed

Looking into it.

comment:4 by Tom, 15 years ago

However, Olly's patch applied to 1.0.15 builds fine.

comment:5 by Olly Betts, 15 years ago

Resolution: fixed
Status: assignedclosed

The error is doxygen failing to build, which is really someone else's problem - it looks like doxygen uses Qt source code which hard codes a case for each version of OS X it knows about...

It's unfortunate if you can't bootstrap from SVN on OS X at present, but at least we can fix this getopt issue so that releases build out of the box for users.

Backported for 1.0.16 as r13437.

Note: See TracTickets for help on using tickets.