Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Wed, 21 Aug 2002 17:35:18 +0200 From: "Gerrit P. Haase" Organization: Esse keine toten Tiere X-Priority: 3 (Normal) Message-ID: <189433577221.20020821173518@familiehaase.de> To: Joshua Daniel Franklin CC: cygwin AT cygwin DOT com Subject: Re: Updating dll info in the User's Guide In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hallo Joshua, Am Mittwoch, 21. August 2002 um 04:28 schriebst du: > 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-------- Maybe it would be easier to get into with a real example (s.th. like this, without your comments): dlltest.C: ========== #include int hello () { using namespace std; cout << "Just another dll hacker,"; } $ g++ -c dlltest.C $ g++ -shared -o mydll.dll \ > -Wl,--out-implib=libmydll.dll.a \ > -Wl,--export-all-symbols \ > -Wl,--enable-auto-import \ > -Wl,--whole-archive dlltest.o \ > -Wl,--no-whole-archive exetest.C: ========== void hello (); int main () { hello (); return 1; } $ g++ -o exetest exetest.C -L/d/dlltest -lmydll $ ./exetest Just another dll hacker, > 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 > 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/