gst: Don't use DllMain in case of static build

That might cause duplicated symbol linking error if app has its own
DllMain

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4905>
This commit is contained in:
Seungha Yang 2023-06-21 01:20:18 +09:00 committed by GStreamer Marge Bot
parent 1d00f726a0
commit eb87bbc1ba
2 changed files with 5 additions and 17 deletions

View file

@ -197,18 +197,12 @@ enum
* val ::= [0-5] * val ::= [0-5]
*/ */
#ifdef G_OS_WIN32 #if defined(G_OS_WIN32) && !defined(GST_STATIC_COMPILATION)
/* Note: DllMain is only called when DLLs are loaded or unloaded, so this will /* Note: DllMain is only called when DLLs are loaded or unloaded, so this will
* never be called if libgstreamer-1.0 is linked statically. Do not add any code * never be called if libgstreamer-1.0 is linked statically. Do not add any code
* here to, say, initialize variables or set things up since that will only * here to, say, initialize variables or set things up since that will only
* happen for dynamically-built GStreamer. * happen for dynamically-built GStreamer.
* */
* Also, ideally this should not be defined when GStreamer is built statically.
* i.e., it should be conditional on #ifdef DLL_EXPORT. It will be ignored, but
* if other libraries make the same mistake of defining it when building
* statically, there will be a symbol collision during linking. Fixing this
* requires one to build two object files: one for static linking and another
* for dynamic linking. */
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
BOOL WINAPI BOOL WINAPI
DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

View file

@ -72,7 +72,7 @@
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <windows.h> #include <windows.h>
static HMODULE gstnet_dll_handle; static HMODULE gstnet_dll_handle = NULL;
#endif #endif
#ifdef HAVE_DLFCN_H #ifdef HAVE_DLFCN_H
@ -2339,18 +2339,12 @@ gst_ptp_is_initialized (void)
return initted; return initted;
} }
#ifdef G_OS_WIN32 #if defined(G_OS_WIN32) && !defined(GST_STATIC_COMPILATION)
/* Note: DllMain is only called when DLLs are loaded or unloaded, so this will /* Note: DllMain is only called when DLLs are loaded or unloaded, so this will
* never be called if libgstnet-1.0 is linked statically. Do not add any code * never be called if libgstnet-1.0 is linked statically. Do not add any code
* here to, say, initialize variables or set things up since that will only * here to, say, initialize variables or set things up since that will only
* happen for dynamically-built GStreamer. * happen for dynamically-built GStreamer.
* */
* Also, ideally this should not be defined when GStreamer is built statically.
* i.e., it should be conditional on #ifdef DLL_EXPORT. It will be ignored, but
* if other libraries make the same mistake of defining it when building
* statically, there will be a symbol collision during linking. Fixing this
* requires one to build two object files: one for static linking and another
* for dynamic linking. */
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
BOOL WINAPI BOOL WINAPI
DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)