Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

error while compiling simple c++ file with libavformat library

i create simple c++ file called test.cpp

#include <iostream>
#include <libavformat\avformat.h>
using namespace std;

int main() 
{
    cout << "Hello, World!";
    return 0;
}

and using g++ in terminal to compile test.cpp file with the command :

g++ test.cpp -o test

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

i get this error =>

test.cpp:2:10: fatal error: libavformat\avformat.h: No such file or directory
    2 | #include <libavformat\avformat.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

Notes:
libavformat\avformat.h path is : /usr/include/x86_64-linux-gnu/libavformat/avformat.h

and using ffmpeg version is :

$ ffmpeg -version

ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: –prefix=/usr –extra-version=0ubuntu0.22.04.1 –toolchain=hardened –libdir=/usr/lib/x86_64-linux-gnu –incdir=/usr/include/x86_64-linux-gnu –arch=amd64 –enable-gpl –disable-stripping –enable-gnutls –enable-ladspa –enable-libaom –enable-libass –enable-libbluray –enable-libbs2b –enable-libcaca –enable-libcdio –enable-libcodec2 –enable-libdav1d –enable-libflite –enable-libfontconfig –enable-libfreetype –enable-libfribidi –enable-libgme –enable-libgsm –enable-libjack –enable-libmp3lame –enable-libmysofa –enable-libopenjpeg –enable-libopenmpt –enable-libopus –enable-libpulse –enable-librabbitmq –enable-librubberband –enable-libshine –enable-libsnappy –enable-libsoxr –enable-libspeex –enable-libsrt –enable-libssh –enable-libtheora –enable-libtwolame –enable-libvidstab –enable-libvorbis –enable-libvpx –enable-libwebp –enable-libx265 –enable-libxml2 –enable-libxvid –enable-libzimg –enable-libzmq –enable-libzvbi –enable-lv2 –enable-omx –enable-openal –enable-opencl –enable-opengl –enable-sdl2 –enable-pocketsphinx –enable-librsvg –enable-libmfx –enable-libdc1394 –enable-libdrm –enable-libiec61883 –enable-chromaprint –enable-frei0r –enable-libx264 –enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100

using this command :

g++ `pkg-config --cflags libavformat` test.cpp  `pkg-config --libs libavformat` -o test

>Solution :

You should use a forward slash, since you are apparently on a Unix system:

#include <libavformat/avformat.h>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading