delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/08/21/11:34:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
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" <gp AT familiehaase DOT de>
Organization: Esse keine toten Tiere
X-Priority: 3 (Normal)
Message-ID: <189433577221.20020821173518@familiehaase.de>
To: Joshua Daniel Franklin <joshuadfranklin AT yahoo DOT com>
CC: cygwin AT cygwin DOT com
Subject: Re: Updating dll info in the User's Guide
In-Reply-To: <Pine.CYG.4.44.0208202127280.1336-100000@joshua.iocc.com>
References: <Pine DOT CYG DOT 4 DOT 44 DOT 0208202127280 DOT 1336-100000 AT joshua DOT iocc DOT com>
MIME-Version: 1.0

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<iostream>
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 <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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019