I'm using MSVC2013 Update 5 and import library for R.dll from Revolution R 3.2.2 x64 to compile custom version of Rserve (https://rforge.net/Rserve/), which used embdded R.dll. CRT type is multithreaded debug DLL. Program crashes when calling to fprintf(stderr, ...) in a very strange way:
ntdll.dll!RtlRaiseStatus() Unknown
ntdll.dll!string "Enabling heap debug options\n"() Unknown
ntdll.dll!RtlEnterCriticalSection() Unknown
msvcrt.dll!_lock_file() Unknown
msvcrt.dll!putc() Unknown
R.dll!000000006c8dd814() Unknown
R.dll!000000006c8df8e8() Unknown
R.dll!000000006c8e3d74() Unknown
R.dll!000000006c8dd00d() Unknown
RServe.exe!loadConfig(const char * fn) Line 2113 C
RServe.exe!main(int argc, char * * argv) Line 4247 C
[External Code]
The code is like this:
if(checkScriptFileName(p) != 0)
fprintf(stderr, "Error: Invalid script file name: '%s'.\n", p);
According to my understanding, fprintf() should be located in the msvcr120d.dll, but it accesses somehow msvcrt.dll and goes through R.dll.
Did anyone face similar issue? Can you please suggest, what can I do in this case in order to solve the issue? (For those who did not understood what about this question) THE QUESTION IS THAT HOW TO FIX THIS CRASH (which normally should not happen, because I've passed all correct parameters to the fprintf()).
Update: More interesting details - tried to switch to static variant of CRT, got following interesting stuff:
1> Generating Code...
1>LIBCMTD.lib(sprintf.obj) : error LNK2005: sprintf already defined in R.lib(R.dll)
1>LIBCMTD.lib(printf.obj) : error LNK2005: printf already defined in R.lib(R.dll)