Tuesday, July 31, 2018

Re: [Discuss-gnuradio] Issue with swig in packet_headerparser block

Hi Michael,
Thank you very much for your help. The top-level CMakelists.txt was okay. I found that the CMakelists.txt in the include directory was missing "packet_header_default.h"  definition. Now, I am able to debug with now error. 
Regards
Jebreel


Jebreel Salem


On Tue, Jul 31, 2018 at 2:02 PM, Michael Dickens <michael.dickens@ettus.com> wrote:
Hi Jebreel - From the import error, it looks like either you're not linking against gr-digital library, or you're referencing some function or method or variables that doesn't exist in (isn't being exported from) the gr-digital library. Did you verify in your OOT's top-level CMakeLists.txt that when you're finding GR, you're specifying "digital" (as well as probably: runtime, blocks)? The line will be something like:
{{{
set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS DIGITAL)
}}}

To get the SWIG part working, you do need a little special SWIG sauce ... and, as you are hopefully finding, sometimes it's best to just copy from the SWIG file that does this in gr-digital & tweak it to your specific class. I'm not sure the SWIG is 100% correct, but it looks good at first reading to me.

If you continue to have errors, I'd suggest you push your GR OOT into a public repo (e.g., on GitHub) & post a link to it so that those of us who have done this before can work with actual code & thus provide real feedback instead of best guesses based on incomplete code.

Hope this is useful. - MLD

On Tue, Jul 31, 2018, at 1:15 PM, Jebreel Salem wrote:
Hello Marcus,
Thank you very much for your reply. The flag is there. However, I think the problem is with SWIG file because it does not have the correct definitions for packet_header_default.  I copied the packet_header_default.cc from the ofdm gnuradio and put it in my lib directory and copied  packet_header_default.h and put  it in my include directory. So I did not create using gr_modtool add. I add manually all definition and paths but I am not  sure if missed something.  Here is my swig file with definitions I added (I changed the name of the class digitalc) but I am still getting errors. 


/* -*- c++ -*- */

#define DIGITALC_API

%include "gnuradio.i" // the common stuff

//load generated python docstrings
%include "digitalc_swig_doc.i"

%{
#include "digitalc/packet_headerparser_b.h"
#include "digitalc/packet_header_default.h"
%}


%include "digitalc/packet_headerparser_b.h"
%include "digitalc/packet_header_default.h"

GR_SWIG_BLOCK_MAGIC2(digitalc, packet_headerparser_b);


%template(packet_header_default_sptr) boost::shared_ptr<gr::digitalc::packet_header_default>;
%pythoncode %{
packet_header_default_sptr.__repr__ = lambda self: "<packet_header_default>"
packet_header_default = packet_header_default .make;
%}

Here is the error I am getting:

Traceback (most recent call last):
  File "/home/dev/Gnuradio_Prjs/parser/gr-digitalc/python/qa_packet_headerparser_b.py", line 32, in <module>
    import digitalc.digitalc_swig as digitalc
  File "/usr/local/lib/python2.7/dist-packages/digitalc/digitalc_swig.py", line 28, in <module>
    _digitalc_swig = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/digitalc/digitalc_swig.py", line 24, in swig_import_helper
    _mod = imp.load_module('_digitalc_swig', fp, pathname, description)
ImportError: /home/dev/Gnuradio_Prjs/parser/gr-digitalc-debug/lib/libgnuradio-digitalc-1.0.0git.so.0.0.0: undefined symbol: _ZN2gr8digitalc21packet_header_defaultC1ElRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_i

Thanks for the help!
Regards,
Jebreel




Jebreel Salem


On Tue, Jul 31, 2018 at 4:54 AM, Müller, Marcus (CEL) <mueller@kit.edu> wrote:
Looks like your library doesn't export that symbol (in this case, the
constructor of the packet_header_default class). Did you make sure that
the class bears the SPERRY_API flag?

Best regards,
Marcus


On Mon, 2018-07-30 at 16:35 -0500, Jebreel Salem wrote:
> Hi,
> I am trying to create packet_headerparser block. The purpose is to first  duplicate the block and then modify it (mostly I would like to modify the dict part). I followed the the instruction in howto tutorial but I got the error below when I tried to run the  qa_packet_headerparser_b.py. I am not sure what I did wrong but I was able to duplicate demux block and make it work fine. Any hint on this is grealty appreciated.
>
>
> Traceback (most recent call last):
>   File "/home/dev/Gnuradio_Prjs/parser/gr-sperry/python/qa_packet_headerparser_b.py", line 28, in <module>
>     import sperry.sperry_swig as sperry
>   File "/usr/local/lib/python2.7/dist-packages/sperry/sperry_swig.py", line 28, in <module>
>     _sperry_swig = swig_import_helper()
>   File "/usr/local/lib/python2.7/dist-packages/sperry/sperry_swig.py", line 24, in swig_import_helper
>     _mod = imp.load_module('_sperry_swig', fp, pathname, description)
> ImportError: /home/dev/Gnuradio_Prjs/parser/gr-sperry-debug/lib/libgnuradio-sperry-1.0.0git.so.0.0.0: undefined symbol: _ZN2gr6sperry21packet_header_defaultC1ElRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_i
>
> Thanks!
>
> Jebreel Salem
>
> _______________________________________________
> Discuss-gnuradio mailing list
_______________________________________________
Discuss-gnuradio mailing list


No comments:

Post a Comment