From 0fd3e6ea29b066919ac03016d9bacf81693cb744 Mon Sep 17 00:00:00 2001 From: Joshua Daniel Franklin Date: Wed, 23 Oct 2002 03:55:34 +0000 Subject: * dll.sgml: Simplify dll build instructions. --- winsup/doc/ChangeLog | 4 ++++ winsup/doc/dll.sgml | 45 ++++++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index f454f9901..abced3172 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,7 @@ +2002-10-22 Joshua Daniel Franklin + + * dll.sgml: Simplify dll build instructions. + 2002-09-11 Corinna Vinschen * ntsec.html: Add chapter for switching user context w/o password. diff --git a/winsup/doc/dll.sgml b/winsup/doc/dll.sgml index 8ba1a6095..d5d8a2f13 100644 --- a/winsup/doc/dll.sgml +++ b/winsup/doc/dll.sgml @@ -39,19 +39,18 @@ For this example, we'll use a single file mydll.c for the contents of the dll (mydll.dll). -Now compile everything to objects: - -gcc -c myprog.c -gcc -c mydll.c - Fortunately, with the latest gcc and binutils the process for building a dll is now pretty simple. Say you want to build this minimal function in mydll.c: -int WINAPI -mydll_init(HANDLE h, DWORD reason, void *foo) + +#include <stdio.h> + +int +hello() { - return 1; -} + printf ("Hello World!\n"); +} + First compile mydll.c to object code: @@ -61,7 +60,26 @@ mydll_init(HANDLE h, DWORD reason, void *foo) gcc -shared -o mydll.dll mydll.o -That's it! However, if you are building a dll as an export library, + +That's it! To finish up the example, you can now link to the +dll with a simple program: + + + +int +main () +{ + hello (); +} + + + +Then link to your dll with a command like: + + +gcc -o myprog myprog.ca -L./ -lmydll + +However, if you are building a dll as an export library, you will probably want to use the complete syntax: gcc -shared -o cyg${module}.dll \ @@ -80,9 +98,10 @@ link against, e.g '-lpng -lz -L/usr/local/special -lmyspeciallib'. Linking Against DLLs If you have an existing DLL already, you need to build a -Cygwin-compatible import library (The supplied ones should work, but -you might not have them) to link against. Unfortunately, there is not -yet any tool to do this automatically. However, you can get most of +Cygwin-compatible import library. If you have the source to compile +the DLL, see for details on having +gcc build one for you. If you do not have the +source or a supplied working import library, you can get most of the way by creating a .def file with these commands (you might need to do this in bash for the quoting to work correctly): -- cgit v1.2.3