[C++-sig] Mac OS 10 success
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Wed May 21 03:43:47 CEST 2003
For the records:
Based on the work done earlier by Rene Rivera and Nick Sauter I've been
able to successfully port all our Boost.Python bindings to Mac OS 10.2.
I am using:
- Python 2.3b1 as a "framework installation"
- gcc 3.3 compiled from sources
- Boost 1.30.0 with a few small patches
The Boost patches are attached. Strictly speaking it is probably
"wrong" to simply disable the static assertions in type_with_alignment.hpp,
but all our regression tests pass anyway. The patch for
as_to_python_function.hpp disables another static assertion that is
probably not critical. The patch for wrap_python.hpp is for Python 2.3
compatibility.
Python 2.3b1 was installed with the commands:
./configure --enable-framework
make
make frameworkinstall
gcc 3.3 was installed with the commands:
./configure --prefix=/usr/local/gcc-3.3 --enable-languages=c,c++
make bootstrap
make
make install
This installation does not interfere with the compiler provided
by Apple. We source the following script before compiling:
set path=(/usr/local/gcc-3.3/bin $path)
set addl_libpath=/usr/local/gcc-3.3/lib:/usr/local/gcc-3.3/lib/soft-float
if ( $?DYLD_LIBRARY_PATH ) then
setenv DYLD_LIBRARY_PATH "$addl_libpath:${DYLD_LIBRARY_PATH}"
else
setenv DYLD_LIBRARY_PATH "$addl_libpath"
endif
unset addl_libpath
Initially g++ stopped with an Internal Compiler Error while compiling
some of our Boost.Python bindings. A workaround is to first preprocess
the sources using the -E compiler option and redirecting the output to
a new file. Then compile the preprocessed file. In my case this worked
for everything except one file; fortunately that one file compiles the
normal way. Phew.
Here is my little script that does the trick:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/libtbx/libtbx/command_line/mac_os_x_cpp.py?rev=1.1&content-type=text/vnd.viewcvs-markup
Instead of "g++" specify the name of the script; arguments are what
you would normally pass to g++ for compiling.
Linking libboost_python.dylib is a two-step process. Here is how
I do it:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/libtbx/libtbx/command_line/mac_os_x_ld_bpl_dll.csh?rev=1.1&content-type=text/vnd.viewcvs-markup
Linking extension modules is less complicated:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/libtbx/libtbx/command_line/mac_os_x_ld_pyd.csh?rev=1.1&content-type=text/vnd.viewcvs-markup
The last problem I had to deal with was unresolved symbols while
linking certain extension modules (only 3 out of 29). It turned
out that these were the only modules that did not make use of
boost::python::class_. To fix the unresolved symbol errors I
added a dummy class_ instance, e.g.:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cctbx/cctbx/sgtbx/boost_python/row_echelon.cpp?rev=1.3&content-type=text/vnd.viewcvs-markup
Look for "dummy"
That's it. Easy!
Well, while writing this I am running a compilation with -O3 instead of
-O0 and evidently the Internal Compiler Errors creep up in different
places. But at least it works with -O0.
Ralf
Index: boost/python/converter/as_to_python_function.hpp
===================================================================
RCS file:
/net/cci/cvs/boost_1_30_0_cci/boost/python/converter/as_to_python_function.hpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -r1.1.1.1 -r1.2
27a28
> #if !(defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ == 3)
31a33
> #endif
Index: boost/python/detail/wrap_python.hpp
===================================================================
RCS file: /net/cci/cvs/boost_1_30_0_cci/boost/python/detail/wrap_python.hpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -r1.1.1.1 -r1.2
160a161,164
>
> #if defined(PY_LONG_LONG) && !defined(LONG_LONG)
> #define LONG_LONG PY_LONG_LONG
> #endif
Index: boost/type_traits/type_with_alignment.hpp
===================================================================
RCS file:
/net/cci/cvs/boost_1_30_0_cci/boost/type_traits/type_with_alignment.hpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -r1.1.1.1 -r1.2
108a109,110
> #if !(defined(__APPLE__) && defined(__MACH__) \
> && defined(__GNUC__) && __GNUC__ == 3 && __GNUC_MINOR__ == 3)
110a113
> #endif
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
More information about the Cplusplus-sig
mailing list