need help in compiling non-GUI DLL Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
smallwolf
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sun Aug 26, 2007 11:02 pm

need help in compiling non-GUI DLL

Post by smallwolf »

hello:
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;
}
have a nice day!:)
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod »

I found someone who is trying to do the same thing as I am. Are you building a library only to call it's functions or does it store any variables, like global variables?

If it is only a library for you to call functions from it, there is no need for a wxApp, wxinitialize or anything like that if the application that calls it uses wxWidgets.

My next step is trying to compile a DLL that has many objects that need to be initiliazed when the dll is loaded and the hard part is for it to work on both windows and linux, cause that code of your is windows specific.

see ya
smallwolf
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sun Aug 26, 2007 11:02 pm

Post by smallwolf »

rodrigod wrote:I found someone who is trying to do the same thing as I am. Are you building a library only to call it's functions or does it store any variables, like global variables?

If it is only a library for you to call functions from it, there is no need for a wxApp, wxinitialize or anything like that if the application that calls it uses wxWidgets.

My next step is trying to compile a DLL that has many objects that need to be initiliazed when the dll is loaded and the hard part is for it to work on both windows and linux, cause that code of your is windows specific.

see ya
thanks!
if i use wxInitialize(hInst), i got compiler errors above,
if i cancled it from source code, i got many linker errors.
could you post the complete source code that works and using
wxwidgets in dll?(simple non-GUI dll, i want to know the basic structure of wxwidgets dll)

have a nice day!
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod »

Before I post the code I need to know if the Application that calls the dll uses wxwidgets.
smallwolf
Experienced Solver
Experienced Solver
Posts: 69
Joined: Sun Aug 26, 2007 11:02 pm

Post by smallwolf »

rodrigod wrote:Before I post the code I need to know if the Application that calls the dll uses wxwidgets.

yes! thanks! :)
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod »

Actually if it is only a function library there is no need for anything, no wxInitialize no wxApp no anything, just the funtions you will use.

I thik it's because the application has already initialized wxWidgets, so the library doesn't have to do anything.

If you need to have objects initialized on OnInit than things change but I am still running some tests to make to code portable.[/code]
Post Reply