The changes from #1209 has been described as:
Fixed declarations of API variables for MSVC (
__declspec(dllimport)
). This fixes MSVC builds of programs which link against a libsecp256k1 DLL dynamically and use API variables (and not only API functions). Unfortunately, the MSVC linker now will emit warningLNK4217
when trying to link against libsecp256k1 statically. Pass/ignore:4217
to the linker to suppress this warning.
Apparently, this description is not complete. When building Bitcoin Core, the other warning is raised as well:
0LINK : warning LNK4217: symbol 'secp256k1_context_static' defined in 'libsecp256k1.lib(secp256k1.obj)' is imported by 'libbitcoin_consensus.lib(pubkey.obj)' in function '"public: static bool __cdecl CPubKey::CheckLowS(class std::vector<unsigned char,class std::allocator<unsigned char> > const &)" (?CheckLowS@CPubKey@@SA_NAEBV?$vector@EV?$allocator@E@std@@@std@@@Z)' [C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\build_msvc\test_bitcoin\test_bitcoin.vcxproj]
1LINK : warning LNK4286: symbol 'secp256k1_context_static' defined in 'libsecp256k1.lib(secp256k1.obj)' is imported by 'libbitcoin_common.lib(key.obj)' [C:\Users\ContainerAdministrator\AppData\Local\Temp\cirrus-ci-build\build_msvc\test_bitcoin\test_bitcoin.vcxproj]
This PR provides to the user of a static libsecp256k1 library an option to define the SECP256K1_STATICLIB
macro instead of ignoring MSVC linker warnings LNK4217 and LNK4286.