CMake 3.16.x not building gRPC 1.23/1.26 anymore on Windows 10 (VS 2017) - cmake

My team and I are building gRPC using CMake. We have been building gRPC v1.26 (and v1.23 too) just fine with CMake 3.15.6, but since CMake 3.16.x is not building anymore.
This is the log of the tools we are using:
[29/32 0.2/sec] Performing configure step for 'grpc'
loading initial cache file C:/TCSoftware/build-frontend-Qt5132_MSVC17_cmake-Debug/_deps/grpc_src-build/grpc/tmp/grpc-cache-Debug.cmake
-- The C compiler identification is MSVC 19.16.27034.0
-- The CXX compiler identification is MSVC 19.16.27034.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Protobuf: C:/TCSoftware/build-frontend-Qt5132_MSVC17_cmake-Debug/install/external/lib/libprotobufd.lib (found version "3.8.0")
-- Found OpenSSL: optimized;C:/Program Files/OpenSSL-Win64/lib/VC/libcrypto64MD.lib;debug;C:/Program Files/OpenSSL-Win64/lib/VC/libcrypto64MDd.lib (found version "1.1.1d")
-- Found ZLIB: C:/TCSoftware/build-frontend-Qt5132_MSVC17_cmake-Debug/install/external/lib/zlibd.lib (found version "1.2.11")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/TCSoftware/build-frontend-Qt5132_MSVC17_cmake-Debug/_deps/grpc_src-build/grpc/src/grpc-build
After configure step, something fails in the build step. However as it can be seen the building process does not stop.
[30/32 0.1/sec] Performing build step for 'grpc'
FAILED: C:/TCSoftware/build-frontend-Qt5132_MSVC17_cmake-Debug/_deps/grpc_src-build/grpc/src/grpc-stamp/grpc-build
cmd.exe /C "cd /D C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\_deps\grpc_src-build\grpc\src\grpc-build && "C:\Program Files\CMake\bin\cmake.exe" --build . && "C:\Program Files\CMake\bin\cmake.exe" -E touch C:/TCSoftware/build-frontend-Qt5132_MSVC17_cmake-Debug/_deps/grpc_src-build/grpc/src/grpc-stamp/grpc-build"
[1/1580 1.3/sec] Building CXX object CMakeFiles\grpc_cronet.dir\src\core\lib\iomgr\udp_server.cc.obj
[2/1580 2.5/sec] Building CXX object CMakeFiles\grpc_cronet.dir\src\core\lib\iomgr\timer_heap.cc.obj
[3/1580 3.3/sec] Building CXX object CMakeFiles\grpc_cronet.dir\src\core\lib\iomgr\timer.cc.obj
It builds a lot of objects until it starts showing strange warnings as follows, but it still keeps building.
[975/1580 5.8/sec] Linking CXX static library gpr.lib
[976/1580 5.8/sec] Linking C static library address_sorting.lib
[977/1580 5.8/sec] Building CXX object CMakeFiles\grpc.dir\src\core\lib\backoff\backoff.cc.obj
...
[982/1580 5.8/sec] Building CXX object CMakeFiles\grpc_ruby_plugin.dir\src\compiler\ruby_plugin.cc.obj
C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\include\google/protobuf/stubs/logging.h(102): warning C4251: 'google::protobuf::internal::LogMessage::message_': class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'google::protobuf::internal::LogMessage'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xstring(4373): note: see declaration of 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\include\google/protobuf/arena_impl.h(251): warning C4251: 'google::protobuf::internal::ArenaImpl::lifecycle_id_generator_': struct 'std::atomic<__int64>' needs to have dll-interface to be used by clients of class 'google::protobuf::internal::ArenaImpl'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xxatomic(162): note: see declaration of 'std::atomic<__int64>'
More warnings are shown as follows:
[1531/1580 5.5/sec] Building CXX object CMakeFiles\grpc_print_google_default_creds_token.dir\test\core\security\print_google_default_creds_token.cc.obj
[1532/1580 5.5/sec] Linking CXX static library grpc++.lib
server_posix.cc.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
rpc_method.cc.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
create_channel_posix.cc.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
[1533/1580 5.5/sec] Linking CXX static library grpc_plugin_support.lib
[1534/1580 5.5/sec] Building CXX object CMakeFiles\grpc_create_jwt.dir\test\core\security\create_jwt.cc.obj
[1535/1580 5.5/sec] Linking CXX static library grpc++_unsecure.lib
server_posix.cc.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
rpc_method.cc.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
create_channel_posix.cc.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
[1536/1580 5.5/sec] Building CXX object CMakeFiles\grpc_create_jwt.dir\test\core\util\cmdline.cc.obj
[1537/1580 5.5/sec] Linking CXX executable grpc_ruby_plugin.exe
FAILED: grpc_ruby_plugin.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\grpc_ruby_plugin.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe /nologo CMakeFiles\grpc_ruby_plugin.dir\src\compiler\ruby_plugin.cc.obj /out:grpc_ruby_plugin.exe /implib:grpc_ruby_plugin.lib /pdb:grpc_ruby_plugin.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotocd.lib C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotobufd.lib grpc_plugin_support.lib C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotocd.lib C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotobufd.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe /nologo CMakeFiles\grpc_ruby_plugin.dir\src\compiler\ruby_plugin.cc.obj /out:grpc_ruby_plugin.exe /implib:grpc_ruby_plugin.lib /pdb:grpc_ruby_plugin.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotocd.lib C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotobufd.lib grpc_plugin_support.lib C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotocd.lib C:\TCSoftware\build-frontend-Qt5132_MSVC17_cmake-Debug\install\external\lib\libprotobufd.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\grpc_ruby_plugin.dir/intermediate.manifest CMakeFiles\grpc_ruby_plugin.dir/manifest.res" failed (exit code 1120) with the following output:
ruby_plugin.cc.obj : warning LNK4217: locally defined symbol ?name#FileDescriptor#protobuf#google##QEBAAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ (public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl google::protobuf::FileDescriptor::name(void)const ) imported in function "bool __cdecl grpc_ruby_generator::ServicesFilename(class google::protobuf::FileDescriptor const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?ServicesFilename#grpc_ruby_generator##YA_NPEBVFileDescriptor#protobuf#google##PEAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std###Z)
grpc_plugin_support.lib(ruby_generator.cc.obj) : warning LNK4049: locally defined symbol ?name#FileDescriptor#protobuf#google##QEBAAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ (public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl google::protobuf::FileDescriptor::name(void)const ) imported
ruby_plugin.cc.obj : warning LNK4217: locally defined symbol ??0CodedOutputStream#io#protobuf#google##QEAA#PEAVZeroCopyOutputStream#123##Z (public: __cdecl google::protobuf::io::CodedOutputStream::CodedOutputStream(class google::protobuf::io::ZeroCopyOutputStream *)) imported in function "public: virtual bool __cdecl RubyGrpcGenerator::Generate(class google::protobuf::FileDescriptor const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class google::protobuf::compiler::GeneratorContext *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)const " (?Generate#RubyGrpcGenerator##UEBA_NPEBVFileDescriptor#protobuf#google##AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PEAVGeneratorContext#compiler#34#PEAV56##Z)
Build stops after a lot of the above warnings with the following log:
ruby_plugin.cc.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public:
__cdecl google::protobuf::compiler::CodeGenerator::CodeGenerator(void)" (__imp_??0CodeGenerator#compiler#protobuf#google##QEAA#XZ) referenced in function "public: __cdecl RubyGrpcGenerator::RubyGrpcGenerator(void)" (??0RubyGrpcGenerator##QEAA#XZ)
ruby_plugin.cc.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl google::protobuf::compiler::PluginMain(int,char * * const,class google::protobuf::compiler::CodeGenerator const *)" (__imp_?PluginMain#compiler#protobuf#google##YAHHQEAPEADPEBVCodeGenerator#123##Z) referenced in function "int __cdecl grpc::protobuf::compiler::PluginMain(int,char * * const,class google::protobuf::compiler::CodeGenerator const *)" (?PluginMain#compiler#protobuf#grpc##YAHHQEAPEADPEBVCodeGenerator#12google###Z)
grpc_plugin_support.lib(ruby_generator.cc.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const & __cdecl google::protobuf::Descriptor::name(void)const " (__imp_?name#Descriptor#protobuf#google##QEBAAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##XZ) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl grpc_ruby_generator::RubyTypeOf(class google::protobuf::Descriptor const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?RubyTypeOf#grpc_ruby_generator##YA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PEBVDescriptor#protobuf#google##AEBV23##Z)
The only thing changed between working build and not working one is: removing build folder, uninstall CMake 3.15.x, reboot, install CMake 3.16.0, build grpc all over again.
Anyone faced something like this? Thank you

Related

Link errors when using CMake and VCPKG with GoogleTest

As a bit of background, I have a project that I have been developing with Visual Studio and VCPKG manifest mode for some time, it contains one static library project and one unit test project. Everything has been working correctly. I'm now trying to migrate this solution to use CMake, this is my first time using CMake.
With CMake the VCPKG dependencies install correctly, and both the static library and unit tests compile, however it fails on the linking step with a large number of linker errors all related to the GoogleTest library. Here is the first, as an example:
CppSlippiTest.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl testing::internal::FormatMatcherDescription(bool,char const *,class std::vector<char const*,class std::allocator<char const *> > const &,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > const &)" (?FormatMatcherDescription#internal#testing##YA?AV$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##_NPEBDAEBV?$vector#PEBDV$allocator#PEBD#std###4#AEBV?$vector#V?$basic_string#DU?$char_traits#D#std##V$allocator#D#2##std##V?$allocator#V?$basic_string#DU$char_traits#D#std##V?$allocator#D#2##std###2##4##Z) referenced in function "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl cpp_slippi::MatchOptionalMatcherP2<class testing::internal::Eq2Matcher,class std::optional<unsigned char> >::gmock_Impl<class std::optional<unsigned char> const &>::FormatDescription(bool)const " (?FormatDescription#$gmock_Impl#AEBV?$optional#E#std###$MatchOptionalMatcherP2#VEq2Matcher#internal#testing##V?$optional#E#std###cpp_slippi##AEBA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##_N#Z) [C:\Users\Derek\Projects\CppSlippi\build\Test.vcxproj]
There are 36 more of these.
Here is my CMakeLists.txt, slightly abridged for clarity:
cmake_minimum_required(VERSION 3.12...3.24)
# Must be before project()
set(VCPKG_TARGET_TRIPLET x64-windows-static)
project(CppSlippi
VERSION 1.0
DESCRIPTION "Slippi replay file parsing library for C++."
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(GTest CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
add_library(CppSlippi STATIC
CppSlippi/src/CppSlippi.cpp
CppSlippi/src/CppSlippi.h
...)
target_include_directories(CppSlippi PUBLIC CppSlippi/src)
target_compile_features(CppSlippi PUBLIC cxx_std_20)
target_compile_options(CppSlippi PUBLIC /MTd)
set_target_properties(CppSlippi PROPERTIES CXX_EXTENSIONS OFF)
target_link_libraries(CppSlippi PUBLIC nlohmann_json::nlohmann_json)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
include(GoogleTest)
endif()
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_executable(Test
Test/src/CppSlippiTest.cpp
...)
target_include_directories(Test PUBLIC Test/src)
target_compile_features(Test PUBLIC cxx_std_20)
target_compile_options(Test PRIVATE /bigobj /MTd)
set_target_properties(Test PROPERTIES CXX_EXTENSIONS OFF)
target_link_libraries(Test PUBLIC
CppSlippi
nlohmann_json::nlohmann_json
GTest::gtest_main)
gtest_discover_tests(Test)
endif()
Here is my VCPKG manifest:
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"name": "cpp-slippi",
"version": "1.0.0",
"description": "C++ Slippi replay parser.",
"builtin-baseline": "68b7fec22eb5fd9c0236b1e42b3c0deb8e771b37",
"dependencies": [
"gtest",
"nlohmann-json"
],
"supports": "windows"
}
And to build this I am running:
cmake --build build --target Test
I turned on --verbose to get more information, and this is the link command that CMake is running:
Link:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\HostX64\x64\link.exe /ERRORREPO
RT:QUEUE /OUT:"C:\Users\Derek\Projects\CppSlippi\build\Debug\Test.exe" /INCREMENTAL /ILK:"Test.dir\Debug\Test.ilk" /N
OLOGO /NATVIS:"C:\Users\Derek\Projects\CppSlippi\build\vcpkg_installed\x64-windows-static\share\nlohmann_json\nlohman
n_json.natvis" Debug\CppSlippi.lib "vcpkg_installed\x64-windows-static\debug\lib\manual-link\gtest_main.lib" "vcpkg_i
nstalled\x64-windows-static\debug\lib\gtest.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifes
t:embed /DEBUG /PDB:"C:/Users/Derek/Projects/CppSlippi/build/Debug/Test.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE
/NXCOMPAT /IMPLIB:"C:/Users/Derek/Projects/CppSlippi/build/Debug/Test.lib" /MACHINE:X64 /machine:x64 Test.dir\Debug
\CppSlippiTest.obj ...
Note the presence of gtest_main.lib and gtest.lib, these are the libraries that I believe should include the missing functions. I have checked that these files are present at the locations shown.
I know that in Visual Studio using the GoogleTest main requires adding an AdditionalDependency manually, but from all the instructions I can find this should not be necessary in CMake and the .lib is already in the command line. I did try using target_link_directories anyways, but this did not help.
At this point I am baffled and searching on Google and Stack Overflow has failed to turn up any help.
You link only one of 4 GoogleTest libraries to your app
target_link_libraries(Test PUBLIC
CppSlippi
nlohmann_json::nlohmann_json
GTest::gtest_main)
Depending on the application needs, it should be linked to at least one more library
target_link_libraries(Test PUBLIC
CppSlippi
nlohmann_json::nlohmann_json
GTest::gtest_main
GTest::gtest)
Or
target_link_libraries(Test PUBLIC
CppSlippi
nlohmann_json::nlohmann_json
GTest::gmock_main
GTest::gmock
GTest::gtest)

flatbuffers - unable to compile with cygwin

I am trying to compile flatbuffers with cygwin.
Here is what I do:
git clone https://github.com/google/flatbuffers.git && cd ./flatbuffers
Than:
cmake .
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for strtof_l
-- Looking for strtof_l - not found
-- Looking for strtoull_l
-- Looking for strtoull_l - not found
-- `tests/monster_test.fbs`: add generation of C++ code with '--no-includes;--gen-compare'
-- `tests/monster_test.fbs`: add generation of binary (.bfbs) schema
-- `tests/namespace_test/namespace_test1.fbs`: add generation of C++ code with '--no-includes;--gen-compare'
-- `tests/namespace_test/namespace_test2.fbs`: add generation of C++ code with '--no-includes;--gen-compare'
-- `tests/union_vector/union_vector.fbs`: add generation of C++ code with '--no-includes;--gen-compare'
-- `tests/optional_scalars.fbs`: add generation of C++ code with '--no-includes;--gen-compare'
-- `tests/native_type_test.fbs`: add generation of C++ code with ''
-- `tests/arrays_test.fbs`: add generation of C++ code with '--scoped-enums;--gen-compare'
-- `tests/arrays_test.fbs`: add generation of binary (.bfbs) schema
-- `tests/monster_test.fbs`: add generation of C++ embedded binary schema code with '--no-includes;--gen-compare'
-- `tests/monster_extra.fbs`: add generation of C++ code with '--no-includes;--gen-compare'
-- `samples/monster.fbs`: add generation of C++ code with '--no-includes;--gen-compare'
-- `samples/monster.fbs`: add generation of binary (.bfbs) schema
Proceeding with version: 1.12.0.177
-- Configuring done
-- Generating done
-- Build files have been written to: /home/Vivas/flatbuffers
And when I run:
$ make
Scanning dependencies of target flatbuffers
[ 1%] Building CXX object CMakeFiles/flatbuffers.dir/src/idl_parser.cpp.o
[ 2%] Building CXX object CMakeFiles/flatbuffers.dir/src/idl_gen_text.cpp.o
[ 3%] Building CXX object CMakeFiles/flatbuffers.dir/src/reflection.cpp.o
[ 4%] Building CXX object CMakeFiles/flatbuffers.dir/src/util.cpp.o
[ 5%] Linking CXX static library libflatbuffers.a
[ 5%] Built target flatbuffers
Scanning dependencies of target flatc
[ 6%] Building CXX object CMakeFiles/flatc.dir/src/idl_parser.cpp.o
[ 7%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_text.cpp.o
[ 9%] Building CXX object CMakeFiles/flatc.dir/src/reflection.cpp.o
[ 10%] Building CXX object CMakeFiles/flatc.dir/src/util.cpp.o
[ 11%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_cpp.cpp.o
[ 12%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_csharp.cpp.o
[ 13%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_dart.cpp.o
[ 14%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_kotlin.cpp.o
[ 15%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_go.cpp.o
[ 17%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_java.cpp.o
[ 18%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_js_ts.cpp.o
[ 19%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_php.cpp.o
[ 20%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_python.cpp.o
[ 21%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_lobster.cpp.o
[ 22%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_lua.cpp.o
[ 23%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_rust.cpp.o
[ 25%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_fbs.cpp.o
[ 26%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_grpc.cpp.o
[ 27%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_json_schema.cpp.o
[ 28%] Building CXX object CMakeFiles/flatc.dir/src/idl_gen_swift.cpp.o
[ 29%] Building CXX object CMakeFiles/flatc.dir/src/flatc.cpp.o
[ 30%] Building CXX object CMakeFiles/flatc.dir/src/flatc_main.cpp.o
[ 31%] Building CXX object CMakeFiles/flatc.dir/src/code_generators.cpp.o
[ 32%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/cpp_generator.cc.o
[ 34%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/go_generator.cc.o
[ 35%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/java_generator.cc.o
[ 36%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/python_generator.cc.o
[ 37%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/swift_generator.cc.o
[ 38%] Building CXX object CMakeFiles/flatc.dir/grpc/src/compiler/ts_generator.cc.o
[ 39%] Linking CXX executable flatc.exe
[ 39%] Built target flatc
Scanning dependencies of target generated_code
[ 40%] Run generation: 'samples/monster.bfbs'
[ 42%] Run generation: 'tests/monster_test_generated.h'
[ 43%] Run generation: 'tests/monster_test.bfbs'
[ 44%] Run generation: 'tests/namespace_test/namespace_test1_generated.h'
[ 45%] Run generation: 'tests/namespace_test/namespace_test2_generated.h'
[ 46%] Run generation: 'tests/union_vector/union_vector_generated.h'
[ 47%] Run generation: 'tests/optional_scalars_generated.h'
[ 48%] Run generation: 'tests/native_type_test_generated.h'
[ 50%] Run generation: 'tests/arrays_test_generated.h'
[ 51%] Run generation: 'tests/arrays_test.bfbs'
[ 52%] Run generation: 'tests/monster_test_bfbs_generated.h'
[ 53%] Run generation: 'tests/monster_extra_generated.h'
[ 54%] Run generation: 'samples/monster_generated.h'
[ 55%] All generated files were updated.
[ 55%] Built target generated_code
Scanning dependencies of target flatsamplebfbs
[ 56%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/idl_parser.cpp.o
[ 57%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/idl_gen_text.cpp.o
[ 59%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/reflection.cpp.o
[ 60%] Building CXX object CMakeFiles/flatsamplebfbs.dir/src/util.cpp.o
[ 61%] Building CXX object CMakeFiles/flatsamplebfbs.dir/samples/sample_bfbs.cpp.o
[ 62%] Linking CXX executable flatsamplebfbs.exe
[ 63%] Built target flatsamplebfbs
Scanning dependencies of target flatsampletext
[ 64%] Building CXX object CMakeFiles/flatsampletext.dir/src/idl_parser.cpp.o
[ 65%] Building CXX object CMakeFiles/flatsampletext.dir/src/idl_gen_text.cpp.o
[ 67%] Building CXX object CMakeFiles/flatsampletext.dir/src/reflection.cpp.o
[ 68%] Building CXX object CMakeFiles/flatsampletext.dir/src/util.cpp.o
[ 69%] Building CXX object CMakeFiles/flatsampletext.dir/samples/sample_text.cpp.o
[ 70%] Linking CXX executable flatsampletext.exe
[ 71%] Built target flatsampletext
Scanning dependencies of target flathash
[ 72%] Building CXX object CMakeFiles/flathash.dir/src/flathash.cpp.o
[ 73%] Linking CXX executable flathash.exe
[ 73%] Built target flathash
Scanning dependencies of target flattests
[ 75%] Building CXX object CMakeFiles/flattests.dir/src/idl_parser.cpp.o
[ 76%] Building CXX object CMakeFiles/flattests.dir/src/idl_gen_text.cpp.o
[ 77%] Building CXX object CMakeFiles/flattests.dir/src/reflection.cpp.o
[ 78%] Building CXX object CMakeFiles/flattests.dir/src/util.cpp.o
[ 79%] Building CXX object CMakeFiles/flattests.dir/src/idl_gen_fbs.cpp.o
[ 80%] Building CXX object CMakeFiles/flattests.dir/tests/test.cpp.o
/home/Vivas/flatbuffers/tests/test.cpp:66:19: error: ‘const auto infinityf’ redeclared as different kind of entity
66 | static const auto infinityf = std::numeric_limits<float>::infinity();
| ^~~~~~~~~
In file included from /usr/lib/gcc/x86_64-pc-cygwin/10/include/c++/cmath:45,
from /home/Vivas/flatbuffers/tests/test.cpp:16:
/usr/include/math.h:398:14: note: previous declaration ‘float infinityf()’
398 | extern float infinityf (void);
| ^~~~~~~~~
In file included from /home/Vivas/flatbuffers/tests/test.cpp:45:
/home/Vivas/flatbuffers/tests/test.cpp: In function ‘void TestMonsterExtraFloats()’:
/home/Vivas/flatbuffers/tests/test.cpp:702:25: error: wrong type argument to unary minus
702 | TEST_EQ(is_quiet_nan(-infinityf), false);
| ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:34: note: in definition of macro ‘TEST_EQ’
19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
| ^~~
/home/Vivas/flatbuffers/tests/test.cpp:731:29: error: wrong type argument to unary minus
731 | TEST_EQ(def_extra->f3(), -infinityf);
| ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
| ^~~
/home/Vivas/flatbuffers/tests/test.cpp:762:25: error: wrong type argument to unary minus
762 | TEST_EQ(extra->f3(), -infinityf);
| ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
| ^~~
/home/Vivas/flatbuffers/tests/test.cpp:770:35: error: wrong type argument to unary minus
770 | TEST_EQ(extra->fvec()->Get(1), -infinityf);
| ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
| ^~~
/home/Vivas/flatbuffers/tests/test.cpp: In function ‘void ValidFloatTest()’:
/home/Vivas/flatbuffers/tests/test.cpp:1971:60: error: wrong type argument to unary minus
1971 | TEST_EQ(TestValue<float>("{ y:-3.4029e+38 }", "float"), -infinityf);
| ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
| ^~~
/home/Vivas/flatbuffers/tests/test.cpp:2015:53: error: wrong type argument to unary minus
2015 | TEST_EQ(TestValue<float>("{ y:-inf }", "float"), -infinityf);
| ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
| ^~~
/home/Vivas/flatbuffers/tests/test.cpp:2017:53: error: wrong type argument to unary minus
2017 | TEST_EQ(TestValue<float>(nullptr, "float=-inf"), -infinityf);
| ^~~~~~~~~
/home/Vivas/flatbuffers/tests/test_assert.h:19:39: note: in definition of macro ‘TEST_EQ’
19 | #define TEST_EQ(exp, val) TestEq(exp, val, "'" #exp "' != '" #val "'", __FILE__, __LINE__, "")
| ^~~
/home/Vivas/flatbuffers/tests/test_assert.h: In instantiation of ‘void TestEq(T, U, const char*, const char*, int, const char*) [with T = float; U = float (*)()]’:
/home/Vivas/flatbuffers/tests/test.cpp:730:3: required from here
/home/Vivas/flatbuffers/tests/test_assert.h:92:7: error: invalid ‘static_cast’ from type ‘float’ to type ‘float (*)()’
92 | if (static_cast<U>(expval) != val) {
| ^~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/flattests.dir/build.make:184: CMakeFiles/flattests.dir/tests/test.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:247: CMakeFiles/flattests.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
Why is that, and how can I fix it?
Easiest would be to rename infinityf (at tests/test.cpp:66:19) and its uses to something different. If that makes it compile, open a PR on https://github.com/google/flatbuffers with your changes.
It seems like it is clashing with things declared in the cmath header. I am not sure why this happens with cygwin and not on other platform we build for gcc?
Also note this is in the tests, which you don't strictly need to build. Invoking CMake with -DFLATBUFFERS_BUILD_TESTS=OFF would likely also work.

Linking C++ on Rust: undefined reference to `operator delete(void*)' and `__gxx_personality_v0', libstdc++ missing?

I'm trying to build a cpp cmake project and link to my Rust project.
cmake_minimum_required(VERSION 3.0)
set (CMAKE_CXX_STANDARD 17)
project(ZLMediaKit_LIB CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(ENABLE_TESTS OFF FORCE)
option(ENABLE_TESTS OFF)
set(ENABLE_OPENSSL FALSE FORCE)
option(ENABLE_OPENSSL OFF)
add_subdirectory(ZLMediaKit)
add_library(libzlmediakit_cpp_interface STATIC interface.cpp)
target_include_directories(libzlmediakit_cpp_interface PUBLIC
.
${CMAKE_CURRENT_SOURCE_DIR}/ZLMediaKit/src
${CMAKE_CURRENT_SOURCE_DIR}/ZLMediaKit/3rdpart/ZLToolKit/src)
target_link_libraries(libzlmediakit_cpp_interface zlmediakit zltoolkit mpeg mov flv libstdc++)
install(TARGETS libzlmediakit_cpp_interface DESTINATION .)
Here's my build.rs:
extern crate cmake;
use cmake::Config;
fn main()
{
let dst = Config::new("zlmediakit_lib").build();
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=static=libzlmediakit_cpp_interface");
}
But I'm getting undefined reference errors:
ong)':
/usr/include/c++/9/ext/new_allocator.h:128: undefined reference to `operator delete(void*)'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o): in function `ZLRTSPClient::~ZLRTSPClient()':
/home/dev/orwell/liborwell_rust/zlmediakit_rust/zlmediakit_lib/ZLRTSPClient.h:14: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o): in function `std::default_delete<ZLRTSPClient>::operator()(ZLRTSPClient*) const':
/usr/include/c++/9/bits/unique_ptr.h:81: undefined reference to `operator delete(void*, unsigned long)'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o): in function `__static_initialization_and_destruction_0(int, int)':
/usr/include/c++/9/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/bin/ld: /usr/include/c++/9/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
/usr/bin/ld: /home/dev/orwell/liborwell_rust/zlmediakit_rust/target/debug/build/zlmediakit_rust-499cc82f14515635/out/liblibzlmediakit_cpp_interface.a(interface.cpp.o):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
I've researched and found some answers (Link error "undefined reference to `__gxx_personality_v0'" and g++) that old me to link against libstdc++. As you see, I'm already doing that.
If I try to compile the CMake project alone, it links sucessfully. However then I compile everything from the Rust side, it gives this error.
Complete output of rust compilation

cmake not linking my class I think, mistakes in cmakelists.text likely culprit

I think, I may have improperly set up cmake wrong,(or improperly set up cmake for that matter) or I'm bad and rusty at C++ or both and possibly more. I just want to add a header and separate code into a class that loads images for opengl. I also put them in another directory parallel to other libraries in my linux file tree.
The main project folder has the main cmakelists.text file in it it's called "maficengine". Inside it are also a "build" file a "common" file and "external" file and a file called "Mafic", "maficGuiSourceFiles" file and one called "distrib." I think we can just focus on 2. "mafic" and "external". Inside mafic I have one called mafic.cpp which has my main function and is the entry point. Inside external, there is another folder called "myCustomHeaders".. therein lies a file called "loadTexture.cpp" It contains the loadTexture class declaration and definition. Also inside "myCustomHeaders" there is an "include" file which contains "loadTexture.h"... I cannot seem to instanciate an instance of LoadTexture lt; and call the function of loadtexture(); I expect it to at line 187 in mafic.cpp
#cmakelists.text file from main project folder
# CMake entry point
cmake_minimum_required (VERSION 3.0)
project (maficengine )
find_package(OpenGL REQUIRED)
add_library(loaders
external/myCustomHeaders/loadTexture.cpp
external/myCustomHeaders/include/loadTexture.h
)
set(SOURCES external/myCustomHeaders/loadTexture.cpp )
# Compile external dependencies
add_subdirectory (external)
# On Visual 2005 and above, this module can set the debug working directory
cmake_policy(SET CMP0026 OLD)
cmake_policy(SET CMP0079 NEW)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/rpavlik-cmake-modules-fe2273")
include(CreateLaunchers)
include(MSVCMultipleProcessCompile) # /MP
if(INCLUDE_DISTRIB)
add_subdirectory(distrib)
endif(INCLUDE_DISTRIB)
include_directories(
external/AntTweakBar-1.16/include/
external/glfw-3.1.2/include/
external/glm-0.9.7.1/
external/glew-1.13.0/include/
external/assimp-3.0.1270/include/
external/bullet-2.81-rev2613/src/
external/myCustomHeaders/include
common/
)
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
GLEW_1130
loaders
)
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
# Tutorial 17
add_executable(mageengine
Mafic/mafic.cpp
common/shader.cpp
common/shader.hpp
common/controls.cpp
common/controls.hpp
common/texture.cpp
common/texture.hpp
common/objloader.cpp
common/objloader.hpp
common/vboindexer.cpp
common/vboindexer.hpp
common/quaternion_utils.cpp
common/quaternion_utils.hpp
#Mafic/loadTexture.h
#Mafic/loadTexture.cpp
Mafic/StandardShading.vertexshader
Mafic/StandardShading.fragmentshader
)
target_link_libraries(mageengine
${ALL_LIBS}
ANTTWEAKBAR_116_OGLCORE_GLFW
loaders
)
here's mafic.cpp
#include <loadTexture.h>
int main( void )
{
loadTexture lt;
lt.loadtexture();
}
here's my loadTexture.cpp
class loadTexture
{
public:
loadTexture();
~loadTexture();
void loadtexture(){
fprintf(stdout, "loadtexture does something, that's a positive result for this test");
}
};
and finally my loadTexture.h
[code]
#pragma once
#include <GL/glew.h>
//GLuint image;
void loadtexture();
[/code]
Hoping it would build with no errors but I get ...
aaron#Zog:~/Desktop/maficengine/build$ make
[ 2%] Built target ANTTWEAKBAR_116_OGLCORE_GLFW
[ 2%] Built target GLEW_1130
[ 2%] Built target loaders
[ 6%] Built target glfw
[ 7%] Building CXX object CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o
/home/aaron/Desktop/maficengine/Mafic/mafic.cpp:1:9: warning: #pragma once in main file
#pragma once
^~~~
/home/aaron/Desktop/maficengine/Mafic/mafic.cpp: In function ‘int main()’:
/home/aaron/Desktop/maficengine/Mafic/mafic.cpp:187:1: error: ‘loadTexture’ was not declared in this scope
loadTexture lt;
^~~~~~~~~~~
/home/aaron/Desktop/maficengine/Mafic/mafic.cpp:187:1: note: suggested alternative: ‘loadtexture’
loadTexture lt;
^~~~~~~~~~~
loadtexture
/home/aaron/Desktop/maficengine/Mafic/mafic.cpp:189:2: error: ‘lt’ was not declared in this scope
lt.loadtexture();
^~
CMakeFiles/mageengine.dir/build.make:62: recipe for target 'CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o' failed
make[2]: *** [CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/mageengine.dir/all' failed
make[1]: *** [CMakeFiles/mageengine.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
aaron#Zog:~/Desktop/maficengine/build$

Cmake building error,trying to install gnuradio-mediatools.amodule in GNURadio

The module can be find Here
I think maybe some dependencies errors occured,anyone who has an idea will be great~
What I find important is
lib/CMakeFiles/gnuradio-mediatools.dir/build.make:86: recipe for target 'lib/CMakeFiles/gnuradio-mediatools.dir/mediatools_audiosource_impl.cc.o' failed
The whole list as follow:
imatrix#Zero:~/下载/GNU/ 模块/gr-mediatools-master/build$ make -j4
Scanning dependencies of target mediatools_swig_swig_doc
Scanning dependencies of target pygen_python_aead6
Scanning dependencies of target pygen_apps_9a6dd
Scanning dependencies of target gnuradio-mediatools
[ 0%] Built target mediatools_swig_swig_doc
[ 5%] Generating __init__.pyc
[ 5%] Built target pygen_apps_9a6dd
Scanning dependencies of target _mediatools_swig_swig_tag
[ 11%] Generating __init__.pyo
[ 17%] Building CXX object swig/CMakeFiles/_mediatools_swig_swig_tag.dir/_mediatools_swig_swig_tag.cpp.o
[ 23%] Building CXX object lib/CMakeFiles/gnuradio-mediatools.dir/mediatools_audiosource_s.cc.o
[ 29%] Building CXX object lib/CMakeFiles/gnuradio-mediatools.dir/mediatools_audiosource_impl.cc.o
[ 35%] Linking CXX executable _mediatools_swig_swig_tag
[ 35%] Built target pygen_python_aead6
[ 35%] Built target _mediatools_swig_swig_tag
[ 41%] Generating mediatools_swig.tag
Scanning dependencies of target mediatools_swig_swig_2d0df
[ 47%] Building CXX object swig/CMakeFiles/mediatools_swig_swig_2d0df.dir/mediatools_swig_swig_2d0df.cpp.o
[ 52%] Linking CXX executable mediatools_swig_swig_2d0df
Swig source
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc: In member function ‘bool mediatools_audiosource_impl::open(std::__cxx11::string)’:
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:42:58: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
d_codec_ctx = d_format_ctx->streams[stream_idx]->codec;
^
In file included from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/include/mediatools_audiosource_impl.h:11:0,
from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:1:
/usr/local/include/libavformat/avformat.h:893:21: note: declared here
AVCodecContext *codec;
^
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:42:58: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
d_codec_ctx = d_format_ctx->streams[stream_idx]->codec;
^
In file included from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/include/mediatools_audiosource_impl.h:11:0,
from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:1:
/usr/local/include/libavformat/avformat.h:893:21: note: declared here
AVCodecContext *codec;
^
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:42:58: warning: ‘AVStream::codec’ is deprecated [-Wdeprecated-declarations]
d_codec_ctx = d_format_ctx->streams[stream_idx]->codec;
^
In file included from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/include/mediatools_audiosource_impl.h:11:0,
from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:1:
/usr/local/include/libavformat/avformat.h:893:21: note: declared here
AVCodecContext *codec;
^
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc: In member function ‘void mediatools_audiosource_impl::readData(std::vector<short int>&)’:
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:91:39: error: ‘avcodec_alloc_frame’ was not declared in this scope
d_frame = avcodec_alloc_frame();
^
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:95:14: warning: ‘int avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, const AVPacket*)’ is deprecated [-Wdeprecated-declarations]
int rc = avcodec_decode_audio4(d_codec_ctx, d_frame, &got_frame, &d_packet);
^
In file included from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/include/mediatools_audiosource_impl.h:10:0,
from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:1:
/usr/local/include/libavcodec/avcodec.h:4817:5: note: declared here
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
^
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:95:14: warning: ‘int avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, const AVPacket*)’ is deprecated [-Wdeprecated-declarations]
int rc = avcodec_decode_audio4(d_codec_ctx, d_frame, &got_frame, &d_packet);
^
In file included from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/include/mediatools_audiosource_impl.h:10:0,
from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:1:
/usr/local/include/libavcodec/avcodec.h:4817:5: note: declared here
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
^
/home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:95:79: warning: ‘int avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, const AVPacket*)’ is deprecated [-Wdeprecated-declarations]
int rc = avcodec_decode_audio4(d_codec_ctx, d_frame, &got_frame, &d_packet);
^
In file included from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/include/mediatools_audiosource_impl.h:10:0,
from /home/imatrix/下载/GNU/ 模块/gr-mediatools-master/lib/mediatools_audiosource_impl.cc:1:
/usr/local/include/libavcodec/avcodec.h:4817:5: note: declared here
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame,
^
lib/CMakeFiles/gnuradio-mediatools.dir/build.make:86: recipe for target 'lib/CMakeFiles/gnuradio-mediatools.dir/mediatools_audiosource_impl.cc.o' failed
make[2]: *** [lib/CMakeFiles/gnuradio-mediatools.dir/mediatools_audiosource_impl.cc.o] Error 1
make[2]: *** 正在等待未完成的任务....
[ 52%] Built target mediatools_swig_swig_2d0df
Scanning dependencies of target pygen_swig_d4ca7
[ 64%] Generating mediatools_swig.pyc
[ 64%] Generating mediatools_swig.pyo
[ 70%] Built target pygen_swig_d4ca7
CMakeFiles/Makefile2:135: recipe for target 'lib/CMakeFiles/gnuradio-mediatools.dir/all' failed
make[1]: *** [lib/CMakeFiles/gnuradio-mediatools.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Your error stems from here:
gr-mediatools-master/lib/mediatools_audiosource_impl.cc:91:39: error: ‘avcodec_alloc_frame’ was not declared in this scope
d_frame = avcodec_alloc_frame();
That's because avcodec_alloc_frame has been deprecated in recent versions of ffmpeg. The gr-mediatools repository is quite old now.
Replacing avcodec_alloc_frame with av_frame_alloc in lib/mediatools_audiosource_impl.cc on line 91 might just do the trick.