discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: C++ Boost QA-tests linking issues


From: David Myers
Subject: Re: C++ Boost QA-tests linking issues
Date: Mon, 5 Apr 2021 14:23:50 -0400

Solved!

The issue was the location of my header file for the class under test (Related_Clocks); it was inside the lib/ directory instead of the include/OOTM_NAME/ directory.

The class was able to compile when both the .cc and the .h file were located in the lib/ directory. However, for CMake to perform the correct linking during "make", the header file needs to be located in include/OOTM_NAME/ (along with the public api header files for the OOTM blocks). The class declaration also needs to include the OOTM_MODULE_API prefix as shown below:

>From gr-time_triggers/include/time_triggers/Related_Clocks.h:

#include <time_triggers/api.h>
namespace gr {
    namespace  time_triggers {
        class TIME_TRIGGERS_API Related_Clocks {
[...]

-David Myers

On Fri, Apr 2, 2021 at 1:09 PM David Myers <chalkedhands@gmail.com> wrote:

Hello all,

 

Longtime GNU Radio user, new member to the list here.

 

I can’t get any C++ (Boost) QA tests to run in my OOTM. Specifically, I'm running into this linking error during the "make" step.

 

usr/bin/ld: CMakeFiles/time_triggers_qa_Related_Clocks.cc.dir/qa_Related_Clocks.cc.o: in function `test_add1::test_method()': qa_Related_Clocks.cc:(.text+0x4d): undefined reference to `gr::time_triggers::Related_Clocks::Related_Clocks()'

 

I'm running GNU Radio 3.8.1.0 as installed from Ubuntu 20.04 apt-get. The class being tested (Related_Clocks) has no issues compiling/linking/installing when used in blocks.

 

I’ve really been beating my head against this one, and any guidance would be greatly appreciated!

Thank you!


From lib/CMakeLists.txt

--------------------------------------

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

list(APPEND time_triggers_sources
    Related_Clocks.cc
    multi_response_1_impl.cc
)

[...............]

########################################################################
# Build and register unit test
########################################################################
include(GrTest)
list(APPEND test_time_triggers_sources
    qa_Related_Clocks.cc
)
list(APPEND GR_TEST_TARGET_DEPS gnuradio-time_triggers)
foreach(qa_file ${test_time_triggers_sources})
    GR_ADD_CPP_TEST("time_triggers_${qa_file}"
        ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file}
    )
endforeach(qa_file)

From qa_Related_Clocks.cc:

-----------------------------------------

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gnuradio/attributes.h>
#include <stdio.h>
#include <boost/test/unit_test.hpp>
#include "Related_Clocks.h"

BOOST_AUTO_TEST_CASE(test_add1)
{
    gr::time_triggers::Related_Clocks clk;
    clk.add_clock("clk1", (uint64_t)0);
    clk.add_clock("clk2", (uint64_t)1);
    clk.set_time("clk1", (uint64_t)10);
    BOOST_REQUIRE_EQUAL(11, clk.get_time("clk2"));
}


reply via email to

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