diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 08c80c83a..c1b42f605 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -332,8 +332,8 @@ Assuming you have code you need to link to in a file called example.c,
 $ swig -java example.i
-$ gcc -c example_wrap.c  -I/usr/java/include -I/usr/java/include/solaris
-$ gcc -c example.c
+$ gcc -fPIC -c example_wrap.c -I/usr/java/include -I/usr/java/include/solaris
+$ gcc -fPIC -c example.c
 $ ld -G example_wrap.o example.o -o libexample.so
 
@@ -493,8 +493,7 @@ compiler. For example:
 % swig -c++ -java example.i
 % g++ -c -fpic example.cxx
-% g++ -c -fpic example_wrap.cxx -I/usr/java/j2sdk1.4.1/include -I/usr/java/
-j2sdk1.4.1/include/linux
+% g++ -c -fpic example_wrap.cxx -I/usr/java/j2sdk1.4.1/include -I/usr/java/j2sdk1.4.1/include/linux
 % g++ -shared example.o example_wrap.o -o libexample.so
 
diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 88d26f385..aab6a2ceb 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -240,8 +240,8 @@ Most, but not all platforms support the dynamic loading of modules (Windows &

 $ swig -lua example.i -o example_wrap.c
-$ gcc -I/usr/include/lua -c example_wrap.c -o example_wrap.o
-$ gcc -c example.c -o example.o
+$ gcc -fPIC -I/usr/include/lua -c example_wrap.c -o example_wrap.o
+$ gcc -fPIC -c example.c -o example.o
 $ gcc -shared -I/usr/include/lua -L/usr/lib/lua example_wrap.o example.o -o example.so
 

diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index db8c0e602..9e577b08b 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -493,8 +493,8 @@ Solaris, you often need to add an extra library -lCrun like this:

 $ swig -c++ -perl example.i
-$ CC -c example.cxx
-$ CC -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
+$ CC -Kpic -c example.cxx
+$ CC -Kpic -c example_wrap.cxx -I/usr/lib/perl/5.14/i386-linux/CORE
 $ CC -shared example.o example_wrap.o -o example.so -lCrun
 
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 301631a20..6ff98ca23 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -259,14 +259,22 @@ operating system would look something like this:

$ swig -ruby example.i
-$ gcc -c example.c
-$ gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
+$ gcc -O2 -fPIC -c example.c
+$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
 $ gcc -shared example.o example_wrap.o -o example.so
 
-

For other platforms it may be necessary to compile with the -fPIC -option to generate position-independent code. If in doubt, consult the +

+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. +

+ +

+If in doubt, consult the manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

@@ -325,8 +333,8 @@ using the C++ compiler. For example:

 $ swig -c++ -ruby example.i
-$ g++ -c example.cxx
-$ g++ -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
+$ g++ -fPIC -c example.cxx
+$ g++ -fPIC -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
 $ g++ -shared example.o example_wrap.o -o example.so
 
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index e0e7dbcaf..aa02b2dee 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -216,7 +216,7 @@ to use the C++ compiler. For example:
 $ swig -c++ -tcl example.i
-$ c++ -c example_wrap.cxx 
+$ c++ -fPIC -c example_wrap.cxx 
 $ c++ example_wrap.o $(OBJS) -o example.so
 
diff --git a/Doc/Manual/Scripting.html b/Doc/Manual/Scripting.html index 26a8dd017..c714fa0d7 100644 --- a/Doc/Manual/Scripting.html +++ b/Doc/Manual/Scripting.html @@ -368,17 +368,12 @@ for a few common platforms is shown below:

 # Build a shared library for Solaris
-gcc -c example.c example_wrap.c -I/usr/local/include
+gcc -fpic -c example.c example_wrap.c -I/usr/local/include
 ld -G example.o example_wrap.o -o example.so
 
 # Build a shared library for Linux
 gcc -fpic -c example.c example_wrap.c -I/usr/local/include
 gcc -shared example.o example_wrap.o -o example.so
-
-# Build a shared library for Irix
-gcc -c example.c example_wrap.c -I/usr/local/include
-ld -shared example.o example_wrap.o -o example.so
-
 

diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index e6b3b4a43..9b9cd7218 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -139,8 +139,8 @@ using commands like this (shown for Linux):

 $ swig -tcl example.i
-$ gcc -c example.c
-$ gcc -c example_wrap.c -I/usr/local/include
+$ gcc -fPIC -c example.c
+$ gcc -fPIC -c example_wrap.c -I/usr/local/include
 $ gcc -shared example.o example_wrap.o -o example.so
 
@@ -374,8 +374,8 @@ compiler. For example:
 % swig -c++ -tcl example.i
-% g++ -c example.cxx
-% g++ -c example_wrap.cxx -I/usr/local/include
+% g++ -fPIC -c example.cxx
+% g++ -fPIC -c example_wrap.cxx -I/usr/local/include
 % g++ -shared example.o example_wrap.o -o example.so
 
@@ -387,8 +387,8 @@ Solaris, you often need to add an extra library -lCrun like this:
 % swig -c++ -tcl example.i
-% CC -c example.cxx
-% CC -c example_wrap.cxx -I/usr/local/include
+% CC -KPIC -c example.cxx
+% CC -KPIC -c example_wrap.cxx -I/usr/local/include
 % CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o example.so -lCrun