# Help needed with hacking through SWIG / Python / custom block

**URL:** <https://www.ruby-forum.com/t/help-needed-with-hacking-through-swig-python-custom-block/233115>\
**Category:** GNU Radio\
**Created:** [November 18, 2014, 3:56pm UTC](https://www.ruby-forum.com/t/help-needed-with-hacking-through-swig-python-custom-block/233115 "2014-11-18T15:56:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [November 18, 2014, 3:56pm UTC](https://www.ruby-forum.com/t/help-needed-with-hacking-through-swig-python-custom-block/233115/1 "2014-11-18T15:56:24Z")

</div>

Hi all,

I’m trying a sort of a ‘hack’, but it doesn’t work so far. What I want  
to do is to add a method to the class in my custom block, and make this  
method available in Python (the top\_block.py). Without knowledge of SWIG  
I just tried the following things (where ZZZ is the name of my block):

1. Add the method protoype to ZZZ.h
2. Add the method protoype to ZZZ\_impl.h
3. Implement the method in ZZZ\_impl.cc
4. Empty the build/swig folder to force a swig rebuild
5. Run make again

When running top\_block.py I get the following errors (apparently my goal  
is not that simple):

Traceback (most recent call last):  
File “top\_block\_modified.py”, line 16, in   
import TNO\_JJJ\_2014  
File  
“/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/ **init**.py”, line  
45, in   
from TNO\_JJJ\_2014\_swig import \*  
File  
“/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/TNO\_JJJ\_2014\_swig.py”,  
line 28, in   
\_TNO\_JJJ\_2014\_swig = swig\_import\_helper()  
File  
“/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/TNO\_JJJ\_2014\_swig.py”,  
line 24, in swig\_import\_helper  
\_mod = imp.load\_module(’\_TNO\_JJJ\_2014\_swig’, fp, pathname,  
description)  
ImportError: /usr/local/lib/libgnuradio-TNO\_JJJ\_2014.so: undefined  
symbol: \_ZN3uhd14tune\_request\_tC1Ed

Make reported me before:

Install the project…  
– Install configuration: “Release”  
– Up-to-date:  
/usr/local/lib/cmake/TNO\_JJJ\_2014/TNO\_JJJ\_2014Config.cmake  
– Up-to-date: /usr/local/include/TNO\_JJJ\_2014/api.h  
– Installing: /usr/local/include/TNO\_JJJ\_2014/JJJ\_kernel.h  
– Installing: /usr/local/lib/libgnuradio-TNO\_JJJ\_2014.so  
– Installing:  
/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/\_TNO\_JJJ\_2014\_swig.so  
– Removed runtime path from  
“/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/\_TNO\_JJJ\_2014\_swig.so”  
– Installing:  
/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/TNO\_JJJ\_2014\_swig.py  
– Installing:  
/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/TNO\_JJJ\_2014\_swig.pyc  
– Installing:  
/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/TNO\_JJJ\_2014\_swig.pyo  
– Up-to-date:  
/usr/local/include/TNO\_JJJ\_2014/TNO\_JJJ\_2014/swig/TNO\_JJJ\_2014\_swig.i  
– Installing:  
/usr/local/include/TNO\_JJJ\_2014/TNO\_JJJ\_2014/swig/TNO\_JJJ\_2014\_swig\_doc.i  
– Up-to-date:  
/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/ **init**.py  
– Up-to-date:  
/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/ **init**.pyc  
– Up-to-date:  
/usr/local/lib/python2.7/dist-packages/TNO\_JJJ\_2014/ **init**.pyo  
– Up-to-date:  
/usr/local/share/gnuradio/grc/blocks/TNO\_JJJ\_2014\_JJJ\_kernel.xml

Anybody knows what I have to add/change to get this working? Maybe  
something in the **init**.py file? If so, how do I generate the  
corresponding .pyc and .pyo files?

Best regards,

Jeroen

This message may contain information that is not intended for you. If  
you are not the addressee or if this message was sent to you by mistake,  
you are requested to inform the sender and delete the message. TNO  
accepts no liability for the content of this e-mail, for the manner in  
which you use it and for damage of any kind resulting from the risks  
inherent to the electronic transmission of messages.
