I've just started using SWIG to port link a C++ class I have to Python. I don't mind saying, its harder than it looks. % swig -python -shadow mc.i Generating wrappers for Python % g++ -shared -c krandom.cpp #Some dull C functions % g++ -shared -c mc.cpp #Class definition % g++ -shared -c mc_wrap.c \ #Auto generated -I/bham/ums/common/pd/packages/Python/include/python1.5/ \ -I/bham/ums/solaris/pd/packages/Python/include/python1.5/ 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. There's more info. below for anyone who's suitably interested by now. Any advice welcome. Cheers, Stu ---mc.i--- %module MC %{ #include "mc.h" %} enum ACTION {coast, forward, backward}; class mcar { public: mcar(); double random_pos(); double random_vel(); double reward(); double curr_pos(); double curr_vel(); void set_curr_pos(double pos); void set_curr_vel(double vel); ACTION int_to_act(int action); ACTION choose_random_act(); void update_position_velocity(ACTION a); int reached_goal(); private: double v; double p; }; ---mc.i--- ---mc.h---- class mcar { public: ... some get and setter functions and a constructor with no args - very uninteresting indeed! ... private: double v, p; // current state = velocity and position }; ------------- PS. Does Python recognise .a files (created with ar rather than ld - and what's the difference??)
participants (1)
-
Stuart I Reynolds