Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Tue, 27 Aug 2002 11:50:36 +0200
From: "Gerrit P. Haase" <freeweb@nyckelpiga.de>
Reply-To: "Gerrit P. Haase" <freeweb@nyckelpiga.de>
Organization: Esse keine toten Tiere
X-Priority: 3 (Normal)
Message-ID: <50-323541628.20020827115036@familiehaase.de>
To: "Niraj Agarwal" <niraja@npi.stpn.soft.net>
CC: cygwin@cygwin.com
Subject: Re: DLL Linking Problem
In-Reply-To: <001a01c24da3$35aec790$46ca09c0@aniraj>
References: <001a01c24da3$35aec790$46ca09c0@aniraj>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------E3D88AC033D4A"

------------E3D88AC033D4A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Niraj schrieb:

[dll problems with simple dll]

Your example is not simple, see this really simple example:

TestDll.c:
==========
#include <stdio.h>
void  printVal()
{
        printf("Hello World!");
}

TestDll.h:
==========
void printVal();

testmain.c:
===========
#include "TestDll.h"
int main()
{
        printVal();
        return 1;
}


$ gcc -c TestDll.c -o TestDll.o

$ gcc -shared -o cygTestDll.dll \
      -Wl,--out-implib=libTestDll.dll.a \
      -Wl,--export-all-symbols \
      -Wl,--enable-auto-import \
      -Wl,--whole-archive TestDll.o \
      -Wl,--no-whole-archive
Creating library file: libTestDll.dll.a

$ gcc -o testmain testmain.c -L. -lTestDll

$ ./testmain
Hello World!


Gerrit
-- 
=^..^=
------------E3D88AC033D4A
Content-Type: text/plain; name="testmain.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="testmain.c"

I2luY2x1ZGUgIlRlc3REbGwuaCIKaW50IG1haW4oKQp7CglwcmludFZhbCgpOwoJcmV0dXJuIDE7
Cn0KCg==

------------E3D88AC033D4A
Content-Type: text/plain; name="TestDll.h"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="TestDll.h"

dm9pZCBwcmludFZhbCgpOwo=

------------E3D88AC033D4A
Content-Type: text/plain; name="TestDll.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="TestDll.c"

I2luY2x1ZGUgPHN0ZGlvLmg+CnZvaWQgIHByaW50VmFsKCkKewoJcHJpbnRmKCJIZWxsbyBXb3Js
ZCEiKTsKfQo=


------------E3D88AC033D4A
Content-Type: text/plain; charset=us-ascii

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

