FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Maestro Antonio: Ayuda con PCODE DLL
Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Maestro Antonio: Ayuda con PCODE DLL
Posted: Wed Sep 23, 2009 12:28 AM
Hola amigos,

Cada actualizaci贸n a un nuevo PCODE de xHarbour es como parir un erizo (puerco esp铆n). Tengo man铆a y dependencia total de c贸digo contenido en DLL麓s. Cada cambio en xHarbour desbaratan lo que antes funcionaba. Qu茅 locura.

Todas mis Dll麓s son autocontenidas (pueden usarse desde cualquier EXE, escrito en cualquier lenguaje).

Ahora, con xHarbour 1.2.1 PCode Versi贸n 10 ya no funcionan m谩s. :-) :-) :-)

He buscado por todo el foro as铆 como en el de xHarbour y no encuentro soluci贸n.

Si en el bat de generaci贸n de la DLL se agrega Harbour.lib funciona, pero la DLL no contiene la VM de xHarbour. Ejecuta el c贸digo contenido de la DLL, recibe y devuelve par谩metros, etc.

Si quito Harbour.lib, SI contiene la VM, pero NO ejecuta el c贸digo contenido en la DLL, aunque devuelve par谩metros.

Aqu铆 va el c贸digo de prueba con FWH 9.08, xHarbour 1.2.1 y Borland 5.5

C贸digo de la DLL, PruDll.prg:
Code (fw): Select all Collapse
#include "\FWH-908\INCLUDE\FiveWin.ch"


FUNCTION DllFunc1()
聽 聽local cLaResp:="Dato retornado desde la DLL, Function DllFunc1()"

聽 聽MsgInfo("Estamos dentro de la DLL, en Function DllFunc1()")

聽 聽PUBLIC 聽cVar1:="cVar 1 creada en DllFunc1"
聽 聽PRIVATE cVar2:="Creada en DllFunc y ser谩 usada en DllFunc2()"

聽 聽DllFunc2()

RETURN(cLaResp)


Procedure DllFunc2
聽 聽MsgInfo("Dentro de DllFunc2() leemos la cVar2 que es PRIVATE y creada en DllFunc1: 聽 "+cVar2)
Return


C贸digo del Programa Principal, Prueba1.prg:
Code (fw): Select all Collapse
#include "\FWH-908\INCLUDE\FiveWin.ch"

Function Inicio()
聽 local cResp:= Space(100)
//local hDll := libLoad( "prudll.dll" )
聽 localhDll := LoadLibrary( "prudll.dll" )
聽 cResp:=HB_LibDo("DllFunc1")
聽 MsgInfo(cResp)
聽 MsgInfo(cVar1)
Return(NIL)


Bat de generaci贸n de la DLL:
Code (fw): Select all Collapse
@echo off

set hdir=c:\xHarbour-20090921
set bcdir=c:\Borland

%hdir%\bin\harbour fwhstub /n /w /es2 /gc0
if errorlevel 1 goto end

bcc32 -M -c -O2 -tWM -D__HARBOUR__ -I%hdir%\include fwhstub.c

if errorlevel 1 goto end
if exist fwhstub.lib del fwhstub.lib
tlib fwhstub +fwhstub, fwhstub
if errorlevel 1 goto end

%bcdir%\bin\bcc32 -M -c -O2 -tWD -D__HARBOUR__ -w-nak -D__EXPORT__ -n%hdir%\lib -I%hdir%\include %hdir%\source\vm\maindllp.c
if errorlevel 1 goto end

if exist %1.dll del %1.dll

%hdir%\bin\harbour %1 /n /vd /gc0 /D__EXPORT__ 聽>> CLIP.LOG

if errorlevel 1 goto end

%bcdir%\bin\bcc32 -M -c -O2 -tWD -D__HARBOUR__ -w-nak -D__EXPORT__ -o%1 -I%hdir%\include %1.c

if errorlevel 1 goto end

@echo c0d32w.obj + > hdll.bc
@echo %1.obj, + >> hdll.bc
@echo %1.DLL, + >> hdll.bc
@echo %1.map, + >> hdll.bc
@echo fwhstub.lib + >> hdll.bc
@echo c:\fwh-908\libX\FiveHX.lib c:\fwh-908\lib\FiveHC.lib + >> hdll.bc
@echo %hdir%\lib\maindllp.obj + >> hdll.bc
rem @echo %hdir%\lib\DllMain.lib + >> hdll.bc
@echo %hdir%\lib\Harbour.lib + >> hdll.bc
@echo %hdir%\lib\rtl.lib + >> hdll.bc
@echo %hdir%\lib\vm.lib + >> hdll.bc
@echo %hdir%\lib\gtgui.lib + >> hdll.bc
@echo %hdir%\lib\lang.lib + >> hdll.bc
@echo %hdir%\lib\macro.lib + >> hdll.bc
@echo %hdir%\lib\rdd.lib + >> hdll.bc
@echo %hdir%\lib\dbfntx.lib + >> hdll.bc
@echo %hdir%\lib\dbfcdx.lib + >> hdll.bc
@echo %hdir%\lib\dbffpt.lib + >> hdll.bc
@echo %hdir%\lib\hbsix.lib + >> hdll.bc
@echo %hdir%\lib\debug.lib + >> hdll.bc
@echo %hdir%\lib\common.lib + >> hdll.bc
@echo %hdir%\lib\pp.lib + >> hdll.bc
@echo %hdir%\lib\PCREPOS.lib + >> hdll.bc
@echo %hdir%\lib\Ace32.lib + >> hdll.bc
@echo %bcdir%\lib\cw32.lib + >> hdll.bc
@echo %bcdir%\lib\import32.lib + >> hdll.bc
@echo %bcdir%\lib\psdk\odbc32.lib, >> hdll.bc

%bcdir%\bin\ilink32 -Gn -aa -Tpd -s @hdll.bc 聽> LINK.LOG
if errorlevel 1 goto end

:end

@echo off
if exist %1.lib del %1.lib
if exist *.tds del *.tds
if exist *.c 聽 del *.c
if exist *.def del *.def
if exist *.map del *.map
if exist %1.obj del %1.obj
if exist *.lst del *.lst
if exist fwhstub.obj del fwhstub.obj
if exist fwhstub.lib del fwhstub.lib

set hdir=
set bcdir=


Bat de compilaci贸n y linkeo del programa principal:
Code (fw): Select all Collapse
##############################################################################
# Template make file for FWH and Borland Make tool 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 #
# Copyright FiveTech 2002 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽#
# Use: bmake.bat <your_make_file> 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽#
##############################################################################

# Win2000 bug ################################################################
# Uncomment next line if you receive any DEL error ###########################
# set DEL=cmd /c del

!if !$d(DEL)
聽 聽DEL = del
!endif

# Make directives ############################################################

.autodepend
.swap
.suffixes: .prg .hrb

# Flags for modules to include: YES | NO (must be UPPERCASE)##################

RES_FILE 聽 聽 聽= NO
LNK_DBFNTX 聽 聽= YES
LNK_DBFCDX 聽 聽= YES
LNK_DEBUG 聽 聽 = NO
LNK_ADVANTAGE = YES
LNK_ODBC 聽 聽 聽= NO
MAP_FILE 聽 聽 聽= NO

# Application directories & filenames ########################################

APP_NAME 聽 聽 聽 聽 = PRUEBA1 # (Your EXE name without extension)
APP_PRG_DIR 聽 聽 聽= .
APP_OBJ_DIR 聽 聽 聽= . 聽# (create the app\obj directory first)
APP_INCLUDE_DIR 聽= .
APP_EXE_DIR 聽 聽 聽= $(APP_PRG_DIR)
APP_RES_DIR 聽 聽 聽= $(APP_PRG_DIR)

APP_EXE 聽= $(APP_EXE_DIR)\$(APP_NAME).EXE
APP_RC 聽 = $(APP_RES_DIR)\$(APP_NAME).rc
APP_RES 聽= $(APP_RES_DIR)\$(APP_NAME).res
APP_MAP 聽= $(APP_RES_DIR)\$(APP_NAME).map

# Paths for dependent files ##################################################

.path.prg = $(APP_PRG_DIR)
.path.hrb = $(APP_OBJ_DIR)
.path.obj = $(APP_OBJ_DIR)

# Application PRG files (your PRG files go here) #############################

APP_PRG_LIST = 聽\
聽 聽PRUEBA1.prg 聽\

# Contruction of the rest dependency lists ###################################

APP_PRGS = $(APP_PRG_LIST)
APP_HRBS = $(APP_PRG_LIST:.prg=.hrb)
APP_OBJS = $(APP_PRG_LIST:.prg=.obj)

# Fivewin directories ########################################################

FIVEWIN_INCLUDE_DIR = c:\fwh-908\include
FIVEWIN_LIB_DIR 聽 聽 = c:\fwh-908\lib

# Fivewin libraries ##########################################################

FIVE_LIB 聽= c:\fwh-908\libX\fiveHX.lib
##FIVE_LIB 聽= $(FIVEWIN_LIB_DIR)\fiveHX.lib
FIVEC_LIB = $(FIVEWIN_LIB_DIR)\fiveHC.lib

# Harbour directories & flags ################################################

HARBOUR_INCLUDE_DIR = c:\Xharbour-20090921\include
HARBOUR_EXE_DIR 聽 聽 = c:\Xharbour-20090921\bin
HARBOUR_LIB_DIR 聽 聽 = c:\Xharbour-20090921\lib
HARBOUR_FLAGS 聽 聽 聽 = -i$(APP_INCLUDE_DIR);$(FIVEWIN_INCLUDE_DIR);$(HARBOUR_INCLUDE_DIR) -n -m -w -P -D__IMPORT__ -D__CONFWH908__ > comp.log
HARBOUR_EXE 聽 聽 聽 聽 = $(HARBOUR_EXE_DIR)\harbour.exe

# Harbour libraries ##########################################################

OPT_GUI 聽 聽= $(HARBOUR_LIB_DIR)\optgui.lib
RTL_LIB 聽 聽= $(HARBOUR_LIB_DIR)\rtl.lib
VM_LIB 聽 聽 = $(HARBOUR_LIB_DIR)\vm.lib

###GTWIN_LIB 聽= $(HARBOUR_LIB_DIR)\gtWin.lib
GTWIN_LIB 聽= $(HARBOUR_LIB_DIR)\gtgui.lib

LANG_LIB 聽 = $(HARBOUR_LIB_DIR)\lang.lib
MACRO_LIB 聽= $(HARBOUR_LIB_DIR)\macro.lib
RDD_LIB 聽 聽= $(HARBOUR_LIB_DIR)\rdd.lib
DBFNTX_LIB = $(HARBOUR_LIB_DIR)\dbfntx.lib
DBFCDX_LIB = $(HARBOUR_LIB_DIR)\dbfcdx.lib
HBCOMM_LIB = $(HARBOUR_LIB_DIR)\hbcomm.lib
DEBUG_LIB 聽= $(HARBOUR_LIB_DIR)\debug.lib
COMMON_LIB = $(HARBOUR_LIB_DIR)\common.lib
PP_LIB 聽 聽 = $(HARBOUR_LIB_DIR)\pp.lib
MISC_LIB 聽 = $(HARBOUR_LIB_DIR)\libmisc.lib
NANF_LIB 聽 = $(HARBOUR_LIB_DIR)\libnf.lib

DBFFPT_LIB = $(HARBOUR_LIB_DIR)\dbffpt.lib
HBSIX_LIB 聽= $(HARBOUR_LIB_DIR)\hbsix.lib
PCREP_LIB 聽= $(HARBOUR_LIB_DIR)\pcrepos.lib

# Advantage libraries ########################################################

RDDADS_LIB = $(HARBOUR_LIB_DIR)\rddads.lib
ACE32_LIB 聽= $(FIVEWIN_LIB_DIR)\ace32.lib

# Borlanc directories & flags ################################################

BORLANDC_INCLUDE_DIR = c:\Borland\include
BORLANDC_EXE_DIR 聽 聽 = c:\Borland\bin
BORLANDC_LIB_DIR 聽 聽 = c:\Borland\lib

BORLANDC_COMP_FLAGS 聽= -c -O2 -D__IMPORT__ -I$(HARBOUR_INCLUDE_DIR);$(BORLANDC_INCLUDE_DIR)

BORLANDC_COMP_EXE 聽 聽= $(BORLANDC_EXE_DIR)\bcc32.exe
BORLANDC_LINK_FLAGS 聽= -Gn -aa -Tpe -s -I$(APP_OBJ_DIR) -D__IMPORT__ > link1.log
BORLANDC_LINK_EXE 聽 聽= $(BORLANDC_EXE_DIR)\ilink32.exe
BORLANDC_RES_EXE 聽 聽 = $(BORLANDC_EXE_DIR)\brc32.exe


!if $(MAP_FILE) != YES
聽 聽BORLANDC_LINK_FLAGS = $(BORLANDC_LINK_FLAGS) -x
!endif

# Borland libraries & files ##################################################

STARTUP_OBJ 聽= $(BORLANDC_LIB_DIR)\c0w32.obj
CW32_LIB 聽 聽 = $(BORLANDC_LIB_DIR)\cw32.lib
IMPORT32_LIB = $(BORLANDC_LIB_DIR)\import32.lib
ODBC32_LIB 聽 = $(BORLANDC_LIB_DIR)\psdk\odbc32.lib

LIB_BORL01 聽 = $(BORLANDC_LIB_DIR)\psdk\rasapi32.lib
LIB_BORL02 聽 = $(BORLANDC_LIB_DIR)\psdk\nddeapi.lib
LIB_BORL03 聽 = $(BORLANDC_LIB_DIR)\psdk\msimg32.lib
LIB_BORL04 聽 = $(BORLANDC_LIB_DIR)\psdk\iphlpapi.lib

# Dependencies ###############################################################

all: $(APP_OBJS) $(APP_HRBS) $(APP_EXE)

!if $(RES_FILE) == YES
all: $(APP_RES)
!endif

# Implicit Rules #############################################################

.prg.hrb:
聽 聽$(HARBOUR_EXE) $(HARBOUR_FLAGS) $** -o$@

.hrb.obj:
聽 聽$(BORLANDC_COMP_EXE) $(BORLANDC_COMP_FLAGS) -o$@ $**

# Explicit Rules #############################################################

!if $(RES_FILE) == YES
$(APP_RES) : $(APP_RC)
聽 聽$(BORLANDC_RES_EXE) -r $**
$(APP_EXE) :: $(APP_RES)
聽 聽@if exist $(APP_EXE) $(DEL) $(APP_EXE) > nul
!endif

$(APP_EXE) :: $(APP_OBJS)
聽 聽$(BORLANDC_LINK_EXE) $(BORLANDC_LINK_FLAGS) @&&|
聽 聽$(STARTUP_OBJ) +
聽 聽$(**), +
聽 聽$(APP_EXE), +
聽 聽$(APP_MAP), +
聽 聽$(FIVE_LIB) +
聽 聽$(FIVEC_LIB) +
聽 聽$(RTL_LIB) +
聽 聽$(VM_LIB) +
聽 聽$(GTWIN_LIB) +
聽 聽$(LANG_LIB) +
聽 聽$(MACRO_LIB) +
聽 聽$(RDD_LIB) +
聽 聽$(HBCOMM_LIB) +
聽 聽$(MISC_LIB) +
聽 聽$(NANF_LIB) +
!if $(LNK_DBFNTX) == YES
聽 聽$(DBFNTX_LIB) +
!endif
!if $(LNK_DBFCDX) == YES
聽 聽$(DBFCDX_LIB) +
!endif
聽 聽$(DBFFPT_LIB) +
聽 聽$(HBSIX_LIB) +
!if $(LNK_DEBUG) == YES
聽 聽$(DEBUG_LIB) +
!endif
聽 聽$(COMMON_LIB) +
聽 聽$(PP_LIB) +
聽 聽$(PCREP_LIB) +
!if $(LNK_ADVANTAGE) == YES
聽 聽$(RDDADS_LIB) +
聽 聽$(ACE32_LIB) +
!endif
!if $(LNK_ODBC) == YES
聽 聽$(ODBC32_LIB) +
!endif
聽 聽$(CW32_LIB) +
聽 聽$(IMPORT32_LIB) +
聽 聽$(LIB_BORL01) 聽+
聽 聽$(LIB_BORL02) 聽+
聽 聽$(LIB_BORL03) 聽+
聽 聽$(LIB_BORL04), 聽+
!if $(RES_FILE) == YES
聽 聽,$(APP_RES) +
!endif
|
聽 聽@$(DEL) $(APP_EXE_DIR)\*.tds
聽 聽@$(DEL) $(APP_EXE_DIR)\*.hrb
聽 聽@$(DEL) $(APP_EXE_DIR)\*.obj
聽 聽@$(DEL) $(APP_EXE_DIR)\*.ppo

Es problable que nos falte alg煤n par谩metro o flag nuevo en alg煤n lado, pero ya agotamos todas las opciones y quedamos parados. Si no resolvemos esto, ni modo de poder actualizarnos. Estoy seguro que debe haber alguna soluci贸n que el Maestro Antonio con su sabidur铆a nos puede ayudar a encontrar. Ufff me sali贸 en prosa :-)

Maestro Antonio, ayuda please :-)

Saludos,

Carlos Gallego

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: PCODE DLL
Posted: Wed Sep 23, 2009 05:24 PM

Maestro Antonio,

Una ayudita please. Qued茅 frenado. Me qued茅 en FWH 8.07 :cry: No he podido actualizar mis aplicaciones a FWH 908, y espero que en pocos d铆as a 9.09, por estas benditas PCODE DLL.

Puse la consulta en el foro de xHarbour, pero con la respuesta qued茅 m谩s confundido.

Me da la impresi贸n de que ahora las PCODE DLL no pueden contener la VM de xHarbour. Van a trabajar contra la VM contenida en el executable que invoca a la DLL. Lo que en principio no permitir谩 que la DLL sea utilizada por aplicaciones hechas en otras herramientas. Si se quiere esto, se deben crear v铆a OleServer. Es decir, cre谩ndolas como Objetos OLE.

Es esto correcto, entend铆 bien, o me enred茅 solo y ya estoy hecho una bestia? :?

Gracias como siempre por tu valios铆sima ayuda.

Carlos Gallego

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 514
Joined: Sun Oct 16, 2005 03:32 AM
Re: Maestro Antonio ayuda con PCODE DLL
Posted: Wed Sep 23, 2009 09:42 PM

Antonio, Maestro, disculpa que sea intenso.

Hice la consulta en el foro de xHarbour pero definitivamente la respuesta de Ron no me soluciona el problema.

La conclusi贸n que saco de su repuesta, es que ahora, para usar PCODE DLL, no se debe incluirse la VM de xHarbour ni en el executable ni en la PCODE DLL, y en cambio s铆 debe inclu铆rse Harbour.Dll. Es esto correcto ?

Insiste Ron en que no debe linkearse maindllp.obj en la DLL.

Lo extra帽o es que si no incluyo maindllp.obj no carga nada de la DLL y genera error al invocar alguna rutina inclu铆da en la misma.

Por otro lado, si s贸lo agrego Harbour.lib al momento de Linkear la DLL todo funciona perfecto, aunque contradice lo que indica Ron, a m谩s que de un tama帽o de 813,056 bytes la DLL se reduce a 58,368 (ya no va inclu铆da la VM)

Si hago las cosas tal como dice Ron, no me funciona, salvo que me falte alguna intrucci贸n en los flags al momento de compilar y linkear tanto el executable como la DLL.

No he podido probar quitando la VM del executable pues al momento de linkear el executable me genera el siguiente error:

<< Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland<< rror: Unresolved external '_hb_oleVariantToItem' >>
<< Referenced from C:\FWH-908\LIB\FIVEHC.LIB|ACTX >>

Quedamos varados. Estamos condenados a quedarnos en FWH 807 y xHarbour 1.1.0 ? :( No puedo creerlo.

Por favor ayudaaaaaaaa, queremos avanzar.

Gracias y saludos,

Carlos Gallego

Saludos,



Carlos Gallego



*** FWH-25.12, xHarbour 1.3.1 Build 20241008, Borland C++7.70, PellesC, ADS 11.1***

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Maestro Antonio: Ayuda con PCODE DLL
Posted: Wed Sep 23, 2009 10:57 PM
Carlos,

No hemos probado recientemente la construcci贸n de DLLs con xHarbour, asi que hasta que no lo revisemos, de poca ayuda podermos serte.

En cuanto a _hb_oleVariantToItem puedes declarar una funci贸n dummy, suficiente para enlazar, y asi ver si te te funciona:
Code (fw): Select all Collapse
int hb_oleVariantToItem( void *, void * )
{
   return 0;
}
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion