1. RE: Making DLL's with Eu

> -----Original Message-----
> From: Grape Vine [mailto:g__vine at hotmail.com]
> 
> Could anyone kindly post a fully working example of making 
> dlls with Eu 
> and Bcc?? Once i see who/what/when/why/where I think i can do it =)
> I am looking to make DLL's for mirc so a working example for 
> mirc would 
> be best(as i am unsure how to pass args to/from mirc to a eu dll 
> correctly(i know how to pass args from mirc to a dll(i belive))

I can't help you with mirc specifically, but here's what I've been able to
do with bcc.  All of the procedures you'll be exporting should take
atoms/integers as params.  I suppose objects will work as well, but, of
course, you could only pass a sequence from another routine in the DLL.

You'll need to add some dummy calls to the routines to export, or the
translator will optimize them away. Here's what I've been doing:

global function SQLAllocHandle( atom htype, atom parent )
..
end function

? SQLAllocHandle( rand(500), rand(500) )

Once you've debugged and added the dummy calls, translate with ecw.  There
are a few changes you'll need to make.  First, change main_.c

void WinMain( .......)
to

int _stdcall _export LibMain( void *hInstance, int Reason )

Then comment out the parts in LibMain that deal with either argv or argc
(since there will be no command line arguments).  Now you need to remove the
dummy calls from LibMain.  If you're registered, it should be easy to find
them.  Otherwise, look for all the calls to the functions, and comment that
out, or delete.  You'll also need to get rid of Cleanup(0);.  If you have a
big program (like maybe you're using win32lb), you may have to look in
main_1.c, main_2.c, etc for this stuff.  Technically, you should probably
put all of this within a switch statement to check for Reason =
DLL_PROCESS_ATTACH, but it seems to work ok without doing this.

Then you need to open up the c file generated that contains the routines you
want to export.  I like to rename the functions, since the _[filenum] is
added.  If you do this, just make sure that if any renamed functions are
called within your code that you fix those calls, as well.  Then add
_stdcall _export to the declaration, between int and the function's name:

int _stdcall _export SQLAllocHandle( int _htype, int _parent )

Open up emake.bat, and change the command line option '-tW' to '-tWD'.  This
tells bcc to create a DLL instead of an EXE.

I've found that if you treat an atom as a pointer in Euphoria, it's fine
when translated to C.  You'll have to consult the mirc API for specifics on
how to interact with it.

Matt Lewis

new topic     » topic index » view message » categorize

2. RE: Making DLL's with Eu

On 14 Mar 2001, at 7:47, Matthew Lewis wrote:

> 
> 
> 
> > -----Original Message-----
> > From: Grape Vine [mailto:g__vine at hotmail.com]
> > 
> > Could anyone kindly post a fully working example of making 
> > dlls with Eu 
> > and Bcc?? Once i see who/what/when/why/where I think i can do it =)
> > I am looking to make DLL's for mirc so a working example for 
> > mirc would 
> > be best(as i am unsure how to pass args to/from mirc to a eu dll 
> > correctly(i know how to pass args from mirc to a dll(i belive))
> 
> I can't help you with mirc specifically, but here's what I've been able to
> do with bcc.  All of the procedures you'll be exporting should take
> atoms/integers as params.  I suppose objects will work as well, but, of
> course, you could only pass a sequence from another routine in the DLL.
> 
> You'll need to add some dummy calls to the routines to export, or the
> translator will optimize them away. Here's what I've been doing:
> 
> global function SQLAllocHandle( atom htype, atom parent )
> ...
> end function
> 
> ? SQLAllocHandle( rand(500), rand(500) )
> 
> Once you've debugged and added the dummy calls, translate with ecw.  There
> are a few changes you'll need to make.  First, change main_.c
> 
> void WinMain( .......)
> to
> 
> int _stdcall _export LibMain( void *hInstance, int Reason )
> 
> Then comment out the parts in LibMain that deal with either argv or argc
> (since there will be no command line arguments).  Now you need to remove the
> dummy calls from LibMain.  If you're registered, it should be easy to find
> them.  Otherwise, look for all the calls to the functions, and comment that
> out, or delete.  You'll also need to get rid of Cleanup(0);.  If you have a
> big program (like maybe you're using win32lb), you may have to look in
> main_1.c, main_2.c, etc for this stuff.  Technically, you should probably
> put all of this within a switch statement to check for Reason =
> DLL_PROCESS_ATTACH, but it seems to work ok without doing this.
> 
> Then you need to open up the c file generated that contains the routines you
> want to export.  I like to rename the functions, since the _[filenum] is
> added.  If you do this, just make sure that if any renamed functions are
> called within your code that you fix those calls, as well.  Then add
> _stdcall _export to the declaration, between int and the function's name:
> 
> int _stdcall _export SQLAllocHandle( int _htype, int _parent )
> 
> Open up emake.bat, and change the command line option '-tW' to '-tWD'.  This
> tells bcc to create a DLL instead of an EXE.

Sheesh, you'd think Robert would make this automated! I mean really....

if found(--calledprogram in source code) then remove the "_" from following
function
line, and don't optimise it away, etc......

Kat

new topic     » goto parent     » topic index » view message » categorize

3. RE: Making DLL's with Eu

> -----Original Message-----
> From: Kat [mailto:gertie at PELL.NET]
> 
> Sheesh, you'd think Robert would make this automated! I mean 
> really....
> 
> if found(--calledprogram in source code) then remove the "_" 
> from following function 
> line, and don't optimise it away, etc......

I think he has said that DLL creation is in the translator's future.  I
don't know about any specifics, however, here are some suggestions.  Add a
command line option for ecw: '-dll'.  Don't add any prefixes to global
functions and add _export _stdcall to the definition.  Also, generate
LibMain, rather than WinMain, of course.

As for the optimization, that's exactly what it does (as far as removing the
function).  But remember that a DLL is really like an include file.  Most
libraries don't call their own functions.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu