diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index cc5cfe84d..fb8853363 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,11 @@ +2002-06-22 Joshua Daniel Franklin + + * dll.sgml: Refine dll build instructions. + +2002-08-21 Christopher Faylor + + * ntsec.html: Correct some typos. + 2002-07-23 Nicholas Wourms * calls.texinfo: Add fcloseall and fcloseall_r. diff --git a/winsup/doc/dll.sgml b/winsup/doc/dll.sgml index 274f12926..724c42d06 100644 --- a/winsup/doc/dll.sgml +++ b/winsup/doc/dll.sgml @@ -41,52 +41,40 @@ For this example, we'll use a single file Now compile everything to objects: - -gcc -c myprog.c -gcc -c mydll.c - +gcc -c myprog.c +gcc -c mydll.c -Unfortunately, the process for building a dll is, well, convoluted. -You have to run five commands, like this: +Fortunately, with the latest gcc and binutils the process for building a dll +is now much simpler. Say you want to build this minimal function in mydll.c: - -gcc -s -Wl,--base-file,mydll.base -o mydll.dll mydll.o -Wl,-e,_mydll_init@12 -dlltool --base-file mydll.base --def mydll.def --output-exp mydll.exp --dllname mydll.dll -gcc -s -Wl,--base-file,mydll.base,mydll.exp -o mydll.dll mydll.o -Wl,-e,_mydll_init@12 -dlltool --base-file mydll.base --def mydll.def --output-exp mydll.exp --dllname mydll.dll -gcc -Wl,mydll.exp -o mydll.dll mydll.o -Wl,-e,_mydll_init@12 - - -The extra steps give dlltool the -opportunity to generate the extra sections (exports and relocation) -that a dll needs. After this, you build the import library: - - -dlltool --def mydll.def --dllname mydll.dll --output-lib mydll.a - - -Now, when you build your program, you link against the import -library: - - -gcc -o myprog myprog.o mydll.a - - -Note that we linked with -e _mydll_init@12. -This tells the OS what the DLL's "entry point" is, and this is a -special function that coordinates bringing the dll to life withing the -OS. The minimum function looks like this: - - -#include <windows.h> - -int WINAPI +int WINAPI mydll_init(HANDLE h, DWORD reason, void *foo) { return 1; -} - +} +First compile mydll.c to object code: + +gcc -c mydll.c + +Then, tell gcc that it is building a shared library: + +gcc -shared -o mydll.dll mydll.o + +That's it! 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 \ + -Wl,--out-implib=lib${module}.dll.a \ + -Wl,--export-all-symbols \ + -Wl,--enable-auto-import \ + -Wl,--whole-archive ${old_lib} \ + -Wl,--no-whole-archive ${dependency_libs} + +Where ${module} is the name of your DLL, ${old_lib} are all +your object files, bundled together in static libs or single object +files and the ${dependency_libs} are import libs you need to +link against, e.g '-lpng -lz -L/usr/local/special -lmyspeciallib'. Linking Against DLLs diff --git a/winsup/doc/ntsec.sgml b/winsup/doc/ntsec.sgml index 8bb8a50ea..7f38fd755 100644 --- a/winsup/doc/ntsec.sgml +++ b/winsup/doc/ntsec.sgml @@ -286,9 +286,9 @@ powerusers::547: -As you can see I've changed my primary group membership from 513 (None) +As you can see, I've changed my primary group membership from 513 (None) to 547 (powerusers). So all file I created inside of Cygwin were now owned -by the powerusers group instead of None. This is the way I liked it. +by the powerusers group instead of None. This is the way I liked it. Groups may be mentioned in the passwd file, too. This has two advantages: