Hi forum,
Very basic stuff here - how can I create the DLL (Visual Studio 2015 Community version, C is used) so that linker does not complain about DLLMain@12 already defined in dllmain.obj?
I tried :
a) extern"C"{int _afxForceUSRDLL;} in DLL source file - failed
b) include library that reports the problem (msvcrtd.lib) into "Additional Dependencies" - failed
c) use /FORCE for linking. This indeed produced DLL but this DLL does not work. Probably some kind of conflict in DLLMain function between CRT and MSF libraries
d) https://support.microsoft.com/en-us/kb/148652 both solutions tried (solution 2 is just verbosity in detecting problem library so nothing much I did there)
e) various flags/combination of flags for linker ( Linker->General and Linker->Input) like "Additional dependencies", "ignore all default libs", "Ignore selected lib", etc.
Function is very basic but what it does is not important - just want linker and compiler do their job.
INT APIENTRY DllMain(HMODULE hDLL, DWORD Reason, LPVOID Reserved) {
FILE *file;
fopen_s(&file, "C:\\test.txt", "a+");
switch(Reason) {
case DLL_PROCESS_ATTACH:
fprintf(file, "DLL attach function called.\n");
break;
case DLL_PROCESS_DETACH:
fprintf(file, "DLL detach function called.\n");
break;
case DLL_THREAD_ATTACH:
fprintf(file, "DLL thread attach function called.\n");
break;
case DLL_THREAD_DETACH:
fprintf(file, "DLL thread detach function called.\n");
break;
}
return TRUE;
}Thanks
Regards
resurector