Форум

pll, dll - что сейчас?

dar: Можно ли облегчить ехе, сбросив повторяющийся код в библиотеку - помните, как в старом добром клиппере pll-файл? Тогда ведь и паковать ехе не надо. И с передачей данных клиенту проще.

Ответов - 16

gfilatov: dar пишет: Можно ли облегчить ехе, сбросив повторяющийся код в библиотеку Да, это возможно, если использовать harbour.dll. SET ENGLISH ON Programs created with Clipper or Harbour are traditionally a monolithic EXE containing all executable code. This includes the Virtual Machine (VM) and the RunTime Library (RTL) as well as your own code. Running under Windows (Win32) with Harbour, you can now also create and use Windows DLLs that contain PRG code. Harbour supports Win32 DLLs in 3 ways. 1) Self-contained DLLs containing functions from any platform. (These are not what we call a "Harbour.dll", although they may be named that. The DLL entry points are different.) These have the VM/RTL inside them and can be used by any other Windows program. You can create a .lib for static linking, or use GetProcAddress as in any standard Win32 DLL. Calling Harbour/Prg functions directly is limited to those that take no parameters unless you include C functions in the DLL that take parameters and then call the PRG-level code. To do static linking, do this to create the .lib: implib harbour.lib harbour.dll For the Borland C platform, use that library and import32.lib and cw32.lib from Borland, and you are ready to go. See contrib\delphi\hbdll for an example of a Delphi program that can use all of Harbour's functionality by accessing a self-contained DLL. BLD_SDLL.BAT is used there to create the DLL. 2) PCode EXEs using a Harbour.dll A Harbour.dll is designed to be called from a Harbour app. A pcode EXE is a small Harbour executable that does not contain the VM/RTL. To execute its functions, it must load and access a Harbour.dll. If you want dynamic linking, then use this to execute a Harbour dynamically loaded pcode DLL function or procedure: HB_DllDo( <cFuncName> [,<params...>] ) --> [<uResult>] This lets you have all your common code in a DLL, and have lots of small EXEs that use it. Realize however that, even though this may be a nice way to manage your code, each EXE may load its own image of the Harbour.dll into memory at runtime. In terms of Windows memory, there may not be a benefit to using pcode EXEs over monolithic EXEs. But it may be a worthwhile maintenance benefit to have lots of replaceable small exes. 3) PCode DLLs used from traditional EXEs A pcode DLL does not contain the VM/RTL. It is a library of Harbour-compiled PRG code that uses the VM/RTL of the EXE that calls it. This has the benefit of having replaceable modules in DLLs that don't necessarily require updating your EXE. The following is clipped from a msg by Antonio Linares to the Harbour developer list explaining some of the details: Please notice that there are three different Windows DLL entry points: + source/vm/ * maindll.c Windows self-contained DLL entry point * maindllh.c Windows Harbour DLL entry point (harbour.dll) * maindllp.c Windows pcode DLL entry point and VM/RTL routing functions > * maindll.c Windows self-contained DLL entry point To produce Harbour code, as DLLs, that may be used from other programming languages applications (as VB, Delphi, C++, etc...) > * maindllh.c Windows Harbour DLL entry point (harbour.dll) To produce Harbour.dll, to be just used from small pcode Harbour EXEs > * maindllp.c Windows pcode DLL entry point and VM/RTL routing To produce small pcode DLLs, to be used just from Harbour EXE apps. maindllp.c is the entry point for the Harbour pcode DLLs. pcode DLLs are quite small DLLs, that just contain pcode and/or C (using extend api) functions. mainwin.c is the entry point for Windows EXEs, not for DLLs. You may use maindll.c, maindllh.c or maindllp.c based on your needs. SET ENGLISH OFF

dar: А можно ли коротко и по-русски? PS. Конечно англ надо учить, но ведь есть и другие языки - всех не успеешь выучить

gfilatov: Коротко так: Харбор поддерживает 3 типа DLL: 1) стандартные Win DLL, доступ к которым возможен из ЛЮБОЙ Win32-программы 2) PCode EXEшники, использующие при своей работе Harbour.dll 3) PCode DLL, использующиеся из Харбор-программы (аналог старых PLL)


Владимир: gfilatov А на Харборе написать свою DLL возможно?

gfilatov: Владимир пишет: А на Харборе написать свою DLL возможно? Да, возможно. Но только надо разбираться с ключами компиляции, иначе DLL не будет правильно работать

Владимир: gfilatov А где можно посмотреть примерчик работы с DLL написанной на Harbour'е?

Pasha: Чтобы собрать свою dll, надо: 1. Скомпилировать свои сырцы для dll, добавив флаги -D__EXPORT__ для компиляторов harbour и bcc, получив один или несколько obj-файлов 2. Собрать dll с помощью линкера ilink32, использовав следующий скрипт: mydll.lnk: f1.obj f2.obj ... fn.obj c0d32w.obj, mydll.dll, , cw32.lib lib\harbour.lib import32.lib uuid.lib ILINK32 -aa -Tpd -Gn @mydll.lnk если эти obj использут еще какие-либо библиотеки, добавить их в этот скрипт 3. С помощью утилиты implib из mydll.dll сделать mydll.lib: implib mydll.lib mydll.dll 4. Получившуюся mydll.lib указывать в списке библиотек при сборке своей программы вместе с harbour.lib и наслаждаться :) не забыв при запуске программы подсунуть ей harbour.dll и mydll.dll

Владимир: Раньше использовал Blinker'овские Dll, поэтому решил сделать Dll из xHarbour'а(см. сообщение выше) Но в момент линковки выкидывается сообщение Error: Unresolved external на функции, которые сидят в Exe-модуле. Как эту бяку обойти?

Pasha: При сборке длл должны быть реализованы все ссылки Т.е она должна быть самодостаточной, и зависить разве что от других длл

Владимир: Понятно

Andrey: Pasha пишет: Чтобы собрать свою dll, надо: ........................ Паша, а как тоже самое сделать с помощью hbmake ? И что нужно вставлять в MAIN() чтоб программа понимала, что нужно подгружать harbour.dll и mydll.dll

Pasha: Я ответил в другой ветке А сырцы программы, использующей или не использующей haebour.dll, не отличаются ничем Отличается только сборка

SadStar3: 2) PCode EXEшники, использующие при своей работе Harbour.dll 3) PCode DLL, использующиеся из Харбор-программы (аналог старых PLL) Ведь Харбор перегоняет все в Си-текст и потом компилирует и линкует. Где здесь место PCode-у?

SadStar3: 2) PCode EXEшники, использующие при своей работе Harbour.dll 3) PCode DLL, использующиеся из Харбор-программы (аналог старых PLL) Ведь Харбор перегоняет все в Си-текст и потом компилирует и линкует. Где здесь место PCode-у?

Петр: SadStar3 пишет: Ведь Харбор перегоняет все в Си-текст и потом компилирует и линкует. Где здесь место PCode-у? Харбор код function Main() dispbox( 1, 1, 5, 5, B_SINGLE + 'X', 'color not supported') С код HB_FUNC( MAIN ) { static const BYTE pcode[] = здесь это место { /* 00000 */ HB_P_BASELINE, 10, 0, /* 10 */ HB_P_PUSHSYMNEAR, 1, /* DISPBOX */ HB_P_PUSHNIL, HB_P_ONE, HB_P_ONE, HB_P_PUSHBYTE, 5, /* 5 */ HB_P_PUSHBYTE, 5, /* 5 */ HB_P_PUSHSTRSHORT, 10, /* 10 */ 218, 196, 191, 179, 217, 196, 192, 179, 'X', 0, HB_P_PUSHSTRSHORT, 20, /* 20 */ 'c', 'o', 'l', 'o', 'r', ' ', 'n', 'o', 't', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd', 0, HB_P_DOSHORT, 6, /* 00048 */ HB_P_LINEOFFSET, 4, /* 14 */ HB_P_PUSHNIL, HB_P_RETVALUE, HB_P_ENDPROC /* 00053 */ }; hb_vmExecute( pcode, symbols, NULL ); а здесь виртуальная машина Харбор выполняет pcode }

Pasha: Как это без пи-кода ? Любая прг-функция транслируется в с-функцию, содержащую пи-код в качестве данных и одного вызова hb_vmExecute с передачей пи-кода как параметра И это и в exe и dll Правда есть режим трансляции в непосредственный с-код - опция -go3



полная версия страницы