Hi all, Cygwin FAQ 6.15 says that I cannot link with both MSVCRT*.dll and cygwin1.dll since they are mutually exclusive. However, I can successfully run a simple Windows console application which dynamically loads a dll (compiled in Cygwin, thus linking to cygwin1.dll). The Windows console application is built with Multi-threaded DLL (/MD). So what's the problem of linking to both MSVCRT*.dll and cygwin1.dll. Am I missing anything?
// test.cpp, DLL code compiled in Cygwin #include <stdio.h> int hello(void) { printf ("welcome to linux world\n"); return 7777777; } This is the code to produce dll $ gcc -g -O2 -c test.cpp $ gcc -shared -o test.dll test.o // main application compiled in MSVC, with /MD #include <stdio.h> #include <Windows.h> int main() { char padding[32768]; memset(padding, 0, sizeof(padding)); HMODULE h = LoadLibrary(TEXT("C:\\cygwin64\\bin\\cygwin1.dll")); if (!h) { DWORD code = GetLastError(); printf ("can't load cygwin1.dll, code %d\n", code); return 0; } typedef void (WINAPI *INITFUC)(); INITFUC init = NULL; init = (INITFUC) GetProcAddress(h, "cygwin_dll_init"); if (!init) { printf ("can't find cygwin_dll_init()\n"); return 0; } init(); h = LoadLibrary(TEXT("E:\\opensource\\Cygwin\\test\\test.dll")); if (!h) { DWORD code = GetLastError(); printf ("can't load test.dll, code %d\n", code); return 0; } typedef int (*MYFUNC)(void); MYFUNC f = NULL; f = (MYFUNC) GetProcAddress(h, "_Z5hellov"); if (!f) { printf ("can't find hello()\n"); return 0; } int res = (*f)(); printf ("res: %d\n", res); printf ("it's over\n"); getchar(); return 0; } The outputs: welcome to linux world res: 7777777 it's over So everything look fine. According to the FAQ 6.15, is there anything that's potentially dangerous that I should be aware of, when linking both msvcrt.dll and cygwin1.dll? Thanks a lot! Thanks, Jing Zhao @ Shanghai Ext. 3273 8+ 7023273 -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple