Apologies for the long message---I've really tried to be precise and complete.
I've had some time and access to a solaris box today to try to deal with this issue. I think I've solved it, based on a hint from David Kirkby.
On 7/7/10 10:23 AM, Jason Grout wrote:
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/scratch/grout/sage-4.5.3/local/lib/python2.6/site-packages/numpy/core/include -I/scratch/grout/sage-4.5.3/local/include -I. -I/scratch/grout/sage-4.5.3/local/lib/python2.6/site-packages/numpy/core/include -Isrc -Iagg24/include -I. -I/scratch/grout/sage-4.5.3/local/lib/python2.6/site-packages/numpy/core/include -I/scratch/grout/sage-4.5.3/local/include/freetype2 -I/scratch/grout/sage-4.5.3/local/include -I. -I/scratch/grout/sage-4.5.3/local/include/python2.6 -c src/backend_agg.cpp -o build/temp.solaris-2.10-sun4v-2.6/src/backend_agg.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
In file included from /scratch/grout/sage-4.5.3/local/include/python2.6/Python.h:8,
/scratch/grout/sage-4.5.3/local/include/python2.6/pyconfig.h:1013:1: warning: "_FILE_OFFSET_BITS" redefined
In file included from /usr/include/sys/types.h:18,
/usr/local/gcc-4.4.1-sun-linker/bin/../lib/gcc/sparc-sun-solaris2.10/4.4.1/include-fixed/sys/feature_tests.h:197:1: warning: this is the location of the previous definition
In file included from /scratch/grout/sage-4.5.3/local/include/python2.6/Python.h:42,
/usr/include/stdlib.h:144: error: declaration of C function 'void swab(const char*, char*, ssize_t)' conflicts with
/usr/include/unistd.h:496: error: previous declaration 'void swab(const void*, void*, ssize_t)' here
error: command 'gcc' failed with exit status 1
This was reportedly fixed in 1.0.0, but apparently the fix does not work for this Solaris box.
Based on a hint from David Kirkby, I changed the CXX/WrapPython.h file to be:
// On some platforms we have to include time.h to get select defined
#if !defined(__WIN32__) && !defined(WIN32) && !defined(_WIN32) && !defined(_WIN64)
// pull in python definitions
(in other words, I just deleted all the defining and undefining of variables). The resulting matplotlib compiled finally, and the result of the testing was:
In : import matplotlib
In : matplotlib.__version__
In : matplotlib.test()
/scratch/grout/sage-4.5.3/local/lib/python2.6/site-packages/matplotlib/axes.py:2369: UserWarning: Attempting to set identical left==right results
in singular transformations; automatically expanding.
+ 'left=%s, right=%s') % (left, right))
Ran 138 tests in 755.419s
so I guess that means everything works.
I also compiled it on Ubuntu 10.04 (64-bit) and OSX 10.6.4, and it seemed to compile fine on those systems, though on OSX 10.6.4, I got some warnings like:
/home/grout/sage/local/include/python2.6/pyconfig.h:1028:1: warning: "_POSIX_C_SOURCE" redefined
/home/grout/sage/local/include/python2.6/pyconfig.h:1037:1: warning: "_XOPEN_SOURCE" redefined
This brings up another issue: going against the Python API
As you probably already know, http://docs.python.org/c-api/intro.html#includes says that:
"Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included."
I notice a lot of other #undef statements for _POSIX_C_SOURCE and _XOPEN_SOURCE in matplotlib code. To my (uneducated) eyes, that seems like a recipe for trouble, since defining it one way while including some other files, and then undefining the macros and defining them a different way may lead to problems.
For example, in _png.cpp, I see:
// To remove a gcc warning
According to the Python API, we should include python.h before including png.h.