[C++-sig] Cross module definition

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Wed Sep 3 20:47:27 CEST 2003


--- Arnaud PICARD <arnaud.picard at edfgdf.fr> wrote:
> If I import them under python, and define a = ModuleA.Cmplx( 1., 0. ), b =
> ModuleB.Printer(), and then try b.print1( a ) or b.print2( a ) it won't
> work.

It works here without a problem. The only change I made is to remove
define_Cmplx(); from Boost_B.cc. Any problems you have must be related
to how you compile and link. Here is how I did it under Redhat 8.0:

g++ -fPIC -ftemplate-depth-120 -w -DNDEBUG -O3 -I/net/cci/rwgk/dist/boost
-I/usr/include/python2.2 -c -o sandbx/cross_module_problem/Boost_A.os
/net/cci/rwgk/dist/sandbx/cross_module_problem/Boost_A.cc
g++ -fPIC -ftemplate-depth-120 -w -DNDEBUG -O3 -I/net/cci/rwgk/dist/boost
-I/usr/include/python2.2 -c -o sandbx/cross_module_problem/Boost_B.os
/net/cci/rwgk/dist/sandbx/cross_module_problem/Boost_B.cc
g++ -shared -o libtbx/sandbx_boost/ModuleB.so
sandbx/cross_module_problem/Boost_B.os -Llibtbx -lboost_python -lm
g++ -shared -o libtbx/sandbx_boost/ModuleA.so
sandbx/cross_module_problem/Boost_A.os -Llibtbx -lboost_python -lm

% cat tst.py
from sandbx_boost import ModuleA
from sandbx_boost import ModuleB
a = ModuleA.Cmplx( 1., 0. )
b = ModuleB.Printer()
b.print1( a )
b.print2( a )

% python tst.py
1 + 0 i
1 + 0 i

Ralf


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com




More information about the Cplusplus-sig mailing list