Errors while building customised ffmpeg4.1 with libopencv_highgui-dev

asked 2019-12-20 03:29:23 -0500

I am building mu customised ffmpeg4.1 version. I am using cvLoadImage and some other opencv functions in my code, so I linked highgui-dev library as -lopencv_highgui in my Makefile. As we know that ffmpeg4.1 needs libavcodec.so.58 and other related libraries(newest). I updated the libopencv-highgui-dev, libopencv_core-dev and libopencv_imgproc-dev libraries. When I run the makefile I got the following errors

/usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to sws_getCachedContext@LIBSWSCALE_4' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavcodec_find_encoder@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to av_free@LIBAVUTIL_55' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavcodec_encode_video2@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to av_seek_frame@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toav_lockmgr_register@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avcodec_decode_video2@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavcodec_open2@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to av_malloc@LIBAVUTIL_55' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavio_close@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to av_init_packet@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toav_log_set_level@LIBAVUTIL_55' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avpicture_get_size@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavformat_get_riff_video_tags@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avformat_close_input@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavpicture_fill@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avformat_network_init@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavformat_find_stream_info@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avcodec_close@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toav_guess_codec@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avio_open@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toav_guess_format@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avformat_open_input@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toav_register_all@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to sws_getContext@LIBSWSCALE_4' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavformat_new_stream@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to av_frame_free@LIBAVUTIL_55' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toav_sub_q@LIBAVUTIL_55' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to av_freep@LIBAVUTIL_55' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavcodec_find_decoder@LIBAVCODEC_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to sws_freeContext@LIBSWSCALE_4' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference tosws_scale@LIBSWSCALE_4' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to avformat_alloc_context@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toav_read_frame@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference to av_codec_get_id@LIBAVFORMAT_57' /usr/lib/x86_64-linux-gnu/libopencv_highgui.so: undefined reference toavcodec_flush_buffers@LIBAVCODEC_57' collect2: error: ld returned 1 exit status make: * [new-ffmpeg] Error 1

I have clearly linked the newest libraries and included them in my makefile. Errors list suggesting me that, libopencv-highgui.so is pointing to libavcodec.57 version api's. Has opencv not upgraded to support libavXX.so.58 libs? or am I doing anything wrong here.

Can we link this libopencv_highgui library to point to libavXX.so.58(newer libs)? or should I need to compile and ... (more)

edit retag flag offensive close merge delete

Comments

which opencv version ? what is libopencv_highgui-dev, exactly ?

I am using cvLoadImage

please avoid using the deprecated c-api, it's dead since 2010

berak gravatar imageberak ( 2019-12-20 04:13:32 -0500 )edit

I am using opencv 2.4 version, what is the new alternative for cvLoadImage()?

infant_batman gravatar imageinfant_batman ( 2019-12-20 04:16:16 -0500 )edit

opencv2.4 is also dead, no more maintained, and noone will be able (or even willing) to help you with it.

please try again with e.g. 3.4.9

berak gravatar imageberak ( 2019-12-20 04:30:21 -0500 )edit

Could you tell me the exact library name for libopencv_highgui-dev.so for debian stretch? I already updated(installed) the newest highgui-dev library from the sudo apt-get install, still got the same error.

infant_batman gravatar imageinfant_batman ( 2019-12-20 06:01:41 -0500 )edit

please build recent release code from github src, opencv does not know about highgui-dev or any deb packages. if you use those, you're at the mercy of their maintainers

berak gravatar imageberak ( 2019-12-20 06:29:00 -0500 )edit

@berak thanks for the response, if I build the opencv from github, can I get the solution to my problem? How can I link that opencv to my C api's? The new opencv version contains the cvLoadImage(or its alternative)?

infant_batman gravatar imageinfant_batman ( 2019-12-20 06:51:48 -0500 )edit

@berak could you please tell me the alternative api for cvLoadImage() in recent opencv?

infant_batman gravatar imageinfant_batman ( 2019-12-20 10:04:31 -0500 )edit

@berak could you give any suggestion?

infant_batman gravatar imageinfant_batman ( 2019-12-23 01:47:04 -0500 )edit

i probably misread th whole thing. --- you're trying to build FFMPEG ? (not opencv in the 1st place ?)

and this has some weird opencv plugin, that requires c code, and thus only works with opencv < 3 ?

in that case -- do you really need the highgui gui module ?

berak gravatar imageberak ( 2019-12-23 02:48:20 -0500 )edit

@berak Yes I am building FFmpeg. My code is using cvLoadImage() api from almost 9 years. I have to find an alternative for this api. Do we have one?

infant_batman gravatar imageinfant_batman ( 2019-12-23 02:55:10 -0500 )edit