Creating a LIB or DLL

Re: Creating a LIB or DLL

Postby Antonio Linares » Wed Mar 18, 2009 11:35 pm

Dave,

Please add this code at the beginning of babudll.prg:

extern LoadLibrary, FreeLibrary, AnsiToWide

Please modify buildhd.bat to use gtgui.lib instead of gtwin.lib
and add this library too:

echo %bcdir%\lib\psdk\msimg32.lib + >> b32.bc This one !!!
echo %bcdir%\lib\psdk\rasapi32.lib, >> b32.bc
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby Dave Zowasky » Thu Mar 19, 2009 3:54 pm

Antonio,

Still have problem with :

_HB_FUN_LOADLIBRARY
_HB_FUN_FREELIBRARY
_HB_FUN_ANSITOWIDE

Here is my current babudll.prg:

Program:
Code: Select all  Expand view

// To build BabuDLL.dll do: buildhd.bat babuDLL

// To run this DLL, do buidh.bat Babu.prg

extern LoadLibrary, FreeLibrary, AnsiToWide

function Test( cMsg1, cMsg2 )

   MsgInfo( cMsg1, cMsg2 )

return nil
 


Here is my current buildhd.bat :

Code: Select all  Expand view
@ECHO OFF
CLS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ FiveWin for Harbour 9.02 - Feb. 2009             Harbour development power ³Ü
ECHO ³ (c) FiveTech, 1993-2009      for Microsoft Windows 95/98/NT/2000/ME and XP ³Û
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ECHO ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß

@echo off
if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST

ECHO Compiling...

set hdir=c:\harbour
set bcdir=c:\bcc55

%hdir%\bin\harbour %1 /n /i..\include;%hdir%\include /w /p %2 %3 > clip.log
@type clip.log
IF ERRORLEVEL 1 PAUSE
IF ERRORLEVEL 1 GOTO EXIT

echo -O2 -I%hdir%\include;%bcdir%\include %1.c > b32.bc
%bcdir%\bin\bcc32 -M -c @b32.bc
:ENDCOMPILE

IF EXIST %1.rc %bcdir%\bin\brc32 -r %1

echo c0d32.obj + %hdir%\obj\b32\maindll.obj + > b32.bc
echo %1.obj, + >> b32.bc
echo %1.dll, + >> b32.bc
echo %1.map, + >> b32.bc
echo ..\lib\FiveH.lib ..\lib\FiveHC.lib + >> b32.bc
ECHO %hdir%\lib\hbrtl.lib + >> b32.bc
ECHO %hdir%\lib\hbvm.lib + >> b32.bc
ECHO %hdir%\lib\gtgui.lib + >> b32.bc
ECHO %hdir%\lib\hblang.lib + >> b32.bc
ECHO %hdir%\lib\hbmacro.lib + >> b32.bc
ECHO %hdir%\lib\hbrdd.lib + >> b32.bc
ECHO %hdir%\lib\rddntx.lib + >> b32.bc
ECHO %hdir%\lib\rddcdx.lib + >> b32.bc
ECHO %hdir%\lib\hbdebug.lib + >> b32.bc
ECHO %hdir%\lib\hbcommon.lib + >> b32.bc
ECHO %hdir%\lib\hbpp.lib + >> b32.bc
ECHO %hdir%\lib\hbmzip.lib + >> b32.bc
ECHO %hdir%\lib\hbsix.lib + >> b32.bc
ECHO %hdir%\lib\rddfpt.lib + >> b32.bc
ECHO %bcdir%\lib\cw32.lib + >> b32.bc
ECHO %bcdir%\lib\import32.lib + >> b32.bc
ECHO %bcdir%\lib\psdk\odbc32.lib + >> b32.bc
ECHO %bcdir%\lib\uuid.lib + >> b32.bc
echo %bcdir%\lib\psdk\msimg32.lib + >> b32.bc
echo %bcdir%\lib\psdk\rasapi32.lib, >> b32.bc
IF EXIST %1.res echo %1.res >> b32.bc
%bcdir%\bin\ilink32 -Tpd -aa -L%bcdir%\lib;%hdir%\lib @b32.bc

IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * self contained DLL successfully built
GOTO EXIT
ECHO

rem delete temporary files
@del %1.c
@del %1.il?

:LINKERROR
ECHO * There are errors
GOTO EXIT

:SINTAX
ECHO    SYNTAX: Build [Program]     {-- No especifiques la extensi›n PRG
ECHO                                {-- Don't specify .PRG extension
GOTO EXIT

:NOEXIST
ECHO The specified PRG %1 does not exist

:EXIT


Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Thu Mar 19, 2009 8:01 pm

Dave,

Please add this library to buildhd.bat and try it again, thanks:

echo %hdir%\lib\rddfpt.lib + >> b32.bc
echo %hdir%\lib\hbwin.lib + >> b32.bc // this one !
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby Dave Zowasky » Thu Mar 19, 2009 11:28 pm

Antonio,

Added the line to the batch file and it creates the dll, however when I compile babu.prg and run
it I am getting :

An exception error(C0000005) occurred during DllEntryPoint or DllMain in module:
c:\fwh\samples\babudll.dll


Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Fri Mar 20, 2009 2:00 am

Dave,

Where have you downloaded maindll.c from ?

How have you compiled maindll.c ? What compiler flags have you used ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby Dave Zowasky » Fri Mar 20, 2009 1:28 pm

Antonio,

I used the latest maindll.c from the harbour-1.0.1\source\vm\maindll.c

I can post it if needed:

I added this to my buildhd.bat

%bcdir%\bin\bcc32 -c -D__EXPORT__ -I%hdir%\include;%bcdir%\include -L%bcdir%\..\lib maindll.c

Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby vailtom » Fri Mar 20, 2009 2:55 pm

Code: Select all  Expand view
%bcdir%\bin\bcc32 -c -D__EXPORT__ -I%hdir%\include;%bcdir%\include -L%bcdir%\..\lib maindll.c

The are changed __EXPORT__ macro to HB_DYNLIB:
Code: Select all  Expand view
2008-08-16 16:16 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
   * make_b32.mak
   * make_gcc.mak
   * make_vc.mak
   * make_vcce.mak
   * include/hbdefs.h
   * source/vm/mainwin.c
   * source/vm/hvm.c
   * source/hbpcre/_hbconf.h
   * source/hbzlib/ChangeLog
   * source/hbzlib/zconf.h
   * utils/hbmake/hbmake.prg
     * __EXPORT__ -> HB_DYNLIB
 

See INSTALL file into source tree for more info.
Vailton Renato
User avatar
vailtom
 
Posts: 47
Joined: Thu Jan 05, 2006 6:56 pm

Re: Creating a LIB or DLL

Postby Dave Zowasky » Fri Mar 20, 2009 3:06 pm

Vailton,

I appreciate the info, however I am not sure what to do with it.

Do I need to change my batch file from __EXPORT__ to HB_DYNLIB ?

Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby vailtom » Fri Mar 20, 2009 3:34 pm

When you compile a .DLL should not use the macro __EXPORT__ as it is in changelog, this was changed.
Maybe this could be it mixed in the command line you posted above.
Vailton Renato
User avatar
vailtom
 
Posts: 47
Joined: Thu Jan 05, 2006 6:56 pm

Re: Creating a LIB or DLL

Postby Antonio Linares » Fri Mar 20, 2009 3:53 pm

Dave,

> Do I need to change my batch file from __EXPORT__ to HB_DYNLIB ?

Yes

Once the DLL is built, please do:

impdef.exe YourDll.DEF YourDll.DLL

and check the contents of YourDll.DEF. It is an ascii file that shows what symbols are exported from the DLL.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby Dave Zowasky » Fri Mar 20, 2009 4:41 pm

Antonio,

Got this in mydll.def

LIBRARY BABUDLL.DLL

EXPORTS
__DbgWndProc @1 ; __DbgWndProc
__WndProc @2 ; __WndProc
___CPPdebugHook @3 ; ___CPPdebugHook

Not sure what to do next.

Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Fri Mar 20, 2009 8:34 pm

Dave,

These lines should be inside the DEF file:

DllEntryPoint @894 ; DllEntryPoint
HBDLLENTRY @895 ; HBDLLENTRY
HBDLLENTRY1 @896 ; HBDLLENTRY1
HBDLLENTRY2 @897 ; HBDLLENTRY2

Those numbers can be different.

If you don't have them, then it means that maindll.obj is not being properly built.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby Antonio Linares » Fri Mar 20, 2009 8:42 pm

Dave,

Please make these changes in maindll.c, and compile it again and build the DLL:

BOOL WINAPI __export DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )

LONG PASCAL __export HBDLLENTRY( char * cProcName )

LONG PASCAL __export HBDLLENTRY1( char * cProcName, LONG pItem )

LONG PASCAL __export HBDLLENTRY2( char * cProcName, LONG pItem1, LONG pItem2 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Creating a LIB or DLL

Postby Dave Zowasky » Fri Mar 20, 2009 10:02 pm

Antonio,

Like:

HB_EXPORT BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )

to

BOOL WINAPI _export DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )

Also

You have
__export

should I use?
_export


Correct?

If so still have same


Thanks



Code: Select all  Expand view
HB_EXPORT BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{
   HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %p)", hInstance, fdwReason,
             pvReserved ) );

   HB_SYMBOL_UNUSED( hInstance );
   HB_SYMBOL_UNUSED( fdwReason );
   HB_SYMBOL_UNUSED( pvReserved );

   switch( fdwReason )
   {
      case DLL_PROCESS_ATTACH:
           hb_vmInit( FALSE );  /* Don't execute first linked symbol */
           break;

      case DLL_PROCESS_DETACH:
           hb_vmQuit();
           break;
   }

   return TRUE;
}

HB_EXPORT LONG PASCAL HBDLLENTRY( char * cProcName )
{
   hb_itemDoC( cProcName, 0, 0 );

   return 0;
}

HB_EXPORT LONG PASCAL _export HBDLLENTRY1( char * cProcName, LONG pItem )
{
   hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );

   return 0;
}

HB_EXPORT LONG PASCAL t HBDLLENTRY2( char * cProcName, LONG pItem1, LONG pItem2 )
{
   hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );

   return 0;
}
 
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Fri Mar 20, 2009 10:46 pm

Dave,

Just to be sure that HB_EXPORT gets properly translated, better replace those lines as I have explained you and compile it again.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 38 guests