1

For last two days i'm trying to create new block in gnuradio, but i'm constantly getting error when i try to execute flow graph:

AttributeError: 'module' object has no attribute 'test'

I think that there is some problem with 3rd party libraries (opennn) i'm trying to use in my project.In main source file (test_impl.cc) i've imported opennn header file. In funtion general_work i'm invoking function:

   int
    test_impl::general_work (int noutput_items,
                       gr_vector_int &ninput_items,
                       gr_vector_const_void_star &input_items,
                       gr_vector_void_star &output_items)
    {
      const float *in = (const float *) input_items[0];
      float *out = (float *) output_items[0];
       OpenNN::NeuralNetwork nn(8, 1, 1);

      // Do <+signal processing+>
      // Tell runtime system how many input items we consumed on
      // each input stream.
      consume_each (noutput_items);

      // Tell runtime system how many output items we produced.
      return noutput_items;
    }

My lib/CMakeLists.txt (in lib folder i have auto-generated gnuradio block source files and dirs with opennn library):

########################################################################
# Setup library
########################################################################
include(GrPlatform) #define LIB_SUFFIX

include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})

list(APPEND tutorial3_sources
    test_impl.cc
)

set(tutorial3_sources "${tutorial3_sources}" PARENT_SCOPE)
if(NOT tutorial3_sources)
    MESSAGE(STATUS "No C++ sources... skipping lib/")
    return()
endif(NOT tutorial3_sources)

add_library(gnuradio-tutorial3 SHARED ${tutorial3_sources})
target_link_libraries(gnuradio-tutorial3 ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES})
set_target_properties(gnuradio-tutorial3 PROPERTIES DEFINE_SYMBOL "gnuradio_tutorial3_EXPORTS")

if(APPLE)
    set_target_properties(gnuradio-tutorial3 PROPERTIES
        INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
    )
endif(APPLE)
########################################################################
# Install built library files
########################################################################
include(GrMiscUtils)
GR_LIBRARY_FOO(gnuradio-tutorial3 RUNTIME_COMPONENT "tutorial3_runtime" DEVEL_COMPONENT "tutorial3_devel")

########################################################################
# Build and register unit test
########################################################################
include(GrTest)

include_directories(${CPPUNIT_INCLUDE_DIRS})

list(APPEND test_tutorial3_sources
    ${CMAKE_CURRENT_SOURCE_DIR}/test_tutorial3.cc
    ${CMAKE_CURRENT_SOURCE_DIR}/qa_tutorial3.cc
)

add_executable(test-tutorial3 ${test_tutorial3_sources})

target_link_libraries(
  test-tutorial3
  ${GNURADIO_RUNTIME_LIBRARIES}
  ${Boost_LIBRARIES}
  ${CPPUNIT_LIBRARIES}
  gnuradio-tutorial3
)

GR_ADD_TEST(test_tutorial3 test-tutorial3)

########################################################################
# Print summary
########################################################################
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Building for version: ${VERSION} / ${LIBVER}")

I've tried adding following code:

########################################################################
# Install opennn library files
########################################################################
add_subdirectory(tinyxml2)
add_subdirectory(opennn)
include_directories(opennn)
add_subdirectory(examples)
add_subdirectory(blank)
add_subdirectory(tests)
include(CPack)

To be honest i've tried to modify this CMake file on many ways, but i'm always getting this error.

Paweł
  • 11
  • 3
  • 1
    // , This might seem a little nitpicky, but it may help you get an answer more quickly if you rephrase the title of this question into the form of, well, a *question*. Also, in troubleshooting sites, you generally post the error you're getting, and they walk you through reproducing it, finding the root cause, etc. Stackoverflow is a little different, though. It looks like if we were to have a conversation about it, I could reproduce your problem, but would you mind rephrasing your question as a step by step guide to reproducing it? – Nathan Basanese Jul 29 '17 at 21:54
  • I've changed title. Sorry for that, i'm used to use tags instead of full sentence in title. – Paweł Jul 29 '17 at 22:02
  • // , No problem. Usually, by the time I resort to a stackoverflow question, my mind is mush anyway. I have a friend with experience in gnuradio, I'll see if he finds this interesting. How do we reproduce this problem on our end? – Nathan Basanese Jul 29 '17 at 22:03
  • 1
    1. Create new module in gnuradio. 2. Create new block in gnu radio (general type). 3. In autogenerated files, add Opennn library from:http://www.opennn.net/ 4. Make minimal configuration of newly created block (add one input, one output, just to make sure it compiles) 5. In main source file [BLOCK_NAME]_impl.cpp import "opennn.h" 6. Add OpenNN::NeuralNetwork nn(8, 1, 1); this function to general_work method. 7. Next compile this block, add it to gnuradio. 8. In gnuradio create flow: Signal Source -> throttle->[OUR_BLOCK]->QT Time Sink 9. Execute flow graph. And thats it – Paweł Jul 29 '17 at 22:10
  • @Paweł did you ever get an answer to this one? - I made my own library and installed it (copied to /usr/shared/libs or such) and can use it with other generic c++ code using by compiling with the flag `-lmylib`. But when I want to use it with gnuradio - once I include the correct header file it seems to compile fine but I get the same error as you ... I am trying to fix this, no luck yet : ( – code_fodder Jan 02 '18 at 11:41
  • @code_fodder yes, the problem was in CMakeLists file, i had to add dependencies (in my case OpenNN library source files) so they'll be also compiled by using list(). E.g list(APPEND nn_sources nneural_impl.cc) //you can include multiple source files here //These were auto-generated add_library(gnuradio-nn SHARED ${nn_sources}) target_link_libraries( test-nn ${GNURADIO_RUNTIME_LIBRARIES} ${Boost_LIBRARIES} ${CPPUNIT_LIBRARIES} gnuradio-nn ) – Paweł Jun 24 '18 at 16:08

1 Answers1

0

Your question gave me the clues to solve my problem, which I think was the same as what is described here, but I'm not sure. The solution in my case was to add the missing external library yaml-cpp to the target_link_libraries directive in the file lib/CMakeLists.txt for my GnuRadio module.

target_link_libraries(gnuradio-AUK gnuradio::gnuradio-runtime yaml-cpp)

I was adding some C++ YAML code to parse configuration files. It compiled fine, but gave the incomprehensible message:

AttributeError: module ... has no attribute ...

All fixed now. Many thanks for the clues.