From: <ol...@us...> - 2009-06-30 14:26:39
|
Revision: 11334 http://swig.svn.sourceforge.net/swig/?rev=11334&view=rev Author: olly Date: 2009-06-30 12:24:49 +0000 (Tue, 30 Jun 2009) Log Message: ----------- Use -O2 in the GCC examples as GCC defaults to not optimising at all. Document using GCC's -fPIC option as the standard approach - x86 is the oddity here and most architectures require it (or are always PIC), and on x86 it's better to use it or else code pages from the library need relocations and can't be shared. Use "python2.5" rather than "python2.0" in paths in example commands. Fix a typo. Modified Paths: -------------- trunk/Doc/Manual/Python.html Modified: trunk/Doc/Manual/Python.html =================================================================== --- trunk/Doc/Manual/Python.html 2009-06-30 11:50:14 UTC (rev 11333) +++ trunk/Doc/Manual/Python.html 2009-06-30 12:24:49 UTC (rev 11334) @@ -339,7 +339,7 @@ setup.py is the tradition) <li> <tt>build_ext</tt> -- telling distutils to build extensions <li> <tt>--inplace</tt> -- this tells distutils to put the extension lib in the current dir. - Other wise, it will put it inside a build hierarchy, and you'd have to move it to use it. + Otherwise, it will put it inside a build hierarchy, and you'd have to move it to use it. </ul> <p> @@ -363,8 +363,8 @@ <div class="shell"><pre> $ swig -python example.i -$ gcc -c -fPIC example.c -$ gcc -c -fPIC example_wrap.c -I/usr/local/include/python2.0 +$ gcc -O2 -fPIC -c example.c +$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/include/python2.5 $ gcc -shared example.o example_wrap.o -o _example.so </pre></div> @@ -654,26 +654,19 @@ <div class="shell"><pre> $ swig -c++ -python example.i -$ g++ -c example.cxx -$ g++ -c example_wrap.cxx -I/usr/local/include/python2.0 +$ g++ -O2 -fPIC -c example.cxx +$ g++ -O2 -fPIC -c example_wrap.cxx -I/usr/local/include/python2.5 $ g++ -shared example.o example_wrap.o -o _example.so </pre></div> <p> -On some platforms, you could also need to generate -position-independent code (PIC), by using a compiler option such as -fPIC. -Notably, the x86_64 (Opteron and EM64T) platform requires it, and when -using the GNU Compiler Suite, you will need to modify the previous example -as follows: +The -fPIC option tells GCC to generate position-independent code (PIC) +which is required for most architectures (it's not vital on x86, but +still a good idea as it allows code pages from the library to be shared between +processes). Other compilers may need a different option specified instead of +-fPIC. </p> -<div class="shell"><pre> -$ swig -c++ -python example.i -$ g++ -fPIC -c example.cxx -$ g++ -fPIC -c example_wrap.cxx -I/usr/local/include/python2.0 -$ g++ -shared example.o example_wrap.o -o _example.so -</pre></div> - <p> In addition to this, you may need to include additional library files to make it work. For example, if you are using the Sun C++ compiler on @@ -683,7 +676,7 @@ <div class="shell"><pre> $ swig -c++ -python example.i $ CC -c example.cxx -$ CC -c example_wrap.cxx -I/usr/local/include/python2.0 +$ CC -c example_wrap.cxx -I/usr/local/include/python2.5 $ CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o _example.so -lCrun </pre></div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |