[so] tema3

Octavian Purdila so@atlantis.cs.pub.ro
Mon, 17 Nov 2003 19:54:43 +0200


On Mon, 17 Nov 2003 16:59:54 +0200, Bogdan Butnaru <bogdanb@fastmail.fm> 
wrote:

> 1. Pe pagina cu tema 3, la sfarsitul enuntului, spune ceva de alte trei
> probleme; Scrie acolo ca pentru cerinte a se vewdea FAQ, dar la FAQ nu
> zice nimic de pb.
>

Formularea va invita sa trimiteti mailuri pe lista daca exista neclaritati 
:)

> 2. In documentatia de mingw care e referita la observatii
> (http://www.mingw.org/docs.shtml) nu am gasit instructiuni despre creat
> DLL de windows. Zice acolo ceva de librarii .so, etc, dar de .dll nu am
> vazut nimic. Daca se poate un link mai precis...
>

Nu prea ai cautat... Al treilea bulet:

How to create a dll

Here's an example. Cut and paste the following into a file named dllfct.h:

    #ifdef BUILD_DLL
    // the dll exports
    #define EXPORT __declspec(dllexport)
    #else
    // the exe imports
    #define EXPORT __declspec(dllimport)
    #endif

    // function to be imported/exported
    EXPORT void tstfunc (void);


Cut and paste the following into a file named dllfct.c:

    #include <stdio.h>
    #include "dllfct.h"

    EXPORT void tstfunc (void)
    {
       printf ("Hello\n");
    }


Cut and paste the following into a file named hello.c:

    #include "dllfct.h"

    int main ()
    {
       tstfunc ();
       return (0);
    }


To create the dll and an executable that uses it, try the following:

    gcc -c hello.c
    gcc -c -DBUILD_DLL dllfct.c
    dllwrap --output-lib=libtstdll.a --dllname=tst.dll --driver-name=gcc 
dllfct.o
    gcc -o hello.exe hello.o -L./ -ltstdll


For more information on dlls, see 
http://www.nanotech.wisc.edu/~khan/software/gnu-win32/dllhelpers.html

tavi