discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] FFTW3 runtime error


From: Activecat
Subject: Re: [Discuss-gnuradio] FFTW3 runtime error
Date: Tue, 4 Mar 2014 14:27:29 +0800

The implementation header file is as below:


#ifndef INCLUDED_ACTIVECAT_FFT1_IMPL_H
#define INCLUDED_ACTIVECAT_FFT1_IMPL_H

#include <activecat/fft1.h>
#include <fftw3.h>

namespace gr {
  namespace activecat {

    class fft1_impl : public fft1
    {
     private:
       int d_N;
       int d_direction;
       int d_shift;
      
       fftw_complex *d_input;
       fftw_plan     d_plan;

     public:
        fft1_impl(int fft_size, int direction, bool fft_shift);
        ~fft1_impl();

        int work(
           int noutput_items,
           gr_vector_const_void_star &input_items,
           gr_vector_void_star &output_items);
    };

  } // namespace activecat
} // namespace gr

#endif /* INCLUDED_ACTIVECAT_FFT1_IMPL_H */



On Tue, Mar 4, 2014 at 1:55 PM, Activecat <address@hidden> wrote:
Dear Sir,

I am trying to build a custom block with FFT capability.
I use FFTW3, the FFT stuff runs well as a standalone program before integrating into gnuradio.

Then I integrate the FFT function into the block, it compiles without any error.
But when I run the flow graph in GRC, it produces following error message.

        Generating: "/home/sgku/gnuradio/flow_graphs/top_block.py"
        Executing: "/home/sgku/gnuradio/flow_graphs/top_block.py"
        Traceback (most recent call last):
          File "/home/sgku/gnuradio/flow_graphs/top_block.py", line 18, in <module>
            import activecat
          File "/usr/local/lib/python2.7/dist-packages/activecat/__init__.py", line 45, in <module>
            from activecat_swig import *
          File "/usr/local/lib/python2.7/dist-packages/activecat/activecat_swig.py", line 26, in <module>
            _activecat_swig = swig_import_helper()
          File "/usr/local/lib/python2.7/dist-packages/activecat/activecat_swig.py", line 22, in swig_import_helper
            _mod = imp.load_module('_activecat_swig', fp, pathname, description)
        ImportError: /usr/local/lib/libgnuradio-activecat.so: undefined symbol: fftw_plan_dft_1d
        >>> Done


Below is the implmentation source file:


    namespace gr {
              namespace activecat {

                fft1::sptr
                fft1::make(int fft_size, int direction, bool fft_shift)
                {
                  return gnuradio::get_initial_sptr
                    (new fft1_impl(fft_size, direction, fft_shift));
                }

                // constructor
                fft1_impl::fft1_impl(int fft_size, int direction, bool fft_shift)
                  : gr::sync_block("fft1",
                          gr::io_signature::make( 1, 1, sizeof(gr_complex)),
                          gr::io_signature::make( 1, 1, sizeof(gr_complex))),
                      d_N(fft_size),
                      d_direction(direction),
                      d_shift(fft_shift)
                {
                    d_input = (fftw_complex*) fftw_malloc( sizeof(fftw_complex) * d_N );
                    d_plan  = fftw_plan_dft_1d( d_N, d_input, d_input, FFTW_BACKWARD, FFTW_ESTIMATE );  // later change FFTW_BACKWARD to d_direction
                   
                    set_output_multiple( d_N );
                    set_min_noutput_items( d_N );
                }

                // destructor
                fft1_impl::~fft1_impl()
                { }

                int
                fft1_impl::work(
                          int noutput_items,
                          gr_vector_const_void_star &input_items,
                          gr_vector_void_star &output_items)
                {
                    const gr_complex  *in  =  (const gr_complex *)  input_items[0];
                    gr_complex        *out =  (gr_complex *)       output_items[0];
            
                    for (int i=0; i < noutput_items; i++)
                    {
                        d_input[i][0] = in[i].real();
                        d_input[i][1] = in[i].imag();
                    }
                   
                    fftw_execute( d_plan );
                   
                    for (int i=0; i < noutput_items; i++)
                    {
                        out[i].real( d_input[i][0] );
                        out[i].imag( d_input[i][1] );
                    }       
                   

                    return noutput_items;
                }
              } /* namespace activecat */
            } /* namespace gr */



Question:
How to solve this error ?

Regards,
Activecat


reply via email to

[Prev in Thread] Current Thread [Next in Thread]