This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Updating dll info in the User's Guide


Gerrit and other dll-builders,

Thanks for the update on dll-building. I almost missed this one...
I was thinking "Why doesn't someone just update the documentation?"
then realized "Hey, I volunteered to do that, didn't I?"
(BTW, everyone--could I get heads-up about the User's Guide like David gets
about the FAQ?)

Here is some new text to replace the section at

http://cygwin.com/cygwin-ug-net/dll.html

that begins with "Unfortunately, the process for building a dll is, well,
convoluted. You have to run five commands, like this"
This is not the actual patch, I will submit one of those after
I verify that I've got the subject matter correct.
Please read carefully since I'm not an expert in this area and may have
mixed up some terminology or concepts.

--------Begin new text--------
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:

#include <windows.h>

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'

--------End new text--------


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]