By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,745 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,745 IT Pros & Developers. It's quick & easy.

wrapping C++ code using blitz++ arrays to python using SWIG

P: 1
Hi there,
I need to use SWIG to wrap my C++ class which heavily uses blitz++ arrays to python. Has anybody done this before? I'm looking for a simple example .i file...

My imports in CFits.h:
Expand|Select|Wrap|Line Numbers
  1.   #include <stdio.h>
  2.   #include <iostream>
  3.   #include <cstdlib>
  4.   #include <blitz/array.h>
  5.   #include <blitz/vector.h>
  6.   #include <blitz/vector-et.h>
  7.   #include <blitz/vecwhere.h>
  8.   #include <blitz/tinyvec.h>
  9.   #include <blitz/tinyvec-et.h>
  10.   #include <fitsio.h>
  11.   #include <fitsio2.h>


My stelladrp.i file:
Expand|Select|Wrap|Line Numbers
  1. %module stelladrp
  2. %{
  3. #include "cfits/src/CAny.h"
  4. #include "cfits/src/CFits.h"
  5. #include "mextract/src/MExtract.h"
  6. %}
  7. %include std_string.i
  8. using std::string;
  9. %include "cfits/src/CAny.h"
  10. %include "cfits/src/CFits.h"
  11. %include "mextract/src/MExtract.h"
my commands:
Expand|Select|Wrap|Line Numbers
  1. swig -c++ -python -I/usr/local/include -I/usr/include stelladrp.i
  2. g++ -lm -fpic -std=c++11 -c mextract/src/MExtract.cpp stelladrp_wrap.cxx -I/usr/include/python2.7/
  3. g++ -shared MExtract.o stelladrp_wrap.o -o _stelladrp.so
my Python output when importing stelladrp:
Expand|Select|Wrap|Line Numbers
  1. >>> import stelladrp
  2. Traceback (most recent call last):
  3.   File "<stdin>", line 1, in <module>
  4.   File "stelladrp.py", line 28, in <module>
  5.     _stelladrp = swig_import_helper()
  6.   File "stelladrp.py", line 24, in swig_import_helper
  7.     _mod = imp.load_module('_stelladrp', fp, pathname, description)
  8. ImportError: ./_stelladrp.so: undefined symbol: _ZNK5CFits6SplIntERN5blitz5ArrayIdLi1EEES3_S3_dPd
  9. >>>
Aug 14 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.