diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/dlfcn.c | 11 |
3 files changed, 21 insertions, 1 deletions
@@ -32,7 +32,7 @@ libdl.a: $(SOURCES) | |||
32 | $(RANLIB) $@ | 32 | $(RANLIB) $@ |
33 | 33 | ||
34 | libdl.dll: $(SOURCES) | 34 | libdl.dll: $(SOURCES) |
35 | $(CC) $(CFLAGS) $(SHFLAGS) -DDLFCN_WIN32_SHARED -shared -o $@ $^ | 35 | $(CC) $(CFLAGS) $(SHFLAGS) -DDLFCN_WIN32_SHARED -D_DllMainCRTStartup=DllMainCRTStartup -nostartfiles -nostdlib -lkernel32 -shared -o $@ $^ |
36 | 36 | ||
37 | libdl.lib: libdl.dll | 37 | libdl.lib: libdl.dll |
38 | $(LIBCMD) /machine:i386 /def:libdl.def | 38 | $(LIBCMD) /machine:i386 /def:libdl.def |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9066e65..5dc21d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt | |||
@@ -15,6 +15,15 @@ set_target_properties(dl PROPERTIES DEFINE_SYMBOL "") | |||
15 | 15 | ||
16 | # set shared mode for compiling library and propagate mode to cmake clients | 16 | # set shared mode for compiling library and propagate mode to cmake clients |
17 | if (BUILD_SHARED_LIBS) | 17 | if (BUILD_SHARED_LIBS) |
18 | # for non-debug shared mode, avoid linking to CRT library as it is not needed | ||
19 | if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
20 | if (MSVC) | ||
21 | set_property(TARGET dl APPEND_STRING PROPERTY COMPILE_FLAGS "/Zl") | ||
22 | else (MSVC) | ||
23 | set_property(TARGET dl APPEND_STRING PROPERTY COMPILE_FLAGS "-D_DllMainCRTStartup=DllMainCRTStartup") | ||
24 | set_property(TARGET dl APPEND_STRING PROPERTY LINK_FLAGS "-nostartfiles -nostdlib -lkernel32") | ||
25 | endif (MSVC) | ||
26 | endif (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
18 | target_compile_definitions(dl PUBLIC DLFCN_WIN32_SHARED) | 27 | target_compile_definitions(dl PUBLIC DLFCN_WIN32_SHARED) |
19 | endif (BUILD_SHARED_LIBS) | 28 | endif (BUILD_SHARED_LIBS) |
20 | 29 | ||
diff --git a/src/dlfcn.c b/src/dlfcn.c index c128579..5ddf1a7 100644 --- a/src/dlfcn.c +++ b/src/dlfcn.c | |||
@@ -955,4 +955,15 @@ BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) | |||
955 | (void) lpvReserved; | 955 | (void) lpvReserved; |
956 | return TRUE; | 956 | return TRUE; |
957 | } | 957 | } |
958 | |||
959 | /* For non-debug DLL builds defines DLL entry point which avoids using CRT library */ | ||
960 | #if !defined( _DEBUG ) | ||
961 | #ifdef __cplusplus | ||
962 | extern "C" | ||
963 | #endif | ||
964 | BOOL WINAPI _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) | ||
965 | { | ||
966 | return DllMain( hinstDLL, fdwReason, lpvReserved ); | ||
967 | } | ||
968 | #endif | ||
958 | #endif | 969 | #endif |