How to properly link ffmpeg library to clion?

Hey everyone :),

I've been trying to use FFmpeg for video compression and other tasks, but I've been stuck for a while. Up until now, I've mostly avoided linking and have only worked with header-only libraries, so I'm not very familiar with CMake or how CLion handles code execution.

I downloaded
https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl-shared.zip as told by ffmpeg.org,
extracted it and added the following linkes to CMakeLists.txt:

1
2
3
4
5
6
7
8
9
10
include_directories("D:\\FFmPeg\\ffmpeg-master-latest-win64-gpl-shared\\include")

link_directories("D:\\FFmPeg\\ffmpeg-master-latest-win64-gpl-shared\\lib")

target_link_libraries(plain_projects
        "D:\\FFmPeg\\ffmpeg-master-latest-win64-gpl-shared\\lib\\avformat.lib"
        "D:\\FFmPeg\\ffmpeg-master-latest-win64-gpl-shared\\lib\\avcodec.lib"
        "D:\\FFmPeg\\ffmpeg-master-latest-win64-gpl-shared\\lib\\swscale.lib"
        "D:\\FFmPeg\\ffmpeg-master-latest-win64-gpl-shared\\lib\\avutil.lib"
)

(ChatGPT helped here)

Now, I'm not getting any build errors, but I'm hitting an exit code -1073741515 (0xC0000135),
which apparently means that some DLL couldn't be found.

Any advice on how to fix this?


Thanks in advance for any help!

Cheers,
Luke
Last edited on
Linking the import libraries (.lib files) only tells the linker that the contained symbols need to be imported from the respective DLL files at runtime. So, if, at runtime, you get error 0xC0000135, it indicates that at least one required DLL could not be loaded by the OS loader!

Make sure that, at runtime, all required DLLs are in one of the directories where Windows is looking for them:
https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-unpackaged-apps

Also, be aware that not only the "main" EXE can have some direct DLL dependencies, but the DLL's themselves may have transitive dependencies on additional DLL's! Use a tool like Dependencies for figure out all direct and indirect dependencies:
https://github.com/lucasg/Dependencies
Last edited on
Thank you so much. I realized i mixed up .dll with .lib in the execution folder..
Registered users can post here. Sign in or register to post.