i want to build a dll using wxWidgets classes with no GUI
inside. it can't be compiled, i search solution on the forum,
most of the dll question about creating GUI dll,which is not
i want.
i post the source code,hope you correct my mistakes.
i use wxDevc++ 6.10.2
dll.h
Code: Select all
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
#include "windows.h"
#include <wx/wx.h>
#include <wx/thread.h>
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
private:
};
class wxDLLApp : public wxApp
{
bool OnInit();
DECLARE_EVENT_TABLE()
};
#endif /* _DLL_H_ */
dllmain.cpp
Code: Select all
/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>
DllClass::DllClass()
{
}
DllClass::~DllClass ()
{
}
BEGIN_EVENT_TABLE(wxDLLApp, wxApp)
END_EVENT_TABLE()
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
{
wxInitialize(hInst); /* compiler errors,
In function `BOOL DllMain(HINSTANCE__*, DWORD, void*)':
invalid conversion from `HINSTANCE__*' to `int'
initializing argument 1 of `bool wxInitialize(int, wxChar**)'
[Build Error] exe: *** [Output/MingW/dllmain.o] Error 1
i read the wxInitialize() documentation, it does explain much, don't understand. */
int argc = 0;
char **argv = NULL;
wxEntryStart(argc, argv);
if ( !wxTheApp || !wxTheApp->CallOnInit() )
return FALSE;
}
break;
case DLL_PROCESS_DETACH:
{
wxUninitialize();
}
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}