Re: Using SWIG for C++ to Python - ld problem
Nathan Sullivan wrote:
Stuart I Reynolds <S.I.Reynolds@cs.bham.ac.uk> writes:
Everthing seems to work fine up until...
% ld -shared *.o libgcc.a libg++.a libstc++.a -o mc.so ld: fatal: option -h and building a dynamic executable are incompatible ld: fatal: Flags processing errors
...which I seem to get whatever I do whenever I include any of my new .o files.
As you can probably tell, I'm using g++ (2.8) under Solaris.
Check your $PATH. You're running either /usr/ucb/ld or /usr/ccs/bin/ld, neither of which support the -shared option. That's apparently a GNU ld exclusive. If you don't have GNU ld, you'll either need to get it or figure out the proper options to /usr/ccs/bin/ld.
OK, you don't have to figure out the proper options to /usr/ccs/bin/ld, because I just did. :) The -G option tells the linker to create a shared object. So, replace -shared with -G, and it should work.
Aha. That works... thank a lot. (I should've read the manual - doh! Or g++ should've complained!!). Almost there. Now I'm using: % swig -python -shadow -stat -c++ mc.i % g++ -shared -c *.cpp *.cc *.c \ -I /bham/ums/common/pd/packages/Python/include/python1.5/ \ -I/bham/ums/solaris/pd/packages/Python/include/python1.5/ % ld -G -o MCcmodule.so \ /bham/pd/packages/gcc-2.8.0/lib/libg++.a \ /bham/pd/packages/gcc-2.8.0/lib/gcc-lib/sparc-sun-solaris2.6/2.8.0/libgcc.a \ *.o Which seems to work without errors. Now running Python I get:
import MC Traceback (innermost last): File "<stdin>", line 1, in ? File "MC.py", line 2, in ? import MCc ImportError: ld.so.1: python: fatal: relocation error: file ./MCcmodule.so: symbol __builtin_new: referenced symbol not found.
I take it "__builtin_new" is in one of the C++ libraries. I've include the c++ libraries libg++.a and libgcc.a because that's what the SWIG manual says. However, we don't seem to have libstc++.a on our system. What's in it / is it the problem? Ideas?? Stuart SWIG Python page http://www.swig.org/Doc1.1/Python.html#n4
participants (1)
-
Stuart I Reynolds