library

Printer-friendly version

HOWTO Create and Deploy a Sample DLL using MinGW

A sample DLL

The DLL we will build will consist of a single source file "example_dll.cpp":

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

__stdcall void hello(const char *s)
{
        printf("Hello %s\n", s);
}
int Double(int x)
{
        return 2 * x;
}
void CppFunc(void)
{
        puts("CppFunc");
}
void MyClass::func(void)
{
        puts("MyClass.func()");
}

The following header "example_dll.h" declares the interface of the DLL, and is used both when building the DLL and when building an executable that uses the DLL:

<pre>

  1. ifndef EXAMPLE_DLL_H

HOWTO Create an Import Library for a DLL using MinGW

This page is about how to "call into" an existing DLL, using your mingw program. for information on creating your own DLL library, see DLL.

Usually (read: for all DLLs created with MinGW and also a few others) MinGW links fine against a DLL. No special import library is necessary (see sampleDLL).

However there are situations when it won't. Then one needs a so-called import library to help the linker. The rest of this page gives hints as to how to create such import libraries when there is only the DLL available.

Site Status

Site maintenance completed May 25th, 2012 at 12:38 UTC