Creating a LIB or DLL
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
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
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
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
Still have problem with :
_HB_FUN_LOADLIBRARY
_HB_FUN_FREELIBRARY
_HB_FUN_ANSITOWIDE
Here is my current babudll.prg:
Program:
Here is my current buildhd.bat :
Thanks
Still have problem with :
_HB_FUN_LOADLIBRARY
_HB_FUN_FREELIBRARY
_HB_FUN_ANSITOWIDE
Here is my current babudll.prg:
Program:
Code: Select all
// 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
Code: Select all
@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
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
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 !
...
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 !
...
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
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
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
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
Where have you downloaded maindll.c from ?
How have you compiled maindll.c ? What compiler flags have you used ?
Where have you downloaded maindll.c from ?
How have you compiled maindll.c ? What compiler flags have you used ?
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
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
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
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Re: Creating a LIB or DLL
Code: Select all
%bcdir%\bin\bcc32 -c -D__EXPORT__ -I%hdir%\include;%bcdir%\include -L%bcdir%\..\lib maindll.c
Code: Select all
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
Vailton Renato
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
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
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
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Re: Creating a LIB or DLL
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.
Maybe this could be it mixed in the command line you posted above.
Vailton Renato
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
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.
> 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.
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
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
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
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
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.
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.
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
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 )
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 )
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
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
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
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
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
Just to be sure that HB_EXPORT gets properly translated, better replace those lines as I have explained you and compile it again.
Just to be sure that HB_EXPORT gets properly translated, better replace those lines as I have explained you and compile it again.