Support MSVC and MinGW SDK consumers

Compared with dc08a95:

- Add explicit module-definition files for the capture and preview DLLs so their public C export names remain stable and can be consumed without compiler-specific C++ symbol conventions.

- Keep the SDK implementation built with MSVC while automatically using MinGW dlltool to generate libgvfg.dll.a and libgvfg_preview.dll.a alongside the existing MSVC import libraries.

- Make the public capture header portable by including SAL only under MSVC and defining no-op annotations required by non-MSVC C and C++ compilers.

- Replace the Qt sample's compiler-specific wait on std::thread::native_handle() with an explicit atomic worker-completion state while preserving synchronous window-message servicing during shutdown.

- Document that MSVC and MinGW consumers use different import libraries while loading the same gvfg.dll and gvfg_preview.dll at runtime.

Validation: MSVC Debug and Release SDK builds passed and produced both MSVC and MinGW import libraries. Qt MSVC Debug, Qt MinGW Debug, and Qt MinGW Release sample builds and links passed. MinGW C and C++ public-header syntax checks passed, the MinGW executable import table references the expected GVFG DLLs and C exports, and git diff --check passed. No runtime launch, capture, audio playback, clean-machine deployment, or hardware validation was run.
This commit is contained in:
Mark.lin
2026-09-11 14:52:24 +08:00
parent dc08a953fa
commit 1214e720d2
9 changed files with 133 additions and 2 deletions
+19
View File
@@ -4,6 +4,7 @@ set(_GVFG_VERSION "${PROJECT_VERSION}")
project(gvfg VERSION ${_GVFG_VERSION} LANGUAGES CXX)
add_library(gvfg SHARED
gvfg.def
include/gvfg_capture.h
include/gvfg_debug.h
src/backend/pcies2mm/pcies2mm_backend_types.h
@@ -58,6 +59,18 @@ if (MSVC)
target_compile_options(gvfg PRIVATE /utf-8 /EHsc)
endif()
if (MSVC AND GVFG_MINGW_DLLTOOL)
add_custom_command(TARGET gvfg POST_BUILD
COMMAND "${GVFG_MINGW_DLLTOOL}"
-d "${CMAKE_CURRENT_SOURCE_DIR}/gvfg.def"
-D gvfg.dll
-l libgvfg.dll.a
WORKING_DIRECTORY "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}"
COMMENT "Generating MinGW import library for gvfg.dll"
VERBATIM
)
endif()
install(TARGETS gvfg
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -66,3 +79,9 @@ install(TARGETS gvfg
install(FILES include/gvfg_capture.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if (MSVC AND GVFG_MINGW_DLLTOOL)
install(FILES "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libgvfg.dll.a"
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
+35
View File
@@ -0,0 +1,35 @@
LIBRARY gvfg
EXPORTS
gvfg_enumerate_devices
gvfg_create
gvfg_destroy
gvfg_open_channel
gvfg_set_channel_event_mask
gvfg_get_channel_event_mask
gvfg_set_channel_zero_copy_enabled
gvfg_get_channel_zero_copy_enabled
gvfg_set_channel_video_format
gvfg_set_channel_audio_enabled
gvfg_get_channel_audio_format
gvfg_start_channel
gvfg_read_channel_frame
gvfg_release_channel_frame
gvfg_read_channel_audio_frame
gvfg_release_channel_audio_frame
gvfg_gpu_convert_to_buffer
gvfg_gpu_convert_to_bgra8
gvfg_gpu_convert_to_rgb10a2
gvfg_gpu_convert_to_nv12
gvfg_poll_channel_event
gvfg_stop
gvfg_stop_channel
gvfg_get_channel_signal_status
gvfg_get_channel_runtime_info
gvfg_get_version
gvfg_pixel_format_name
gvfg_strerror
gvfg_get_channel_last_error_detail
gvfg_debug_get_channel_backend_stats
gvfg_debug_read_register
gvfg_debug_write_register
+10 -1
View File
@@ -43,8 +43,11 @@
* a separate worker thread when reading video and audio concurrently.
*/
#ifdef _WIN32
#if defined(_WIN32) && defined(_MSC_VER)
#include <sal.h>
#endif
#ifdef _WIN32
#ifdef GVFG_BUILD
#define GVFG_API __declspec(dllexport)
#else
@@ -52,6 +55,9 @@
#endif
#else
#define GVFG_API
#endif
#if !defined(_MSC_VER)
#ifndef _In_
#define _In_
#endif
@@ -70,6 +76,9 @@
#ifndef _Out_writes_to_opt_
#define _Out_writes_to_opt_(size, count)
#endif
#ifndef _Out_writes_bytes_
#define _Out_writes_bytes_(size)
#endif
#endif
#include <stdint.h>