Define SHARED when building shared library
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6dcf8a3..972ffb4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,6 +13,10 @@ option(BUILD_TESTS "tests?" OFF)
set(headers dlfcn.h)
set(sources dlfcn.c)
+if (BUILD_SHARED_LIBS)
+ add_definitions(-DSHARED)
+endif (BUILD_SHARED_LIBS)
+
add_library(dl ${sources})
install (TARGETS dl RUNTIME DESTINATION bin
diff --git a/Makefile b/Makefile
index 2b03051..0f32932 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ CFLAGS=-Wall -O3 -fomit-frame-pointer
ifeq ($(BUILD_SHARED),yes)
TARGETS += libdl.dll
SHFLAGS += -Wl,--out-implib,libdl.dll.a
+ CFLAGS += -DSHARED
INSTALL += shared-install
endif
ifeq ($(BUILD_STATIC),yes)
diff --git a/visual-studio/12/dl/dl.vcxproj b/visual-studio/12/dl/dl.vcxproj
index 6062cad..cea69bd 100644
--- a/visual-studio/12/dl/dl.vcxproj
+++ b/visual-studio/12/dl/dl.vcxproj
@@ -125,6 +125,7 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -155,6 +156,7 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -195,6 +197,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -209,6 +212,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>SHARED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>