View this article only
网上论坛:borland.public.cppbuilder.vcl.components.using
日期:2003-09-11 09:01:39 PST
Can MIDAS.DLL be statically linked in CPB 6 like it can in Delphi 6? If so,
how is it done?
The following is from the Delphi 6 release notes:
Static linking DataSnap clients
------------------------------
It is now possible to eliminate the need to deploy the
TClientDataSet runtime module (MIDAS.DLL). This can be done
for DataSnap clients and other applications requiring this
module by including MidasLib in the uses statement of any
unit in the project. DataSnap servers still require
MIDAS.DLL.
线索内的第 2 条留言
寄件者:Dennis Cote (maps_me@hotmail.com)
主旨:Re: Static linking to MIDAS.DLL
View this article only
网上论坛:borland.public.cppbuilder.vcl.components.using
日期:2003-09-11 11:40:04 PST
It can be done! The explanation of how is a little round about so I have
posted it here in the hope it may help someone else in the future.
The online documentation says the following under "Deploying database
applications";
Database applications that use client datasets such as TClientDataSet or
dataset providers require you to include midaslib.dcu and crtl.dcu (for
static linking when providing a stand-alone executable); if you are
packaging your application (with the executable and any needed DLLs), you
need to include Midas.dll.
It also says the following under "Deploying dbExpress database
applications";
You can deploy dbExpress applications either as a stand-alone executable
file or as an executable file that includes associated dbExpress driver
DLLs.
To deploy dbExpress applications as stand-alone executable files, the
dbExpress object files must be statically linked into your executable. You
do this by including the following DCUs, located in the lib directory:
Database unit When to include
dbExpINT Applications connecting to InterBase databases
dbExpORA Applications connecting to Oracle databases
dbExpDB2 Applications connecting to DB2 databases
dbExpMYS Applications connecting to MySQL 3.22.x databases
dbExpMYSQL Applications connecting to MySQL 3.23.x databases
crtl Required by all executables that use dbExpress
MidasLib Required by dbExpress executables that use client datasets such as
TClientDataSet
Note: For database applications using Informix, you cannot deploy a
stand-alone executable. Instead, deploy an executable file with the driver
DLL dbexpinf.dll (listed in the table following).
Both of these descriptions are promising and also misleading. They both talk
about MidasLib (the library used with Delphi 6 is MidasLib.DCU). Also,
neither of these sections (or anywhere elese I could find in the online
help) explained exactly how to do this static linking.
I found more useful information in the CPB6 readme.txt file. It has a
section that talks static linking to dbExpress drivers which I have copied
below.
How to statically link dbExpress drivers
------------------------------
Static linking of dbExpress drivers (dbxdsnint.lib for
InterBase, dbxdsnora.lib for Oracle, dbxdsndb2.lib for DB2,
or dbxdsnmys.lib for MySQL 3.23.x) in C++Builder is a two-
step process: Link the driver, then register both the driver
and the DataSnap library. You can enter this code in your
TForm constructor.
The .lib files are located in your \cbuilder6\lib directory.
Important:
Do not link more than one dbExpress driver into a project.
Linking more than one driver will cause linking errors and
may require a corrective shutdown of C++Builder.
The following example uses the InterBase driver.
Step 1. Include the dbExpress/DataSnap header file:
#include <dbxdsnint.h>
Step 2. Register the static library:
RegisterDbXpressLib(::getSQLDriverINTERBASE);
RegisterMidasLib(::DllGetClassObject);
Note:
DataSnap (a part of what was formerly known as MIDAS) is
linked in to each dbExpress driver for C++Builder 6. Thus,
if you need to statically link DataSnap only for access to
midaslib, simply link in any of the drivers listed above.
The useful information (at least from my point of view) is in the note at
the bottom. It says I can link to any of the drivers and it will also link
MidasLib. So I followed the instructions given only to get a couple of
compile errors. It seems there a couple of errors in the instructions given
in the readme.
First, the RegisterDbXpressLib function is declared in the sqlexpr.hpp
header so it must be included as well. The dbxdsnint.h header file given in
the instructions is for Interbase only, if you are using MySQl you would
use dbxdsnmys.h instead.
Second, the function name passed to RegisterMidasLib is declared in the
dbxdsnint.h header as DllGetDataSnapClassObject not DllGetClassObject as
shown in the readme.
The correct code to include in the main form constructor is therefore;
#include <sqlexpr.hpp> //for RegisterDbXpressLib()
#include <dbxdsnint.h> //or <dbxdsnmys.h> for MySQL
RegisterDbXpressLib(::getSQLDriverINTERBASE);
// or RegisterDbXpressLib(::getSQLDriverMYSQL); for MySQL
RegisterMidasLib(::DllGetDataSnapClassObject);
With this code in place my application is fianlly statically linked to
MidasLib and does not require the deployment of Midas.dll.
"Dennis Cote" <maps_me@hotmail.com> wrote in message
news:3f609bd8@newsgroups.borland.com...
> Can MIDAS.DLL be statically linked in CPB 6 like it can in Delphi 6? If so,
> how is it done?
>
> The following is from the Delphi 6 release notes:
>
> Static linking DataSnap clients
> ------------------------------
>
> It is now possible to eliminate the need to deploy the
> TClientDataSet runtime module (MIDAS.DLL). This can be done
> for DataSnap clients and other applications requiring this
> module by including MidasLib in the uses statement of any
> unit in the project. DataSnap servers still require
> MIDAS.DLL.
线索内的第 3 条留言
寄件者:Uber Notem (uber@notem.com)
主旨:Re: Static linking to MIDAS.DLL
View this article only
网上论坛:borland.public.cppbuilder.vcl.components.using
日期:2003-09-15 22:53:37 PST
Hello,
I tried the following...
#include <vcl.h>
#include <sqlexpr.hpp> //for RegisterDbXpressLib()
#include <dbxdsnmys.h> //or <dbxdsnint.h> for MySQL
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
RegisterDbXpressLib(::getSQLDriverMYSQL);
RegisterMidasLib(::DllGetDataSnapClassObject);
}
//---------------------------------------------------------------------------
but I keep getting [Linker Error] Unresolved external '__fastcall
Sqlexpr::RegisterDbXpressLib(void *)' referenced from C:\PROGRAM
FILES\BORLAND\CBUILDER6\PROJECTS\UNIT1.OBJ
I've added dbxdsnmys.lib to the project. I'm using C++ Builder 6.0
Pro. Dynamic RTL and runtime packages are turned off.
What am I missing?
Thanks.
On Thu, 11 Sep 2003 12:38:13 -0600, "Dennis Cote"
©2004 Google
http://wangzw.wordpress.com/
个性化台历、日历制作
http://shop33697570.taobao.com/
