I have a native win32 dll which has been built from 3 static libraries using Visual Studio 12 2013.
Two of these static libraries are static 'plugins' which rely on global initialisers to 'register' with the third library.
This means I need code to be executed when the dll is loaded. I have a function:
int NullDevicePlugin_construct() {
inititalise_plugin();
return 0;
}
int g_NullDevicePlugin_initialiser = NullDevicePlugin_construct();
This function never gets called. I have checked the symbols in the static lib where this code resides, and I have:
00C 00000000 SECT5 notype Static | .CRT$XCU
Section length 4, #relocs 1, #linenums 0, checksum 0
00E 00000000 SECT5 notype Static | _g_NullDevicePlugin_initialiser$initializer$
I have also linked the dll which contains this static lib with /OPT:NOREF and /OPT:NOICF.
This is a mobile cross-development project, and for Android and iOS I use:
__attribute__((constructor)) static void NullDevicePlugin_constructor()
decoration which gets called on both platforms.
I have also tried: __attribute__((constructor)) equivalent in VC?, but this does not work for me.
The c# code calls into the native dll with no problems.
Can anyone help with this?
Many thanks