Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpango_video.so / libswscale build error on Linux Ubuntu 18.04.6 #732

Closed
brianm-sra opened this issue Feb 7, 2022 · 5 comments
Closed

Comments

@brianm-sra
Copy link

OS : Ubuntu Linux 18.04.6 LTS
cmake version : 3.21.3

$ git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
$ cd Pangolin
$ ./scripts/install_prerequisites.sh --dry-run recommended
$ mkdir build && cd build
$ cmake ..
$ cmake --build .

build error:

[ 53%] Linking CXX shared library libpango_video.so
/usr/bin/ld: /usr/local/lib/libswscale.a(swscale.o): relocation R_X86_64_PC32 against symbol `ff_M24A' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
CMakeFiles/pango_video.dir/build.make:545: recipe for target 'libpango_video.so' failed
make[2]: *** [libpango_video.so] Error 1
CMakeFiles/Makefile2:859: recipe for target 'CMakeFiles/pango_video.dir/all' failed
make[1]: *** [CMakeFiles/pango_video.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2
@brianm-sra brianm-sra changed the title libpango_video.so / libswscale error on Linux Ubuntu 18.04.6 libpango_video.so / libswscale build error on Linux Ubuntu 18.04.6 Feb 7, 2022
@brianm-sra
Copy link
Author

I am trying the suggestion from #27 (comment)

@brianm-sra
Copy link
Author

Still having trouble getting it to build

@brianm-sra
Copy link
Author

Now I'm running into this ( #323 )
type of issue

git clone --recursive https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin/
./scripts/install_prerequisites.sh recommended
mkdir build && cd build
 cmake ..
cmake --build .
[ 51%] Building CXX object CMakeFiles/pango_video.dir/components/pango_video/src/drivers/ffmpeg.cpp.o
In file included from /home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg.h:32:0,
                 from /home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:37:
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h: In function ‘std::__cxx11::string pangolin::FfmpegFmtToString(AVPixelFormat)’:
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:37:39: error: ‘AV_PIX_FMT_VAAPI_MOCO’ was not declared in this scope
 #define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;
                                       ^
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:97:5: note: in expansion of macro ‘TEST_PIX_FMT_RETURN’
     TEST_PIX_FMT_RETURN(VAAPI_MOCO);
     ^~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:37:39: note: suggested alternative: ‘AV_PIX_FMT_VAAPI’
 #define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;
                                       ^
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:97:5: note: in expansion of macro ‘TEST_PIX_FMT_RETURN’
     TEST_PIX_FMT_RETURN(VAAPI_MOCO);
     ^~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:37:39: error: ‘AV_PIX_FMT_VAAPI_IDCT’ was not declared in this scope
 #define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;
                                       ^
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:98:5: note: in expansion of macro ‘TEST_PIX_FMT_RETURN’
     TEST_PIX_FMT_RETURN(VAAPI_IDCT);
     ^~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:37:39: note: suggested alternative: ‘AV_PIX_FMT_VAAPI’
 #define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;
                                       ^
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:98:5: note: in expansion of macro ‘TEST_PIX_FMT_RETURN’
     TEST_PIX_FMT_RETURN(VAAPI_IDCT);
     ^~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:37:39: error: ‘AV_PIX_FMT_VAAPI_VLD’ was not declared in this scope
 #define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;
                                       ^
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:99:5: note: in expansion of macro ‘TEST_PIX_FMT_RETURN’
     TEST_PIX_FMT_RETURN(VAAPI_VLD);
     ^~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:37:39: note: suggested alternative: ‘AV_PIX_FMT_VAAPI’
 #define TEST_PIX_FMT_RETURN(fmt) case AV_PIX_FMT_##fmt: return #fmt;
                                       ^
/home/b1.miller/src/github_com/Pangolin/components/pango_video/include/pangolin/video/drivers/ffmpeg_common.h:99:5: note: in expansion of macro ‘TEST_PIX_FMT_RETURN’
     TEST_PIX_FMT_RETURN(VAAPI_VLD);
     ^~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp: In member function ‘void pangolin::FfmpegVideo::InitUrl(std::__cxx11::string, std::__cxx11::string, std::__cxx11::string, bool, int, pangolin::ImageDim)’:
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:62:5: error: ‘av_register_all’ was not declared in this scope
     av_register_all();
     ^~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:62:5: note: suggested alternative: ‘avdevice_register_all’
     av_register_all();
     ^~~~~~~~~~~~~~~
     avdevice_register_all
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:69:35: error: invalid conversion from ‘const AVInputFormat*’ to ‘AVInputFormat*’ [-fpermissive]
         fmt = av_find_input_format(codec_hint.c_str());
               ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:120:36: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codec’
         if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
                                    ^~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:123:42: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codec’
         }else if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO)
                                          ^~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:139:54: error: ‘AVStream {aka struct AVStream}’ has no member named ‘codec’
     pVidCodecCtx = pFormatCtx->streams[videoStream]->codec;
                                                      ^~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:142:35: error: invalid conversion from ‘const AVCodec*’ to ‘AVCodec*’ [-fpermissive]
     pVidCodec=avcodec_find_decoder(pVidCodecCtx->codec_id);
               ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:180:17: error: ‘avpicture_get_size’ was not declared in this scope
     numBytesOut=avpicture_get_size(fmtout, w, h);
                 ^~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:180:17: note: suggested alternative: ‘av_opt_get_int’
     numBytesOut=avpicture_get_size(fmtout, w, h);
                 ^~~~~~~~~~~~~~~~~~
                 av_opt_get_int
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:185:21: error: ‘AVPicture’ was not declared in this scope
     avpicture_fill((AVPicture *)pFrameOut, buffer, fmtout, w, h);
                     ^~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:185:21: note: suggested alternative: ‘AVPictureType’
     avpicture_fill((AVPicture *)pFrameOut, buffer, fmtout, w, h);
                     ^~~~~~~~~
                     AVPictureType
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:185:32: error: expected primary-expression before ‘)’ token
     avpicture_fill((AVPicture *)pFrameOut, buffer, fmtout, w, h);
                                ^
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:185:5: error: ‘avpicture_fill’ was not declared in this scope
     avpicture_fill((AVPicture *)pFrameOut, buffer, fmtout, w, h);
     ^~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp: In member function ‘virtual bool pangolin::FfmpegVideo::GrabNext(unsigned char*, bool)’:
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:254:13: error: ‘avcodec_decode_video2’ was not declared in this scope
             avcodec_decode_video2(pVidCodecCtx, pFrame, &gotFrame, &packet);
             ^~~~~~~~~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:254:13: note: suggested alternative: ‘avcodec_decode_subtitle2’
             avcodec_decode_video2(pVidCodecCtx, pFrame, &gotFrame, &packet);
             ^~~~~~~~~~~~~~~~~~~~~
             avcodec_decode_subtitle2
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:264:9: error: ‘av_free_packet’ was not declared in this scope
         av_free_packet(&packet);
         ^~~~~~~~~~~~~~
/home/b1.miller/src/github_com/Pangolin/components/pango_video/src/drivers/ffmpeg.cpp:264:9: note: suggested alternative: ‘av_get_packet’
         av_free_packet(&packet);
         ^~~~~~~~~~~~~~
         av_get_packet
CMakeFiles/pango_video.dir/build.make:433: recipe for target 'CMakeFiles/pango_video.dir/components/pango_video/src/drivers/ffmpeg.cpp.o' failed
make[2]: *** [CMakeFiles/pango_video.dir/components/pango_video/src/drivers/ffmpeg.cpp.o] Error 1
CMakeFiles/Makefile2:859: recipe for target 'CMakeFiles/pango_video.dir/all' failed
make[1]: *** [CMakeFiles/pango_video.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

@brianm-sra
Copy link
Author

I was able to workaround this issue by modifying file components/pango_video/CMakeLists.txt
and removing these lines:

option(BUILD_PANGOLIN_FFMPEG "Build support for ffmpeg video input" ON)
if(BUILD_PANGOLIN_FFMPEG)
find_package(FFMPEG QUIET)
if(FFMPEG_FOUND)
target_sources( ${COMPONENT} PRIVATE
${DRIVER_DIR}/ffmpeg.cpp
${DRIVER_DIR}/ffmpeg_convert.cpp
${DRIVER_DIR}/ffmpeg_output.cpp
)
target_link_libraries(${COMPONENT} PRIVATE ${FFMPEG_LIBRARIES} )
target_include_directories(${COMPONENT} PRIVATE ${FFMPEG_INCLUDE_DIRS} )
PangolinRegisterFactory( VideoInterface FfmpegVideo FfmpegVideoConvert)
PangolinRegisterFactory( VideoOutputInterface FfmpegVideoOutput)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# FFMPEG is a real pain for deprecating the API.
set_source_files_properties(${DRIVER_DIR}/ffmpeg.cpp PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
endif()
message(STATUS "ffmpeg Found and Enabled")
endif()
endif()

@stevenlovegrove
Copy link
Owner

You can also disable any feature of Pangolin by setting the appropriate CMake option (in this case BUILD_PANGOLIN_FFMPEG to Off with ccmake or cmake-gui for instance)

The link below talks about static linking of ffmpeg into a shared library in case that is related to this issue. You could try their suggestion or make sure find_package is locating a dynamic version of the library.
https://stackoverflow.com/questions/34936080/gcc-relocation-r-x86-64-pc32-against-symbol-ff-m24a-error-when-linking-stati

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants