构建 CXX 对象 gnuradio-runtime 时出错

Error building CXX object gnuradio-runtime

我正在尝试安装特定版本的 gnuradio (3.7.10.1)。为此,我没有使用 Pybombs,但我尝试从源代码开始(我正在关注 this)。

首先我克隆了 github 存储库,然后检出合适的版本。它工作正常,直到我尝试调用 CMake 并构建 GNU Radio:

mkdir build
cd build
cmake ../
make

make 期间,完成 6% 后,出现以下错误:

In file included from /usr/include/c++/7/type_traits:35:0,
                 from /usr/include/cppunit/tools/StringHelper.h:7,
                 from /usr/include/cppunit/TestAssert.h:8,
                 from /usr/include/cppunit/TestCase.h:6,
                 from /usr/include/cppunit/TestCaller.h:5,
                 from /usr/include/cppunit/extensions/HelperMacros.h:9,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^~~~~
In file included from /usr/include/cppunit/TestAssert.h:8:0,
                 from /usr/include/cppunit/TestCase.h:6,
                 from /usr/include/cppunit/TestCaller.h:5,
                 from /usr/include/cppunit/extensions/HelperMacros.h:9,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/tools/StringHelper.h:22:15: error: ‘enable_if’ in namespace ‘std’ does not name a template type
 typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
               ^~~~~~~~~
/usr/include/cppunit/tools/StringHelper.h:22:24: error: expected unqualified-id before ‘<’ token
 typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x)
                        ^
/usr/include/cppunit/tools/StringHelper.h:31:15: error: ‘enable_if’ in namespace ‘std’ does not name a template type
 typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)
               ^~~~~~~~~
/usr/include/cppunit/tools/StringHelper.h:31:24: error: expected unqualified-id before ‘<’ token
 typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x)

In file included from /usr/include/cppunit/TestCase.h:6:0,
                 from /usr/include/cppunit/TestCaller.h:5,
                 from /usr/include/cppunit/extensions/HelperMacros.h:9,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestAssert.h: In static member function ‘static std::__cxx11::string CppUnit::assertion_traits<T>::toString(const T&)’:
/usr/include/cppunit/TestAssert.h:74:42: error: ‘toString’ is not a member of ‘CppUnit::StringHelper’
         return CPPUNIT_NS::StringHelper::toString(x);
                                          ^~~~~~~~
In file included from /usr/include/cppunit/extensions/HelperMacros.h:9:0,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestCaller.h: At global scope:
/usr/include/cppunit/TestCaller.h:159:37: error: ‘std::function’ has not been declared
   TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
                                     ^~~~~~~~
/usr/include/cppunit/TestCaller.h:159:45: error: expected ‘,’ or ‘...’ before ‘<’ token
   TestCaller(std::string name, std::function<void()> test_function, Fixture* fixture):
                                             ^
/usr/include/cppunit/TestCaller.h:200:8: error: ‘function’ in namespace ‘std’ does not name a template type
   std::function<void()> m_test_function;
        ^~~~~~~~
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod)’:
/usr/include/cppunit/TestCaller.h:121:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
      m_test_function( std::bind(test, m_fixture) )
      ^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:121:28: error: ‘bind’ is not a member of ‘std’
      m_test_function( std::bind(test, m_fixture) )
                            ^~~~
/usr/include/cppunit/TestCaller.h:121:28: note: suggested alternative: ‘find’
      m_test_function( std::bind(test, m_fixture) )
                            ^~~~
                            find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod, Fixture&)’:
/usr/include/cppunit/TestCaller.h:138:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
      m_test_function( std::bind(test, &fixture) )
      ^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:138:28: error: ‘bind’ is not a member of ‘std’
      m_test_function( std::bind(test, &fixture) )
                            ^~~~
/usr/include/cppunit/TestCaller.h:138:28: note: suggested alternative: ‘find’
      m_test_function( std::bind(test, &fixture) )
                            ^~~~
                            find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, CppUnit::TestCaller<Fixture>::TestMethod, Fixture*)’:
/usr/include/cppunit/TestCaller.h:155:6: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
      m_test_function( std::bind(test, fixture) )
      ^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:155:28: error: ‘bind’ is not a member of ‘std’
      m_test_function( std::bind(test, fixture) )
                            ^~~~
/usr/include/cppunit/TestCaller.h:155:28: note: suggested alternative: ‘find’
      m_test_function( std::bind(test, fixture) )
                            ^~~~
                            find
/usr/include/cppunit/TestCaller.h: In constructor ‘CppUnit::TestCaller<Fixture>::TestCaller(std::__cxx11::string, int)’:
/usr/include/cppunit/TestCaller.h:162:17: error: ‘fixture’ was not declared in this scope
       m_fixture(fixture),
                 ^~~~~~~
/usr/include/cppunit/TestCaller.h:162:17: note: suggested alternative: ‘Fixture’
       m_fixture(fixture),
                 ^~~~~~~
                 Fixture
/usr/include/cppunit/TestCaller.h:163:7: error: class ‘CppUnit::TestCaller<Fixture>’ does not have any field named ‘m_test_function’
       m_test_function(test_function)
       ^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:163:23: error: ‘test_function’ was not declared in this scope
       m_test_function(test_function)
                       ^~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h: In member function ‘void CppUnit::TestCaller<Fixture>::runTest()’:
/usr/include/cppunit/TestCaller.h:175:7: error: there are no arguments to ‘m_test_function’ that depend on a template parameter, so a declaration of ‘m_test_function’ must be available [-fpermissive]
       m_test_function();
       ^~~~~~~~~~~~~~~
/usr/include/cppunit/TestCaller.h:175:7: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
In file included from /usr/include/cppunit/extensions/HelperMacros.h:14:0,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/extensions/TestNamer.h: In member function ‘std::__cxx11::string CppUnit::TestNamer::getTestNameFor(const string&, const E&) const’:
/usr/include/cppunit/extensions/TestNamer.h:70:95: error: ‘toString’ is not a member of ‘CppUnit::StringHelper’
  return getTestNameFor(testMethodName) + " with parameter: " + CPPUNIT_NS::StringHelper::toString(val);
                                                                                          ^~~~~~~~
In file included from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26:0,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h: In static member function ‘static CppUnit::TestSuite* qa_fxpt::suite()’:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: ‘unique_ptr’ is not a member of ‘std’
   CPPUNIT_TEST_SUITE_END();
   ^
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: expected primary-expression before ‘>’ token
   CPPUNIT_TEST_SUITE_END();
   ^
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:36:3: error: ‘guard’ was not declared in this scope
   CPPUNIT_TEST_SUITE_END();
   ^
In file included from /usr/include/cppunit/extensions/HelperMacros.h:9:0,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.h:26,
                 from /home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:27:
/usr/include/cppunit/TestCaller.h: In instantiation of ‘void CppUnit::TestCaller<Fixture>::runTest() [with Fixture = qa_fxpt]’:
/home/cofex/workarea/gnuradio/gnuradio-runtime/lib/math/qa_fxpt.cc:102:1:   required from here
/usr/include/cppunit/TestCaller.h:175:22: error: ‘m_test_function’ was not declared in this scope
       m_test_function();
       ~~~~~~~~~~~~~~~^~
/usr/include/cppunit/TestCaller.h:175:22: note: suggested alternative: ‘__fortify_function’
       m_test_function();
       ~~~~~~~~~~~~~~~^~
       __fortify_function
gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/build.make:62: recipe for target 'gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/math/qa_fxpt.cc.o' failed
make[2]: *** [gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/math/qa_fxpt.cc.o] Error 1
CMakeFiles/Makefile2:726: recipe for target 'gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/all' failed
make[1]: *** [gnuradio-runtime/lib/CMakeFiles/test-gnuradio-runtime.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

我不是 Linux 专家,我对这种 compiler/library 支持不是很熟悉。我真的不明白错误来自哪里以及如何纠正它。 我使用 Ubuntu 18.04.

你能帮我一下吗? 任何帮助将不胜感激。 非常感谢。

/usr/include/c++/7/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

要解决上述错误,您需要使用 -std=c++11 标志进行编译。打开 CMakeLists.txt,找到所有出现的或 -std=c++98 并将它们更改为 -std=c++11。然后进入build目录,删除CMakeCache.txt并重建

sed -i 's/-std=c++98/-std=c++11/g' CMakeLists.txt
cd build
rm CMakeCache.txt
cmake ..
make

此外,由于错误在 cppunit 中并且它用于测试,您可以尝试禁用所有测试

cd build
rm CMakeCache.txt
cmake -DENABLE_TESTING=OFF ..
make