diff --git a/include/secp256k1.h b/include/secp256k1.h index 9370906c31638..88b68df7b0e7d 100644 --- a/include/secp256k1.h +++ b/include/secp256k1.h @@ -134,10 +134,12 @@ typedef int (*secp256k1_nonce_function)( #endif /* Symbol visibility. See https://gcc.gnu.org/wiki/Visibility */ -/* DLL_EXPORT is defined internally for shared builds */ #if defined(_WIN32) -# ifdef SECP256K1_BUILD -# ifdef DLL_EXPORT +# if defined(SECP256K1_BUILD) +# if defined(DLL_EXPORT) || defined(SECP256K1_DLL_EXPORT) + /* Building libsecp256k1 as a DLL. + * 1. If using Libtool, it defines DLL_EXPORT automatically. + * 2. In other cases, SECP256K1_DLL_EXPORT must be defined. */ # define SECP256K1_API extern __declspec (dllexport) # endif /* The user must define SECP256K1_STATIC when consuming libsecp256k1 as a static diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd7c48fcf17dc..b305751b08da7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,10 +20,9 @@ if(SECP256K1_ASM STREQUAL "arm32") target_link_libraries(secp256k1_asm INTERFACE secp256k1_asm_arm) endif() -# Define our export symbol only for Win32 and only for shared libs. -# This matches libtool's usage of DLL_EXPORT if(WIN32) - set_target_properties(secp256k1 PROPERTIES DEFINE_SYMBOL "DLL_EXPORT") + # Define our export symbol only for shared libs. + set_target_properties(secp256k1 PROPERTIES DEFINE_SYMBOL SECP256K1_DLL_EXPORT) target_compile_definitions(secp256k1 INTERFACE $<$>:SECP256K1_STATIC>) endif()