I'm trying to create a Dart FFI plugin for the GStreamer library to use it in my Flutter application on Windows, with plans to expand to other platforms in the future. Since GStreamer is written in C, I thought it would be relatively straightforward to create bindings for it.
To get started, I downloaded the pre-compiled dynamic library from the official website, specifically the MSVC 64-bit (VS 2019, Release CRT) 1.22.4 runtime installer
. However, I'm having trouble getting the library to load properly.
When I try to run the Dart FFI plugin, I get the following error message:
Invalid argument(s): Failed to load dynamic library 'gstreamer-1.0-0.dll': error code 126
I've checked that the DLL file is present in the correct directory and I've also added the DLL to my CMakeLists.txt
file for the plugin.
Here is Windows CMakeLists.txt
file:
cmake_minimum_required(VERSION 3.14)
set(PROJECT_NAME "gstreamer")
project(${PROJECT_NAME} LANGUAGES CXX)
set(PLUGIN_NAME "gstreamer_plugin")
list(APPEND PLUGIN_SOURCES
"gstreamer_plugin.cpp"
"gstreamer_plugin.h"
)
add_library(${PLUGIN_NAME} SHARED
"include/gstreamer/gstreamer_plugin_c_api.h"
"gstreamer_plugin_c_api.cpp"
${PLUGIN_SOURCES}
)
apply_standard_settings(${PLUGIN_NAME})
set_target_properties(${PLUGIN_NAME} PROPERTIES
CXX_VISIBILITY_PRESET hidden)
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
# Eveything is Dart's default plugin staff
set(gstreamer_bundled_libraries
# Only added this line
"${CMAKE_CURRENT_SOURCE_DIR}/gstreamer-1.0-0.dll"
PARENT_SCOPE
)
Here is my flutter environment setup:
Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.22621.1928], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc4)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.6.4)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.79.2)
[√] Connected device (3 available)
[√] Network resources
What could be causing this issue, and how can I resolve it? Is there anything else I can try to get the dynamic library working properly in my Dart FFI plugin on Windows?