Subject: RE: link GNU and msdev
From: "Peleg, Raz" <[email-masked]>
To: "Shamsutdinov, Salikhyan" <[email-masked]>
Cc: "[email-masked]'" <[email-masked]>
Date: Tue, 23 Jan 2001 05:48:55 -0800

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 <stdio.h>

void print()
{
	printf("Hello world\n");
}

int f()
{
	return 1;
}
----------------------- prog.c -----------------------
#include <stdio.h>

#ifdef WIN32
#include <windows.h>
	__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; [email-masked]'
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:[email-masked]]
Sent: Tuesday, January 23, 2001 10:22 AM
To: [email-masked]
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

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple