discuss-gnuradio
[Top][All Lists]
Advanced

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

Linking .so library leads to AttributeError: 'module' object has no attr


From: Massimo Isonni
Subject: Linking .so library leads to AttributeError: 'module' object has no attribute 'blockname'
Date: Fri, 22 Nov 2019 11:18:35 +0100

Hi,

I've been trying for 3 full days now to link a shared object library to my OOT module.
I am trying to link the libfec.so library in order to use the reed-solomon encoding and decoding functions.

As found on the internet i have made a FindFec.cmake file inside cmake/Modules as follows shown below.
I edited my CMakeLists.text in main directory adding find_package(Fec)
I added include dir to include_directories and Library to target_link_library in lib/CMakeLists.text
As shown below.
However whenever i cmake .. make sudo make install and sudo ldconfig if i run make tests or if i try to run python test from python IF a function from the library is used, and only in that case, an attribute not found error will show.
If i edit cpp test testing the class that is using the library function during compile time it will show that said function is not defined. i.e.:

CMakeFiles/test-AX100.dir/Encoder.cpp.o: nella funzione "Encoder::Encode(unsigned char*, int, char const*)":
Encoder.cpp:(.text+0x61): riferimento non definito a "encode_rs_8(unsigned char*, unsigned char*, int)"
collect2: error: ld returned 1 exit status
lib/CMakeFiles/test-AX100.dir/build.make:155: set di istruzioni per l'obiettivo "lib/test-AX100" non riuscito
make[2]: *** [lib/test-AX100] Errore 1
CMakeFiles/Makefile2:159: set di istruzioni per l'obiettivo "lib/CMakeFiles/test-AX100.dir/all" non riuscito
make[1]: *** [lib/CMakeFiles/test-AX100.dir/all] Errore 2
Makefile:140: set di istruzioni per l'obiettivo "all" non riuscito
make: *** [all] Errore 2

sadly it is in italian, however it says that reference to encode_rs_8() not defined.

While through python tests:

E
======================================================================
ERROR: test_001_t (__main__.qa_Msg_Encoder)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "qa_Msg_Encoder.py", line 35, in test_001_t
    enc = AX100.Msg_Encoder("in1","out1")
AttributeError: 'module' object has no attribute 'Msg_Encoder'

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

Thanks for your support!
Massimo

########################################################################
# Find gnuradio build dependencies
########################################################################
find_package(CppUnit)
find_package(Doxygen)

find_package(Fec)

# Search for GNU Radio and its components and versions. Add any
# components required to the list of GR_REQUIRED_COMPONENTS (in all
# caps such as FILTER or FFT) and change the version to the minimum
# API compatible version required.
set(GR_REQUIRED_COMPONENTS RUNTIME)
find_package(Gnuradio "3.7.2" REQUIRED)

if(NOT CPPUNIT_FOUND)
message(FATAL_ERROR "CppUnit required to compile AX100")
endif()


include(GrPlatform) #define LIB_SUFFIX

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

list(APPEND AX100_sources
Msg_Encoder_impl.cc
Encoder.cpp
Golay.cpp
)

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

add_library(gnuradio-AX100 SHARED ${AX100_sources})
target_link_libraries(gnuradio-AX100 ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${FEC_LIBRARY})
set_target_properties(gnuradio-AX100 PROPERTIES DEFINE_SYMBOL "gnuradio_AX100_EXPORTS")

if(APPLE)
set_target_properties(gnuradio-AX100 PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
)
endif(APPLE)


# Try to find FEC library and include path.
# Once done this will define
#
# FEC_INCLUDE_DIRS - where to find fec.h, etc.
# FEC_LIBRARIES - List of libraries when using libfec.
# FEC_FOUND - True if libfec found.

find_path(FEC_INCLUDE_DIR fec.h DOC "The directory where fec.h resides")
find_library(FEC_LIBRARY NAMES fec DOC "The libfec library")

if(FEC_INCLUDE_DIR AND FEC_LIBRARY)
set(FEC_FOUND 1)
set(FEC_LIBRARIES ${FEC_LIBRARY})
set(FEC_INCLUDE_DIRS ${FEC_INCLUDE_DIR})
else(FEC_INCLUDE_DIR AND FEC_LIBRARY)
set(FEC_FOUND 0)
set(FEC_LIBRARIES)
set(FEC_INCLUDE_DIRS)
endif(FEC_INCLUDE_DIR AND FEC_LIBRARY)

mark_as_advanced(FEC_INCLUDE_DIR)
mark_as_advanced(FEC_LIBRARY)
mark_as_advanced(FEC_FOUND)

if(NOT FEC_FOUND)
set(FEC_DIR_MESSAGE "libfec was not found. Make sure FEC_LIBRARY and FEC_INCLUDE_DIR are set.")
if(NOT FEC_FIND_QUIETLY)
message(STATUS "${FEC_DIR_MESSAGE}")
else(NOT FEC_FIND_QUIETLY)
if(FEC_FIND_REQUIRED)
message(FATAL_ERROR "${FEC_DIR_MESSAGE}")
endif(FEC_FIND_REQUIRED)
endif(NOT FEC_FIND_QUIETLY)
endif(NOT FEC_FOUND)



reply via email to

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