![](https://secure.gravatar.com/avatar/83e2e81183334c30c4089728bc9745d3.jpg?s=120&d=mm&r=g)
Hey guys (and girls, are there any???), I have some C++ code, it does a decomposition of a large matrix.. It has a bunch of objects. It is very black box though, you just declare an object, give it the matrix and it will give an output. I think it uses CLAPACK. I would like to call this from python. I looked at some Weave information, but that didn't help, because I obviously can't run this in-line since it is many files. Any help like web links is appreciated. David
![](https://secure.gravatar.com/avatar/c84d03cc4b6ed728e124b61d78b3f1e4.jpg?s=120&d=mm&r=g)
Anyone used SWIG? David Grant wrote:
Hey guys (and girls, are there any???),
I have some C++ code, it does a decomposition of a large matrix.. It has a bunch of objects. It is very black box though, you just declare an object, give it the matrix and it will give an output. I think it uses CLAPACK. I would like to call this from python.
I looked at some Weave information, but that didn't help, because I obviously can't run this in-line since it is many files.
Any help like web links is appreciated.
David
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
-- David J. Grant Scientific Officer Intellectual Property D-Wave Systems Inc. tel: 604.732.6604 fax: 604.732.6614 ************************** CONFIDENTIAL COMMUNICATION This electronic transmission, and any documents attached hereto, is confidential. The information is intended only for use by the recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of information received in error is strictly prohibited.
![](https://secure.gravatar.com/avatar/c84d03cc4b6ed728e124b61d78b3f1e4.jpg?s=120&d=mm&r=g)
I also see this: http://docs.python.org/ext/ext.html. It says how to build a module but not how to actually USE it?? David David Grant wrote:
Anyone used SWIG?
David Grant wrote:
Hey guys (and girls, are there any???),
I have some C++ code, it does a decomposition of a large matrix.. It has a bunch of objects. It is very black box though, you just declare an object, give it the matrix and it will give an output. I think it uses CLAPACK. I would like to call this from python.
I looked at some Weave information, but that didn't help, because I obviously can't run this in-line since it is many files.
Any help like web links is appreciated.
David
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
-- David J. Grant Scientific Officer Intellectual Property D-Wave Systems Inc. tel: 604.732.6604 fax: 604.732.6614 ************************** CONFIDENTIAL COMMUNICATION This electronic transmission, and any documents attached hereto, is confidential. The information is intended only for use by the recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of information received in error is strictly prohibited.
![](https://secure.gravatar.com/avatar/9b85a909fbfc71a3ea3275c7872e714d.jpg?s=120&d=mm&r=g)
On Fri, 29 Oct 2004, David Grant wrote:
I also see this: http://docs.python.org/ext/ext.html. It says how to build a module but not how to actually USE it??
Did you read the first section of this document: http://docs.python.org/ext/simpleExample.html ?
David Grant wrote:
Anyone used SWIG?
Yes, of course;-)
David Grant wrote:
Hey guys (and girls, are there any???),
I have some C++ code, it does a decomposition of a large matrix.. It has a bunch of objects. It is very black box though, you just declare an object, give it the matrix and it will give an output. I think it uses CLAPACK. I would like to call this from python.
What kind of a matrix decomposition are you trying to calculate? May be scipy.linalg has it already. Pearu
![](https://secure.gravatar.com/avatar/c84d03cc4b6ed728e124b61d78b3f1e4.jpg?s=120&d=mm&r=g)
Pearu Peterson wrote:
On Fri, 29 Oct 2004, David Grant wrote:
I also see this: http://docs.python.org/ext/ext.html. It says how to build a module but not how to actually USE it??
Did you read the first section of this document:
http://docs.python.org/ext/simpleExample.html
?
Yeah, but that was for C. Mine is C++. I thought it would be a little different.
David Grant wrote:
Anyone used SWIG?
Yes, of course;-)
So will it work for me? From what I've told you so far?
David Grant wrote:
Hey guys (and girls, are there any???),
I have some C++ code, it does a decomposition of a large matrix.. It has a bunch of objects. It is very black box though, you just declare an object, give it the matrix and it will give an output. I think it uses CLAPACK. I would like to call this from python.
What kind of a matrix decomposition are you trying to calculate? May be scipy.linalg has it already.
It does some CSD. But the algorithm is specific to quantum computing, so I doubt it is in scipy.linalg. Although I'm not sure how much of this code is CSD and how much is other stuff. It's possible I guess to use scipy.linalg and rewrite the supporting stuff in python directly.
Pearu
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
-- David J. Grant Scientific Officer Intellectual Property D-Wave Systems Inc. tel: 604.732.6604 fax: 604.732.6614 ************************** CONFIDENTIAL COMMUNICATION This electronic transmission, and any documents attached hereto, is confidential. The information is intended only for use by the recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of information received in error is strictly prohibited.
![](https://secure.gravatar.com/avatar/9b85a909fbfc71a3ea3275c7872e714d.jpg?s=120&d=mm&r=g)
On Fri, 29 Oct 2004, David Grant wrote:
Pearu Peterson wrote:
On Fri, 29 Oct 2004, David Grant wrote:
I also see this: http://docs.python.org/ext/ext.html. It says how to build a module but not how to actually USE it??
Did you read the first section of this document:
http://docs.python.org/ext/simpleExample.html
?
Yeah, but that was for C. Mine is C++. I thought it would be a little different.
Not so much different, see http://docs.python.org/ext/cplusplus.html However, if you need to wrap C++ classes then you can use either SWIG or Boost.Python.
Anyone used SWIG?
Yes, of course;-)
So will it work for me? From what I've told you so far?
From what you have told us I see no reason why wouldn't it work.
David Grant wrote:
Hey guys (and girls, are there any???),
I have some C++ code, it does a decomposition of a large matrix.. It has a bunch of objects. It is very black box though, you just declare an object, give it the matrix and it will give an output. I think it uses CLAPACK. I would like to call this from python.
What kind of a matrix decomposition are you trying to calculate? May be scipy.linalg has it already.
It does some CSD. But the algorithm is specific to quantum computing, so I doubt it is in scipy.linalg. Although I'm not sure how much of this code is CSD and how much is other stuff. It's possible I guess to use scipy.linalg and rewrite the supporting stuff in python directly.
So you would need gsvd in scipy.linalg but that has not been implemented yet. Pearu
![](https://secure.gravatar.com/avatar/73f4e1ffd23622a339c1c9303615d7fe.jpg?s=120&d=mm&r=g)
"David" == David Grant <david.grant@telus.net> writes:
David> Hey guys (and girls, are there any???), I have some C++ David> code, it does a decomposition of a large matrix.. It has a David> bunch of objects. It is very black box though, you just David> declare an object, give it the matrix and it will give an David> output. I think it uses CLAPACK. I would like to call David> this from python. David> I looked at some Weave information, but that didn't help, David> because I obviously can't run this in-line since it is many David> files. pycxx is very nice; boost python is also a good choice. JDH
![](https://secure.gravatar.com/avatar/2b9e709099c91ef94cc520e87f605b53.jpg?s=120&d=mm&r=g)
"DG" == David Grant <david.grant@telus.net> writes:
DG> I looked at some Weave information, but that didn't help, DG> because I obviously can't run this in-line since it is many DG> files. That seems like an incorrect assumption. Weave will let you call any function you want from within the inlined code. From the information you have provided, I assume you want to do something like this in Python: a = Numeric.array(...) # Setup your matrix the way you want. call_c_code_that_does_stuff_to_array(a) # Continue work from Python... So simply define call_c_code_that_does_stuff_to_array and write some simple C++ code that does what you want. This is definitely doable from weave. The question is what 'output' does your blackbox produce? If its a number/array then they are easy to handle since weave will let you do that. When you call inline you can pass headers and link to libraries that you have built. So in theory you can build your blackbox C++ code as a library, and call its functions from your inlined code. Of course, you can use SWIG or Boost.Python also. But weave is still an option. cheers, prabhu
![](https://secure.gravatar.com/avatar/c84d03cc4b6ed728e124b61d78b3f1e4.jpg?s=120&d=mm&r=g)
Prabhu Ramachandran wrote:
"DG" == David Grant <david.grant@telus.net> writes:
DG> I looked at some Weave information, but that didn't help, DG> because I obviously can't run this in-line since it is many DG> files.
That seems like an incorrect assumption. Weave will let you call any function you want from within the inlined code. From the information you have provided, I assume you want to do something like this in Python:
a = Numeric.array(...) # Setup your matrix the way you want.
call_c_code_that_does_stuff_to_array(a)
# Continue work from Python...
So simply define call_c_code_that_does_stuff_to_array and write some simple C++ code that does what you want. This is definitely doable from weave. The question is what 'output' does your blackbox produce? If its a number/array then they are easy to handle since weave will let you do that. When you call inline you can pass headers and link to libraries that you have built. So in theory you can build your blackbox C++ code as a library, and call its functions from your inlined code.
Prabhu, I tried doing what you describe. I basically am doing the following as a test to see if I can get this to work. I have the following test python script: import weave inc_dirs=['/home/david/working_dir/python/qcd', '/usr/include'] lib_dirs=['/home/david/working_dir/python/qcd', '/usr/lib'] libs=['dcomplex'] code = """ #include "DComplex.h" DComplex z(2,3); """ weave.inline(code, include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2) DComplex.cpp and DComplex.h define a class for complex numbers. I build DComplex.cpp separately using a makefile. This does: gcc -c DComplex.cpp ar rc libdcomplex.a DComplex.o ranlib libdcomplex.a This builds a static library libdcomplex.a Then, as shown in my test python script above, I use libs=['dcomplex'] and that will include libdcomplex.a in the current directory. The linking actually seems to work ok! The prooblem seems to be when python imports the file: running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'sc_89dfe56fc9f6dd6ee19b60174c27c7511' extension compiling C++ sources g++ options: '-fno-strict-aliasing -DNDEBUG -fPIC' compile options: '-I/home/david/working_dir/python/qcd -I/usr/include -I/usr/lib/python2.3/site-packages/weave -I/usr/lib/python2.3/site-packages/weave/scxx -I/usr/include/python2.3 -c' g++: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.cpp g++ -pthread -shared /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.o /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/usr/lib/python2.3/site-packages/weave/scxx/weave_imp.o -L/home/david/working_dir/python/qcd -L/usr/lib -ldcomplex -o /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so Traceback (most recent call last): File "test_weave.py", line 20, in ? weave.inline(code,['arr','_Narr'], include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2) File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 335, in inline auto_downcast = auto_downcast, File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 445, in compile_function exec 'import ' + module_name File "<string>", line 1, in ? ImportError: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so: undefined symbol: _ZZ13compiled_funcP7_objectS0_EN8DComplexC1Edd As you can see above there is an undefined symbol in the python .so extension, which ends in ...DComplex... I've been stuck on this for an hour and I have no clue what is wrong. If you or anything else can help me, it would be appreciated.
Of course, you can use SWIG or Boost.Python also. But weave is still an option.
cheers, prabhu
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user
-- David J. Grant Scientific Officer Intellectual Property D-Wave Systems Inc. tel: 604.732.6604 fax: 604.732.6614 ************************** CONFIDENTIAL COMMUNICATION This electronic transmission, and any documents attached hereto, is confidential. The information is intended only for use by the recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of information received in error is strictly prohibited.
![](https://secure.gravatar.com/avatar/ec366db3649cf13f4061b519193849d6.jpg?s=120&d=mm&r=g)
David Grant wrote:
I tried doing what you describe. I basically am doing the following as a test to see if I can get this to work. I have the following test python script:
import weave inc_dirs=['/home/david/working_dir/python/qcd', '/usr/include'] lib_dirs=['/home/david/working_dir/python/qcd', '/usr/lib'] libs=['dcomplex'] code = """ #include "DComplex.h" DComplex z(2,3); """ weave.inline(code, include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2)
I'm pretty sure that you want to put all #include's as support code. Everything in 'code' gets pasted into a function body. E.g. support_code = """#include "DComplex.h" """ code = """DComplex z(2,3); """ weave.inline(code, support_code=support_code, ...)
DComplex.cpp and DComplex.h define a class for complex numbers. I build DComplex.cpp separately using a makefile. This does:
gcc -c DComplex.cpp ar rc libdcomplex.a DComplex.o ranlib libdcomplex.a
This builds a static library libdcomplex.a Then, as shown in my test python script above, I use libs=['dcomplex'] and that will include libdcomplex.a in the current directory. The linking actually seems to work ok! The prooblem seems to be when python imports the file:
When linking shared libraries, the linker will often (always?) not check for missing symbols.
running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'sc_89dfe56fc9f6dd6ee19b60174c27c7511' extension compiling C++ sources g++ options: '-fno-strict-aliasing -DNDEBUG -fPIC' compile options: '-I/home/david/working_dir/python/qcd -I/usr/include -I/usr/lib/python2.3/site-packages/weave -I/usr/lib/python2.3/site-packages/weave/scxx -I/usr/include/python2.3 -c' g++: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.cpp g++ -pthread -shared /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.o /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/usr/lib/python2.3/site-packages/weave/scxx/weave_imp.o -L/home/david/working_dir/python/qcd -L/usr/lib -ldcomplex -o /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so
Traceback (most recent call last): File "test_weave.py", line 20, in ? weave.inline(code,['arr','_Narr'], include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2) File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 335, in inline auto_downcast = auto_downcast, File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 445, in compile_function exec 'import ' + module_name File "<string>", line 1, in ? ImportError: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so: undefined symbol: _ZZ13compiled_funcP7_objectS0_EN8DComplexC1Edd
As you can see above there is an undefined symbol in the python .so extension, which ends in ...DComplex...
The stuff before it, ...compiled_func... points, I believe to the fact that the #include came inside the function body whereas the library needs it outside of the function body. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
![](https://secure.gravatar.com/avatar/c84d03cc4b6ed728e124b61d78b3f1e4.jpg?s=120&d=mm&r=g)
Robert Kern wrote:
David Grant wrote:
I tried doing what you describe. I basically am doing the following as a test to see if I can get this to work. I have the following test python script:
import weave inc_dirs=['/home/david/working_dir/python/qcd', '/usr/include'] lib_dirs=['/home/david/working_dir/python/qcd', '/usr/lib'] libs=['dcomplex'] code = """ #include "DComplex.h" DComplex z(2,3); """ weave.inline(code, include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2)
I'm pretty sure that you want to put all #include's as support code. Everything in 'code' gets pasted into a function body.
E.g.
support_code = """#include "DComplex.h" """ code = """DComplex z(2,3); """ weave.inline(code, support_code=support_code, ...)
Cool, thanks. This is similar to headers! Probably headers just gets wrapped into support_code I'm guessing, which might explain why it is undocumented?
DComplex.cpp and DComplex.h define a class for complex numbers. I build DComplex.cpp separately using a makefile. This does:
gcc -c DComplex.cpp ar rc libdcomplex.a DComplex.o ranlib libdcomplex.a
This builds a static library libdcomplex.a Then, as shown in my test python script above, I use libs=['dcomplex'] and that will include libdcomplex.a in the current directory. The linking actually seems to work ok! The prooblem seems to be when python imports the file:
When linking shared libraries, the linker will often (always?) not check for missing symbols.
Right.
running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'sc_89dfe56fc9f6dd6ee19b60174c27c7511' extension compiling C++ sources g++ options: '-fno-strict-aliasing -DNDEBUG -fPIC' compile options: '-I/home/david/working_dir/python/qcd -I/usr/include -I/usr/lib/python2.3/site-packages/weave -I/usr/lib/python2.3/site-packages/weave/scxx -I/usr/include/python2.3 -c' g++: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.cpp g++ -pthread -shared /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.o /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/usr/lib/python2.3/site-packages/weave/scxx/weave_imp.o -L/home/david/working_dir/python/qcd -L/usr/lib -ldcomplex -o /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so
Traceback (most recent call last): File "test_weave.py", line 20, in ? weave.inline(code,['arr','_Narr'], include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2) File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 335, in inline auto_downcast = auto_downcast, File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 445, in compile_function exec 'import ' + module_name File "<string>", line 1, in ? ImportError: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so: undefined symbol: _ZZ13compiled_funcP7_objectS0_EN8DComplexC1Edd
As you can see above there is an undefined symbol in the python .so extension, which ends in ...DComplex...
The stuff before it, ...compiled_func... points, I believe to the fact that the #include came inside the function body whereas the library needs it outside of the function body.
Thanks. -- David J. Grant Scientific Officer Intellectual Property D-Wave Systems Inc. tel: 604.732.6604 fax: 604.732.6614 ************************** CONFIDENTIAL COMMUNICATION This electronic transmission, and any documents attached hereto, is confidential. The information is intended only for use by the recipient named above. If you have received this electronic message in error, please notify the sender and delete the electronic message. Any disclosure, copying, distribution, or use of the contents of information received in error is strictly prohibited.
![](https://secure.gravatar.com/avatar/ec366db3649cf13f4061b519193849d6.jpg?s=120&d=mm&r=g)
David Grant wrote:
Cool, thanks. This is similar to headers! Probably headers just gets wrapped into support_code I'm guessing, which might explain why it is undocumented?
Lack of time on the part of the person/people who have the knowledge is more likely. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
![](https://secure.gravatar.com/avatar/2b9e709099c91ef94cc520e87f605b53.jpg?s=120&d=mm&r=g)
"RK" == Robert Kern <rkern@ucsd.edu> writes:
RK> I'm pretty sure that you want to put all #include's as support RK> code. Everything in 'code' gets pasted into a function body. Well support code could be used when you want to write functions that you don't want to wrap but want to call in the wrapped function. I think headers are the way to go if you just want to specify the headers to include. cheers, prabhu
![](https://secure.gravatar.com/avatar/ec366db3649cf13f4061b519193849d6.jpg?s=120&d=mm&r=g)
Prabhu Ramachandran wrote:
"RK" == Robert Kern <rkern@ucsd.edu> writes:
RK> I'm pretty sure that you want to put all #include's as support RK> code. Everything in 'code' gets pasted into a function body.
Well support code could be used when you want to write functions that you don't want to wrap but want to call in the wrapped function. I think headers are the way to go if you just want to specify the headers to include.
Yes, indeed. Last time I had to delve into weave, I just reflexively used the first thing I saw (somewhat more forgivably on my part, I needed both headers and support functions). And then I reflexively passed it on to an unsuspecting David. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
![](https://secure.gravatar.com/avatar/c84d03cc4b6ed728e124b61d78b3f1e4.jpg?s=120&d=mm&r=g)
David Grant wrote:
Prabhu,
I tried doing what you describe. I basically am doing the following as a test to see if I can get this to work. I have the following test python script:
import weave inc_dirs=['/home/david/working_dir/python/qcd', '/usr/include'] lib_dirs=['/home/david/working_dir/python/qcd', '/usr/lib'] libs=['dcomplex'] code = """ #include "DComplex.h" DComplex z(2,3); """ weave.inline(code, include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2)
DComplex.cpp and DComplex.h define a class for complex numbers. I build DComplex.cpp separately using a makefile. This does:
gcc -c DComplex.cpp ar rc libdcomplex.a DComplex.o ranlib libdcomplex.a
This builds a static library libdcomplex.a Then, as shown in my test python script above, I use libs=['dcomplex'] and that will include libdcomplex.a in the current directory. The linking actually seems to work ok! The prooblem seems to be when python imports the file:
running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'sc_89dfe56fc9f6dd6ee19b60174c27c7511' extension compiling C++ sources g++ options: '-fno-strict-aliasing -DNDEBUG -fPIC' compile options: '-I/home/david/working_dir/python/qcd -I/usr/include -I/usr/lib/python2.3/site-packages/weave -I/usr/lib/python2.3/site-packages/weave/scxx -I/usr/include/python2.3 -c' g++: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.cpp g++ -pthread -shared /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.o /tmp/david/python23_intermediate/compiler_d039d257d176c3731283eef034e62e43/usr/lib/python2.3/site-packages/weave/scxx/weave_imp.o -L/home/david/working_dir/python/qcd -L/usr/lib -ldcomplex -o /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so
Traceback (most recent call last): File "test_weave.py", line 20, in ? weave.inline(code,['arr','_Narr'], include_dirs=inc_dirs, library_dirs=lib_dirs, libraries=libs, verbose=2) File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 335, in inline auto_downcast = auto_downcast, File "/usr/lib/python2.3/site-packages/weave/inline_tools.py", line 445, in compile_function exec 'import ' + module_name File "<string>", line 1, in ? ImportError: /home/david/.python23_compiled/sc_89dfe56fc9f6dd6ee19b60174c27c7511.so: undefined symbol: _ZZ13compiled_funcP7_objectS0_EN8DComplexC1Edd
As you can see above there is an undefined symbol in the python .so extension, which ends in ...DComplex...
I've been stuck on this for an hour and I have no clue what is wrong. If you or anything else can help me, it would be appreciated.
Grr....I figured it out. I need to use the headers=[] arg. It isn't documented on scipy.org. Grrr.... I'll email Eric Jones and politely inform him. :-) Dave
![](https://secure.gravatar.com/avatar/2b9e709099c91ef94cc520e87f605b53.jpg?s=120&d=mm&r=g)
"DG" == David Grant <david@dwavesys.com> writes:
DG> David Grant wrote: >> wrong. If you or anything else can help me, it would be >> appreciated. DG> Grr....I figured it out. I need to use the headers=[] arg. DG> It isn't documented on scipy.org. Grrr.... I'll email Eric DG> Jones and politely inform him. :-) Well, the inline command is fully documented in the sources. :) Look at inline_tools.py:: 132 def inline(code,arg_names=[],local_dict = None, global_dict = None, 133 force = 0, 134 compiler='', 135 verbose = 0, 136 support_code = None, 137 headers = [], 138 customize=None, 139 type_converters = None, 140 auto_downcast=1, 141 **kw): 142 """ Inline C/C++ code within Python scripts. [... snipped long docs ...] Also, if you look at the examples directory the swig2_example.py and vtk_example.py use the headers. I know, this is perhaps no excuse for lack of docs but using the sources is generally a good idea. :) I also think Fernando's examples ought to be cleaned up sometime and put in the examples directory. It sure covers a lot of ground! For now perhaps a link to his examples would be a good idea. This is from an older mail from him on this list:: http://amath.colorado.edu/faculty/fperez/python/weave_examples.html original source here: http://amath.colorado.edu/faculty/fperez/python/weave_examples.py HTH, cheers, prabhu
![](https://secure.gravatar.com/avatar/83e2e81183334c30c4089728bc9745d3.jpg?s=120&d=mm&r=g)
Prabhu Ramachandran wrote:
Also, if you look at the examples directory the swig2_example.py and vtk_example.py use the headers.
Yeah, that was how I discovered it. Looked in the examples directory and grepped for "#include" -- David J. Grant http://www.davidgrant.ca:81
participants (6)
-
David Grant
-
David Grant
-
John Hunter
-
Pearu Peterson
-
Prabhu Ramachandran
-
Robert Kern