Hi Im trying to create a DLL from a library called Enet:
http://enet.bespin.org/
I got the source and compiled it into a static library,
then I created a new project:
// dll.h
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif
EXPORT int CALLBACK mymagicfunction(void);
#include <windows.h>
#include "dll.h"
EXPORT int CALLBACK mymagicfunction(void)
{
enet_initialize();
}
I told the IDE to use libenet.a as a linker. (the static library that I compiled)
the error message was:
ld.exe cannot find -lEnet
The below code worked for me in release, but not in debug.
#include <windows.h>
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT
#endif
#include "enet/enet.h"
int DLL_EXPORT CALLBACK mymagicfunction(void);
int DLL_EXPORT CALLBACK mymagicfunction(void)
{
enet_initialize();
}
As two files below. Works in release not in debug. A lot of the time debug needs windows libraries not on my system to work, it could work on yours.
Remember to define BUILD_DLL in the project building the DLL.
Tim S
// dll.h
#ifndef DLL_H_INCLUDED
#define DLL_H_INCLUDED
#ifdef BUILD_DLL
#define DLL_EXPORT __declspec(dllexport)
#else
#define DLL_EXPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
int DLL_EXPORT CALLBACK mymagicfunction(void);
#ifdef __cplusplus
}
#endif
#endif // DLL_H_INCLUDED
#include <windows.h>
#include "dll.h"
#include "enet/enet.h"
int DLL_EXPORT CALLBACK mymagicfunction(void)
{
enet_initialize();
}