diff options
author | Joshua Daniel Franklin <joshuadfranklin@yahoo.com> | 2002-10-23 03:55:34 +0000 |
---|---|---|
committer | Joshua Daniel Franklin <joshuadfranklin@yahoo.com> | 2002-10-23 03:55:34 +0000 |
commit | 0fd3e6ea29b066919ac03016d9bacf81693cb744 (patch) | |
tree | ed7b16fbd32565a1a6b3291ca9d6ddc864b3c746 /winsup/doc | |
parent | 281e3b24234d5e0a0ac6a2d8aaca5bffccbba0e2 (diff) | |
download | cygnal-0fd3e6ea29b066919ac03016d9bacf81693cb744.tar.gz cygnal-0fd3e6ea29b066919ac03016d9bacf81693cb744.tar.bz2 cygnal-0fd3e6ea29b066919ac03016d9bacf81693cb744.zip |
* dll.sgml: Simplify dll build instructions.
Diffstat (limited to 'winsup/doc')
-rw-r--r-- | winsup/doc/ChangeLog | 4 | ||||
-rw-r--r-- | 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 <joshuadfranklin@yahoo.com> + + * dll.sgml: Simplify dll build instructions. + 2002-09-11 Corinna Vinschen <corinna@vinschen.de> * 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 <filename>mydll.c</filename> for the contents of the dll (<filename>mydll.dll</filename>).</para> -<para>Now compile everything to objects:</para> - -<screen>gcc -c myprog.c -gcc -c mydll.c</screen> - <para>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:</para> -<screen>int WINAPI -mydll_init(HANDLE h, DWORD reason, void *foo) +<screen> +#include <stdio.h> + +int +hello() { - return 1; -}</screen> + printf ("Hello World!\n"); +} +</screen> <para>First compile mydll.c to object code:</para> @@ -61,7 +60,26 @@ mydll_init(HANDLE h, DWORD reason, void *foo) <screen>gcc -shared -o mydll.dll mydll.o</screen> -<para>That's it! However, if you are building a dll as an export library, +<para> +That's it! To finish up the example, you can now link to the +dll with a simple program: +</para> + +<screen> +int +main () +{ + hello (); +} +</screen> + +<para> +Then link to your dll with a command like: +</para> + +<screen>gcc -o myprog myprog.ca -L./ -lmydll</screen> + +<para>However, if you are building a dll as an export library, you will probably want to use the complete syntax:</para> <screen>gcc -shared -o cyg${module}.dll \ @@ -80,9 +98,10 @@ link against, e.g '-lpng -lz -L/usr/local/special -lmyspeciallib'.</para> <sect2 id="dll-link"><title>Linking Against DLLs</title> <para>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 <Xref Linkend="dll-build"> for details on having +<filename>gcc</filename> 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 <filename>bash</filename> for the quoting to work correctly):</para> |