Forum: GNU Radio Question about adding your own classes

34ca4305e0456e8510a1d4d7009a12d0?d=identicon&s=25 Tommy Tracy II (Guest)
on 2013-09-20 19:59
(Received via mailing list)
Dear List,

I am using gr_modtool to create new modules and blocks, and I have a
question about adding additional .cc/.h files that are not included by
gr_modtool to the cmake file or otherwise importing them by hand.

My new blocks are dependent on two new classes called
NetworkInterface.{cc,h} and EthernetConnector.{cc,h}. During the make
process, if there is a syntax error in either of these files, the
compiler will alert me. I was able to fix all problems and get the
cmake, make, and make install completed. The problem manifested itself
when I attempted to import the module:
----------
>>> import router
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/home/tjt7a/Src/target/lib/python2.7/dist-packages/router/__init__.py",
line 45, in <module>
    from router_swig import *
  File
"/home/tjt7a/Src/target/lib/python2.7/dist-packages/router/router_swig.py",
line 26, in <module>
    _router_swig = swig_import_helper()
  File
"/home/tjt7a/Src/target/lib/python2.7/dist-packages/router/router_swig.py",
line 22, in swig_import_helper
    _mod = imp.load_module('_router_swig', fp, pathname, description)
ImportError: /home/tjt7a/Src/target/lib/libgnuradio-router.so: undefined
symbol: _ZN16NetworkInterface7connectEPc
----------
To investigate the definition of this symbol, I ran c++filt
----------
$c++filt _ZN16NetworkInterface7connectEPc
NetworkInterface::connect(char*)
----------
This indicates, that my libgnuradio-router module cannot access the
NetworkInterface object file, even though it was part of the compilation
step.

My thought process was to create the two shared object (.so) files by
hand, and move them to my python path location. So I did that:
----------
cc -shared -o libEthernetConnector.so -fPIC EthernetConnector.cc
cc -shared -o libNetworkInterface.so -fPIC NetworkInterface.cc
I then copied them to the location of my gnuradio .so files
----------

Unfortunately, this still hasn't solved the problem. Does anyone know a
solution to this problem?

Tommy James Tracy II
Ph.D Student
High Performance Low Power Lab
University of Virginia
Phone: 913-775-2241
Ad80d352eb445a3d7dccd5a779db0e43?d=identicon&s=25 Martin Braun (CEL) (Guest)
on 2013-09-21 01:15
(Received via mailing list)
Hi Tommy,

is this a visibility issue? Did you use modtool to add the additional
classes? If not, do you have a FOO_API macro in your class def?

MB


On Fri, Sep 20, 2013 at 01:58:16PM -0400, Tommy Tracy II wrote:
> error in either of these files, the compiler will alert me. I was able to fix
>
>   File "/home/tjt7a/Src/target/lib/python2.7/dist-packages/router/
>
>
> I then copied them to the location of my gnuradio .so files
> Ph.D Student
>
> High Performance Low Power Lab
>
> University of Virginia
>
> Phone: 913-775-2241
>
>

> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


--
Karlsruhe Institute of Technology (KIT)
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin Braun
Research Associate

Kaiserstra├če 12
Building 05.01
76131 Karlsruhe

Phone: +49 721 608-43790
Fax: +49 721 608-46071
www.cel.kit.edu

KIT -- University of the State of Baden-W├╝rttemberg and
National Laboratory of the Helmholtz Association
C539637020fd56193dd6daec746c4a84?d=identicon&s=25 Tom Rondeau (Guest)
on 2013-09-21 17:22
(Received via mailing list)
On Fri, Sep 20, 2013 at 7:13 PM, Martin Braun (CEL)
<martin.braun@kit.edu> wrote:
> Hi Tommy,
>
> is this a visibility issue? Did you use modtool to add the additional
> classes? If not, do you have a FOO_API macro in your class def?
>
> MB

Tommy,

Yes, make sure that the FOO_API is declared for the classes. Also, you
have to make sure they are being imported into the swig module
correctly in gr-foo/swig/foo_swig.i.

You can use gr_modtool with the class type "noblock" to create classes
that are not gr::blocks for this purpose, which will set up the cmake
and swig files correctly.


>> and EthernetConnector.{cc,h}. During the make process, if there is a syntax
>>   File "<stdin>", line 1, in <module>
>>
>> To investigate the definition of this symbol, I ran c++filt
>> NetworkInterface object file, even though it was part of the compilation step.
>>
>>
>> _______________________________________________
> Research Associate
> National Laboratory of the Helmholtz Association
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>



--
Tom
GRCon13 Oct. 1 - 4
http://www.trondeau.com/grcon13
34ca4305e0456e8510a1d4d7009a12d0?d=identicon&s=25 Tommy Tracy II (Guest)
on 2013-09-23 06:25
(Received via mailing list)
Attachment: signature.asc (494 Bytes)
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
C539637020fd56193dd6daec746c4a84?d=identicon&s=25 Tom Rondeau (Guest)
on 2013-09-23 17:22
(Received via mailing list)
On Mon, Sep 23, 2013 at 12:24 AM, Tommy Tracy II <tjt7a@virginia.edu>
wrote:
> Perfect,
>
> Thank you everyone. What I did was include the header files in my block
> source files; I needed to add them to the CMakeLists.txt in /lib under:
> list(APPEND router_sources
> to get everything to build and link correctly.
>
> I was then able to import the module and use it without error in python.
> From now on I will use 'no block'.

Great!

> audio_oss_sink: /dev/dsp: No such file or directory
> terminate called after throwing an instance of 'std::runtime_error'
>   what():  audio_oss_sink
> Aborted (core dumped)

We've always just pointed to the dial tone example for how to build
C++-only projects. I don't think that we've produced a tutorial on how
to do it, though someone else may have.

As for your problem, what you are seeing is just an audio driver
issue. In your VM, does your sound work at all? Do you know what
device or audio system you are using (OSS, ALSA, Pulseaudio, etc)? The
/dev/dsp is assuming OSS. The dial_tone.cc file is pretty light on
features. You'll have to get in there and edit it to change the device
it's using. Go to the "audio::sink::make(rate)" and change that to
"audio::sink::make(rate, device)" where 'device' is the device name
that you want to use. If you are using Ubunut, say, in your VM and
sound works fine with it, you can likely use "pulse" as your device
name. Recompile and try that.

Tom



> <martin.braun@kit.edu> wrote:
>
>
> My new blocks are dependent on two new classes called
> import router
>    from router_swig import *
>
>
> and
> ----------
> High Performance Low Power Lab
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> Kaiserstrae 12
> _______________________________________________
> http://www.trondeau.com/grcon13
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
>



--
Tom
GRCon13 Oct. 1 - 4
http://www.trondeau.com/grcon13
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.