Linking to libavcodec on Windows

  • I'm new to Windows programming, and am having some trouble getting my code to link. I'm trying to use the libavcodec library from the FFmpeg package. All of my source compiles fine, but when I go to link, all my avcodec calls are unresolved. In my .pro file I've got:

    win32: LIBS += -L$$PWD/../ffmpeg/win64/lib/ -lavcodec -lavutil
    INCLUDEPATH += $$PWD/../ffmpeg/win64/include
    DEPENDPATH += $$PWD/../ffmpeg/win64/include

    in the referenced lib directory I've got the download from the FFmpeg website containing the .lib and .dll.a files for avcodec and avutil. The linker doesn't tell me it can't find those libraries or that they are the wrong format, so I'm at a loss. Any idea what's going wrong? On Windows I don't even know how to begin debugging this issue.

  • I'm going to answer my own question in case others are looking for this: I forgot to put my includes inside an extern "C" block, e.g.

    extern "C" {
        #include <libavutil/opt.h>
        #include <libavutil/imgutils.h>
        #include <libavcodec/avcodec.h>

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.