* dll.sgml: Simplify dll build instructions.
This commit is contained in:
parent
281e3b2423
commit
0fd3e6ea29
|
@ -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>
|
2002-09-11 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* ntsec.html: Add chapter for switching user context w/o password.
|
* ntsec.html: Add chapter for switching user context w/o password.
|
||||||
|
|
|
@ -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.c</filename> for the contents of the dll
|
||||||
(<filename>mydll.dll</filename>).</para>
|
(<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
|
<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>
|
is now pretty simple. Say you want to build this minimal function in mydll.c:</para>
|
||||||
|
|
||||||
<screen>int WINAPI
|
<screen>
|
||||||
mydll_init(HANDLE h, DWORD reason, void *foo)
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
hello()
|
||||||
{
|
{
|
||||||
return 1;
|
printf ("Hello World!\n");
|
||||||
}</screen>
|
}
|
||||||
|
</screen>
|
||||||
|
|
||||||
<para>First compile mydll.c to object code:</para>
|
<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>
|
<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>
|
you will probably want to use the complete syntax:</para>
|
||||||
|
|
||||||
<screen>gcc -shared -o cyg${module}.dll \
|
<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>
|
<sect2 id="dll-link"><title>Linking Against DLLs</title>
|
||||||
|
|
||||||
<para>If you have an existing DLL already, you need to build a
|
<para>If you have an existing DLL already, you need to build a
|
||||||
Cygwin-compatible import library (The supplied ones should work, but
|
Cygwin-compatible import library. If you have the source to compile
|
||||||
you might not have them) to link against. Unfortunately, there is not
|
the DLL, see <Xref Linkend="dll-build"> for details on having
|
||||||
yet any tool to do this automatically. However, you can get most of
|
<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
|
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
|
do this in <filename>bash</filename> for the quoting to work
|
||||||
correctly):</para>
|
correctly):</para>
|
||||||
|
|
Loading…
Reference in New Issue