undefined reference to `png_set_longjmp_fn' when compiling PCL source file - cmake

I am trying to install PCL from source file, but I have this error " undefined reference to `png_set_longjmp_fn'". I have searched a lot but can't find a solution.
Other info.: Now, in my computer, I have installed both libpng1.6 and libpng1.2. I can't remove libpng1.2 because other application depends on it.
Scanning dependencies of target pcl_io_ply
Scanning dependencies of target pcl_pcd_convert_NaN_nan
Scanning dependencies of target pcl_people
Scanning dependencies of target pcl_octree
Scanning dependencies of target pcl_common
[ 1%] Building CXX object io/CMakeFiles/pcl_io_ply.dir/src/ply/ply_parser.cpp.o
[ 1%] [ 1%] Building CXX object io/tools/CMakeFiles/pcl_pcd_convert_NaN_nan.dir/pcd_convert_NaN_nan.cpp.o
Building CXX object people/CMakeFiles/pcl_people.dir/src/hog.cpp.o
[ 1%] Building CXX object octree/CMakeFiles/pcl_octree.dir/src/octree_inst.cpp.o
[ 2%] [ 2%] [ 2%] [ 2%] Building CXX object common/CMakeFiles/pcl_common.dir/src/io.cpp.o
Building CXX object common/CMakeFiles/pcl_common.dir/src/common.cpp.o
Building CXX object common/CMakeFiles/pcl_common.dir/src/pcl_base.cpp.o
Building CXX object common/CMakeFiles/pcl_common.dir/src/point_types.cpp.o
Linking CXX executable ../../bin/pcl_pcd_convert_NaN_nan
[ 2%] Built target pcl_pcd_convert_NaN_nan
[ 3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/correspondence.cpp.o
Linking CXX shared library ../lib/libpcl_people.so
[ 3%] Built target pcl_people
[ 3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/distances.cpp.o
[ 3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/parse.cpp.o
[ 3%] Building CXX object common/CMakeFiles/pcl_common.dir/src/poses_from_matches.cpp.o
[ 4%] Building CXX object common/CMakeFiles/pcl_common.dir/src/print.cpp.o
[ 4%] Building CXX object common/CMakeFiles/pcl_common.dir/src/projection_matrix.cpp.o
[ 4%] Building CXX object common/CMakeFiles/pcl_common.dir/src/time_trigger.cpp.o
[ 5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/gaussian.cpp.o
[ 5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/bearing_angle_image.cpp.o
[ 5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/range_image.cpp.o
[ 5%] Building CXX object common/CMakeFiles/pcl_common.dir/src/range_image_planar.cpp.o
[ 6%] Building C object common/CMakeFiles/pcl_common.dir/src/fft/kiss_fft.c.o
[ 6%] Building C object common/CMakeFiles/pcl_common.dir/src/fft/kiss_fftr.c.o
Linking CXX shared library ../lib/libpcl_io_ply.so
[ 6%] Built target pcl_io_ply
Scanning dependencies of target pcl_ply2obj
Scanning dependencies of target pcl_ply2raw
Scanning dependencies of target pcl_ply2ply
Scanning dependencies of target pcl_plyheader
[ 7%] [ 7%] [ 7%] [ 7%] Building CXX object io/tools/ply/CMakeFiles/pcl_ply2obj.dir/ply2obj.cpp.o
Building CXX object io/tools/ply/CMakeFiles/pcl_ply2raw.dir/ply2raw.cpp.o
Building CXX object io/tools/ply/CMakeFiles/pcl_ply2ply.dir/ply2ply.cpp.o
Building CXX object io/tools/ply/CMakeFiles/pcl_plyheader.dir/plyheader.cpp.o
Linking CXX executable ../../../bin/pcl_plyheader
[ 7%] Built target pcl_plyheader
Linking CXX shared library ../lib/libpcl_common.so
[ 7%] Built target pcl_common
Scanning dependencies of target pcl_kdtree
Scanning dependencies of target pcl_sample_consensus
Scanning dependencies of target pcl_io
Scanning dependencies of target pcl_example_check_if_point_is_valid
[ 7%] [ 7%] Building CXX object kdtree/CMakeFiles/pcl_kdtree.dir/src/kdtree_flann.cpp.o
Building CXX object examples/common/CMakeFiles/pcl_example_check_if_point_is_valid.dir/example_check_if_point_is_valid.cpp.o
[ 7%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac.cpp.o
[ 7%] Building CXX object io/CMakeFiles/pcl_io.dir/src/debayer.cpp.o
[ 7%] Building CXX object io/CMakeFiles/pcl_io.dir/src/pcd_grabber.cpp.o
Linking CXX executable ../../../bin/pcl_ply2obj
[ 7%] Built target pcl_ply2obj
Scanning dependencies of target pcl_example_copy_point_cloud
[ 7%] Building CXX object examples/common/CMakeFiles/pcl_example_copy_point_cloud.dir/example_copy_point_cloud.cpp.o
Linking CXX executable ../../bin/pcl_example_check_if_point_is_valid
Linking CXX executable ../../../bin/pcl_ply2raw
[ 7%] Built target pcl_example_check_if_point_is_valid
Scanning dependencies of target pcl_example_organized_point_cloud
[ 7%] Built target pcl_ply2raw
[ 7%] [ 8%] Building CXX object examples/common/CMakeFiles/pcl_example_organized_point_cloud.dir/example_organized_point_cloud.cpp.o
Building CXX object io/CMakeFiles/pcl_io.dir/src/pcd_io.cpp.o
Linking CXX executable ../../bin/pcl_example_copy_point_cloud
[ 8%] Built target pcl_example_copy_point_cloud
Scanning dependencies of target pcl_example_scope_time
[ 9%] Building CXX object examples/common/CMakeFiles/pcl_example_scope_time.dir/example_scope_time.cpp.o
Linking CXX executable ../../../bin/pcl_ply2ply
[ 9%] Built target pcl_ply2ply
[ 10%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_circle.cpp.o
Linking CXX executable ../../bin/pcl_example_organized_point_cloud
[ 10%] Built target pcl_example_organized_point_cloud
Scanning dependencies of target pcl_example_half_edge_mesh
[ 10%] Building CXX object examples/geometry/CMakeFiles/pcl_example_half_edge_mesh.dir/example_half_edge_mesh.cpp.o
Linking CXX executable ../../bin/pcl_example_scope_time
[ 10%] Built target pcl_example_scope_time
[ 10%] Building CXX object io/CMakeFiles/pcl_io.dir/src/vtk_io.cpp.o
Linking CXX executable ../../bin/pcl_example_half_edge_mesh
[ 10%] Built target pcl_example_half_edge_mesh
[ 10%] Building CXX object io/CMakeFiles/pcl_io.dir/src/ply_io.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/ascii_io.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/compression.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/lzf.cpp.o
[ 11%] Building CXX object io/CMakeFiles/pcl_io.dir/src/lzf_image_io.cpp.o
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/obj_io.cpp.o
Linking CXX shared library ../lib/libpcl_octree.so
[ 12%] Built target pcl_octree
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/ifs_io.cpp.o
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_grabber.cpp.o
[ 12%] Building CXX object io/CMakeFiles/pcl_io.dir/src/hdl_grabber.cpp.o
[ 13%] Building CXX object io/CMakeFiles/pcl_io.dir/src/robot_eye_grabber.cpp.o
[ 13%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_circle3d.cpp.o
[ 13%] Building CXX object io/CMakeFiles/pcl_io.dir/src/file_io.cpp.o
[ 13%] Building CXX object io/CMakeFiles/pcl_io.dir/src/io_exception.cpp.o
Linking CXX shared library ../lib/libpcl_kdtree.so
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/vtk_lib_io.cpp.o
[ 14%] Built target pcl_kdtree
Scanning dependencies of target pcl_search
[ 14%] Building CXX object search/CMakeFiles/pcl_search.dir/src/search.cpp.o
[ 14%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_cylinder.cpp.o
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/png_io.cpp.o
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_rgb24.cpp.o
[ 14%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_yuv422.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_ir.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/image_depth.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/dinast_grabber.cpp.o
[ 15%] Building CXX object io/CMakeFiles/pcl_io.dir/src/libpng_wrapper.cpp.o
[ 15%] Building CXX object search/CMakeFiles/pcl_search.dir/src/kdtree.cpp.o
[ 15%] Building CXX object search/CMakeFiles/pcl_search.dir/src/brute_force.cpp.o
[ 16%] Building CXX object search/CMakeFiles/pcl_search.dir/src/organized.cpp.o
[ 16%] Building CXX object search/CMakeFiles/pcl_search.dir/src/octree.cpp.o
[ 16%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_cone.cpp.o
Linking CXX shared library ../lib/libpcl_io.so
[ 17%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_line.cpp.o
[ 17%] Built target pcl_io
Scanning dependencies of target pcl_convert_pcd_ascii_binary
[ 17%] Building CXX object io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/convert_pcd_ascii_binary.cpp.o
Scanning dependencies of target pcl_hdl_grabber
[ 17%] Building CXX object io/tools/CMakeFiles/pcl_hdl_grabber.dir/hdl_grabber_example.cpp.o
[ 17%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_stick.cpp.o
[ 17%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_normal_parallel_plane.cpp.o
Linking CXX executable ../../bin/pcl_convert_pcd_ascii_binary
../../lib/libpcl_io.so.1.7.2: undefined reference to `png_set_longjmp_fn'
collect2: error: ld returned 1 exit status
io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/build.make:215: recipe for target 'bin/pcl_convert_pcd_ascii_binary' failed
make[2]: *** [bin/pcl_convert_pcd_ascii_binary] Error 1
CMakeFiles/Makefile2:565: recipe for target 'io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/all' failed
make[1]: *** [io/tools/CMakeFiles/pcl_convert_pcd_ascii_binary.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_normal_plane.cpp.o
Linking CXX executable ../../bin/pcl_hdl_grabber
../../lib/libpcl_io.so.1.7.2: undefined reference to `png_set_longjmp_fn'
collect2: error: ld returned 1 exit status
io/tools/CMakeFiles/pcl_hdl_grabber.dir/build.make:215: recipe for target 'bin/pcl_hdl_grabber' failed
make[2]: *** [bin/pcl_hdl_grabber] Error 1
CMakeFiles/Makefile2:602: recipe for target 'io/tools/CMakeFiles/pcl_hdl_grabber.dir/all' failed
make[1]: *** [io/tools/CMakeFiles/pcl_hdl_grabber.dir/all] Error 2
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_normal_sphere.cpp.o
Linking CXX shared library ../lib/libpcl_search.so
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_plane.cpp.o
[ 18%] Built target pcl_search
[ 18%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_registration.cpp.o
[ 19%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_sphere.cpp.o
Linking CXX shared library ../lib/libpcl_sample_consensus.so
[ 19%] Built target pcl_sample_consensus
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

This modification in CMakeLists.txt(check PCL source folder) have worked in my case. (which is from CMake compile options for libpng). You should use below cmake configuration instead of original one.
# LibPNG
option(WITH_PNG "PNG file support" TRUE)
if(WITH_PNG)
# search for pkg-config
include (FindPkgConfig)
if (NOT PKG_CONFIG_FOUND)
message (FATAL_ERROR "pkg-config not found")
endif ()
# check for libpng
pkg_check_modules (LIBPNG libpng16 REQUIRED)
if (NOT LIBPNG_FOUND)
message(FATAL_ERROR "You don't seem to have libpng16 development libraries installed")
else ()
include_directories (${LIBPNG_INCLUDE_DIRS})
link_directories (${LIBPNG_LIBRARY_DIRS})
link_libraries (${LIBPNG_LIBRARIES})
endif ()
endif(WITH_PNG)

Related

Can't link to bullet physics library - LNK2019,LNK2001

I have built bullet3-3.08 on Windows using cmake (commands have been executed from the build folder created in the bullet3-3.08 directory):
cmake -G "Visual Studio 15 2017" -A x64 -D "CMAKE_INSTALL_PREFIX:PATH=C:/MyLibs/bullet3-3.08" -D "USE_MSVC_RUNTIME_LIBRARY_DLL=ON" -D "INSTALL_LIBS=ON" ..
cmake --build . --config Release --parallel 8 --target install
I have an application which uses MD/MDd runtime library so I have built Bullet with the following option: USE_MSVC_RUNTIME_LIBRARY_DLL=ON. Bullet is built as a static library by default. I use Visual Studio 2017 and build my application using cmake. When I link to Bullet I get many linker errors (LNK2019, LNK2001), for example:
error LNK2019: unresolved external symbol "public: __cdecl btCollisionDispatcher::btCollisionDispatcher(class btCollisionConfiguration *)" (??0btCollisionDispatcher##QEAA#PEAVbtCollisionConfiguration###Z) referenced in function main
error LNK2001: unresolved external symbol "public: virtual void __cdecl btCollisionShape::getBoundingSphere(class btVector3 &,float &)const " (?getBoundingSphere#btCollisionShape##UEBAXAEAVbtVector3##AEAM#Z)
I use direct library paths in CMakeLists.txt:
target_link_libraries(${executableName} "C:/MyLibs/bullet3-3.08/lib/Bullet3Collision.lib"
"C:/MyLibs/bullet3-3.08/lib/Bullet3Dynamics.lib"
"C:/MyLibs/bullet3-3.08/lib/LinearMath.lib")
Here is CMakeSettings.json:
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
}
]
}
What is wrong ?
As Bullet provides a BulletConfig.cmake file it is quite simple to link against Bullet.
First you need to install Bullet (if not done so) and add -DCMAKE_PREFIX_PATH=C:/MyLibs/bullet3-3.08 (or the appropriate installation directory) to your cmake command line.
Then in your CMakeLists.txt file you need to add
find_package(Bullet REQUIRED)
# your add_executable call follows here
add_executable(${executableName} .......)
target_compile_definitions(${executableName} PRIVATE ${BULLET_DEFINITIONS})
target_include_directories(${executableName} PRIVATE ${BULLET_INCLUDE_DIRS})
target_link_libraries(${executableName} PRIVATE ${BULLET_LIBRARIES})
This should be the steps necessary to link to Bullet.

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.

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

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

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.