Re: OOT block swig problem (maybe qmake vs cmake)

2020-05-25 Thread Vasil Velichkov
Hi Ali,

On 25/05/2020 11.30, Ali G. Dezfuli wrote:
>   File "/home/ali/grdrills/top_block.py", line 69, in __init__
> self.tmp_tmp_cmo_acq0_0 = tmp.tmp_cmo_acq0()
> AttributeError: 'module' object has no attribute 'tmp_cmo_acq0'

One possible reason for errors like this one is undefined references in the 
shared object files. To check if this is the case go in the cmake build 
directory of you OOT module and execute

  ldd -r ./swig/*.so
  ldd -r ./lib/*.so

To resolve this add all your *.cc/*.cpp files in lib/CMakeLists.txt, add the 
-Wl,--no-undefined to link flags

  set_target_properties(gnuradio-tmp PROPERTIES LINK_FLAGS "-Wl,--no-undefined")

open python/__init__.py and remove the try except block around swig import line

   from .tmp_swig import *

Regards,
Vasil



OOT block swig problem (maybe qmake vs cmake)

2020-05-25 Thread Ali G. Dezfuli
Hi all,

The story is this:

I always add all the necessary gr_modtool created files to a new project in
qt-creator named "pre_gr" and develop a new OOT block there. Then, by
building from source, I add the block to GRC, test it, and use it. This way
I have developed some nontrivial practical modems.

BUT

I decided to be more organized by using more object-oriented features.
The problem is: the code in qt-creator compiled OK but when I add the block
to GRC, I get this error:

Generating: '/home/ali/grdrills/top_block.py'
Executing: /usr/bin/python2 -u /home/ali/grdrills/top_block.py
Traceback (most recent call last):
  File "/home/ali/grdrills/top_block.py", line 168, in 
main()
  File "/home/ali/grdrills/top_block.py", line 156, in main
tb = top_block_cls()
  File "/home/ali/grdrills/top_block.py", line 69, in __init__
self.tmp_tmp_cmo_acq0_0 = tmp.tmp_cmo_acq0()
AttributeError: 'module' object has no attribute 'tmp_cmo_acq0'

which is usually related to SWIG.
The point is that the class "_impl.h" has two member variables:
Prm d_p;
ACQ d_acq;
which are Prm class to hold all the parameters, and ACQ class for
acquisition, and in "_impl.cpp" the constructor is like this:
tmp_cmo_acq0_impl::tmp_cmo_acq0_impl()
  : gr::block("tmp_cmo_acq0",
  gr::io_signature::make(1, 1, sizeof(gr_complex)),
  gr::io_signature::make(1, 1, sizeof(gr_complex))),
d_p(awgn, 5),
d_acq(d_p)
{
}
and the problem arises just as I add "d_acq" to the block.
I really wonder why and it drives me crazy these days.
I did a lot of searches but nothing!
I am certain that there are lots of experts on the list and that's my only
hope!

The code is as follows:

tmp_cmo_acq0_impl.h:









*#ifndef INCLUDED_TMP_TMP_CMO_ACQ0_IMPL_H#define
INCLUDED_TMP_TMP_CMO_ACQ0_IMPL_H#include #include
"acq.h"#include "nco.h"#include "prm.h"#include #include
#include #include *






















*namespace gr {  namespace tmp {class tmp_cmo_acq0_impl : public
tmp_cmo_acq0{ private:Prm d_p;ACQ
  d_acq; public:  tmp_cmo_acq0_impl();
~tmp_cmo_acq0_impl();  // Where all the action really happens  void
forecast (int noutput_items, gr_vector_int _items_required);
int general_work(int noutput_items,   gr_vector_int _items,
 gr_vector_const_void_star _items,
 gr_vector_void_star _items);};  } // namespace tmp} //
namespace gr#endif /* INCLUDED_TMP_TMP_CMO_ACQ0_IMPL_H */*



tmp_cmo_acq0_impl.cpp:






























































*#ifdef HAVE_CONFIG_H#include "config.h"#endif#include
#include "tmp_cmo_acq0_impl.h"#include
"acq.h"#include "nco.h"#include "prm.h"#include #include
#include #include namespace gr {
namespace tmp {tmp_cmo_acq0::sptrtmp_cmo_acq0::make(){
return gnuradio::get_initial_sptr(new tmp_cmo_acq0_impl());}
tmp_cmo_acq0_impl::tmp_cmo_acq0_impl()  : gr::block("tmp_cmo_acq0",
  gr::io_signature::make(1, 1, sizeof(gr_complex)),
  gr::io_signature::make(1, 1, sizeof(gr_complex))),
d_p(awgn, 5),d_acq(d_p){}
tmp_cmo_acq0_impl::~tmp_cmo_acq0_impl(){}void
tmp_cmo_acq0_impl::forecast (int noutput_items, gr_vector_int
_items_required){  ninput_items_required[0] =
noutput_items;}inttmp_cmo_acq0_impl::general_work (int
noutput_items,   gr_vector_int _items,
 gr_vector_const_void_star _items,
 gr_vector_void_star _items){const gr_complex *in =
(const gr_complex *) input_items[0];gr_complex *out = (gr_complex
*) output_items[0];// Do <+signal processing+>int i = 0;
for (i = 0; i < noutput_items; ++i) {out[i] = in[i]; //
almost nothing !!!}consume_each (noutput_items);
return noutput_items;}  } /* namespace tmp */} /* namespace gr */*


prm.h:




















*#ifndef PRM_H#define PRM_H#include using namespace
std;using namespace itpp;enum CH_MODE {awgn, rayleigh};class Prm{public:
CH_MODE ch_mode;int n_sb;public:Prm(CH_MODE u_ch_mode, int
u_n_sb);};#endif // PRM_H*



prm.cpp:










*#include "prm.h"#include using namespace std;using
namespace itpp;Prm::Prm(CH_MODE u_ch_mode, int u_n_sb):
ch_mode(u_ch_mode),  n_sb(u_n_sb){}*



acq.h


















*#ifndef ACQ_H#define ACQ_H#include "nco.h"#include "prm.h"#include
#include #include
#include class ACQ {public:const Prm
public:ACQ(const Prm _p);}; // Acq#endif //
ACQ_H*




acq.cpp










*#include "acq.h"#include "nco.h"#include "prm.h"#include
#include ACQ::ACQ(const Prm _p)
  : p(u_p){}*




The versions:
*** cmake: 3.15.1
*** gnuradio: 3.7.13.4
*** ubuntu: 16.04
and IT++ is quite OK in my other OOT blocks. (and of course here)

I really appreciate it,
regards
Ali G. Dezfuli