Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: From: "Peleg, Raz" To: "Shamsutdinov, Salikhyan" Cc: "'cygwin AT cygwin DOT com'" Subject: RE: link GNU and msdev Date: Tue, 23 Jan 2001 05:48:55 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C08543.3A2AA430" ------_=_NextPart_000_01C08543.3A2AA430 Content-Type: text/plain; charset="iso-8859-1" Sasha. thanks for that knowledge. please look at this code: both MS and GNU environments work fine with the function f(). but both fail in function print() that call printf() library function using that Makefile will produce two executables gprog - that compiled and linked by gcc prog - that compiled and linked by MS's tools ---------------------- dll_code.c ------------------ #include void print() { printf("Hello world\n"); } int f() { return 1; } ----------------------- prog.c ----------------------- #include #ifdef WIN32 #include __declspec( dllimport ) void print(); __declspec( dllimport ) int f(); #else void print(); int f(); #endif void (*pPrint)(); int (*pF)(); int main() { #ifdef WIN32 HINSTANCE hLib; hLib = LoadLibrary("dll.dll"); pF = (int (*)(int val))GetProcAddress(hLib,"f"); pPrint = (int (*)(char*))GetProcAddress(hLib,"print"); #else pF = f; pPrint = print; #endif printf("%d\n",pF()); pPrint(); return 0; } ---------------------- main.c ----------------------- int main() {} -------------------- Makefile ---------------------------- gprog.exe: prog.c dll.dll msprog.exe gcc -g prog.c dll.lib -o gprog dll.dll: exp.o main.c gcc -g main.c dll_code.c exp.o -o dll.dll -mno-cygwin exp.o: dll_code.o dlltool -e exp.o -l dll.lib -D dll.dll --export-all-symbols dll_code.o dll_code.o: dll_code.c gcc -c -g dll_code.c clean: rm -f *.o *.exe* *.lib *.dll *.lreg *.obj vc6* msprog.exe: prog.c dll.lib cl prog.c dll.lib /D "WIN32" -Femsprog /nologo /W3 /GX /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c link prog.obj dll.lib ---------------------------------------------------------------------------- -- other thing is that MS linked executable do not statically load the DLL Raz -----Original Message----- From: Shamsutdinov, Salikhyan Sent: Tuesday, January 23, 2001 12:57 PM To: Peleg, Raz; 'razp AT iil DOT intel DOT com' Subject: RE: link GNU and msdev Sorry for mistake. The option is -mno-cygwin (compiled program will use crtdll.dll from Win32 and not Cygwin1.dll), this is the option of cc1.exe c compiler which gcc.exe calls. This works for both gcc version 2.91 and gcc version 2.95.2 what I use. Sasha. -----Original Message----- From: Peleg, Raz Sent: Tuesday, January 23, 2001 11:30 AM To: Shamsutdinov, Salikhyan Subject: RE: link GNU and msdev I'm trying to compile gdb my gcc compiler do not support this option. can you tell me in which versions it do work? thanks Raz -----Original Message----- From: Shamsutdinov, Salikhyan Sent: Tuesday, January 23, 2001 10:55 AM To: Peleg, Raz Subject: RE: link GNU and msdev Almost all GNU applications support -mno_cygwin compilation option for gcc, this allows to compile GNU application by using Win32 dll, not Cygnus1.dll. What is the name of GNU application you are trying to compile? Sasha. -----Original Message----- From: Raz Peleg [mailto:raz DOT peleg AT intel DOT com] Sent: Tuesday, January 23, 2001 10:22 AM To: cygwin AT cygwin DOT com Subject: link GNU and msdev Hi all, I'm trying to port a gnu application to windows, in order to do so I need to link a library compiled with gcc to my own code written on msdev. Q: Is any one know a way to do it smooth? It seem that ms compiler and gcc binaries do not share the same naming method and the linking fail. Q: Is there a way to convince them to work together? Another idea is to make the gnu libraries a win32 DLL, and to put away the join link, at this point I found msdev linked applications do not load this DLL at start and I must use dynamic DLL load [LoadLibrary()]. Q: any idea why? now it work on a little test case I made, as long as the dll do not contain library function call. Q: WHY??? regards Raz -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple ------_=_NextPart_000_01C08543.3A2AA430 Content-Type: application/octet-stream; name="main.c" Content-Disposition: attachment; filename="main.c" int main() {} ------_=_NextPart_000_01C08543.3A2AA430 Content-Type: application/octet-stream; name="dll_code.c" Content-Disposition: attachment; filename="dll_code.c" #include void print() { printf("Hello world\n"); } int f() { return 1; } ------_=_NextPart_000_01C08543.3A2AA430 Content-Type: application/octet-stream; name="Makefile" Content-Disposition: attachment; filename="Makefile" #makefile gprog.exe: prog.c dll.dll msprog.exe gcc -g prog.c dll.lib -o gprog dll.dll: exp.o main.c gcc -g main.c dll_code.c exp.o -o dll.dll -mno-cygwin -dll exp.o: dll_code.o dlltool -e exp.o -l dll.lib -D dll.dll --export-all-symbols dll_code.o dll_code.o: dll_code.c gcc -c -g dll_code.c clean: rm -f *.o *.exe* *.lib *.dll *.lreg *.obj vc6* msprog.exe: prog.c dll.lib cl prog.c dll.lib /D "WIN32" -Femsprog /nologo /W3 /GX /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c link prog.obj dll.lib ------_=_NextPart_000_01C08543.3A2AA430 Content-Type: application/octet-stream; name="prog.c" Content-Disposition: attachment; filename="prog.c" #include #ifdef WIN32 #include __declspec( dllimport ) void print(); __declspec( dllimport ) int f(); #else void print(); int f(); #endif void (*pPrint)(); int (*pF)(); int main() { #ifdef WIN32 HINSTANCE hLib; hLib = LoadLibrary("dll.dll"); pF = (int (*)(int val))GetProcAddress(hLib,"f"); pPrint = (int (*)(char*))GetProcAddress(hLib,"print"); #else pF = f; pPrint = print; #endif printf("%d\n",pF()); pPrint(); return 0; } ------_=_NextPart_000_01C08543.3A2AA430 Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple ------_=_NextPart_000_01C08543.3A2AA430--