==========C++Builder使用Delphi文件时的连接问题!=========

RomanticProgrammer 2004-10-14 02:16:25
如果我在我的C++Builder的工程中加入一个Pas文件:A.pas
而这个A.Pas文件中使用的函数是从另外一个pas文件B.pas中用下面的方式从Dll中引入的
function ReadBusyCount :Integer; stdcall; far external 'TFCore.dll';
所以我把A.pas 和B.pas都加入到我的工程中了。
编译可以通过,但链接提示找不到我在B.pas文件中从Dll中引入的函数。(注:TFCore.dll存在)
请问如何解决!

///////////////////////////////////////////////////////////////////////////////////
...全文
245 36 打赏 收藏 转发到动态 举报
写回复
用AI写文章
36 条回复
切换为时间正序
请发表友善的回复…
发表回复
taozc 2004-11-11
  • 打赏
  • 举报
回复
----------------------------------------------
...另外一个pas文件B.pas中用下面的方式从Dll中引入的
function ReadBusyCount :Integer; stdcall; far external 'TFCore.dll';
----------------------------------------------
这种方式是静态加载DLL文件,Delphi会自动处理,C++Builder在链接时就需要LIB文件了。
用implib生成DLL文件的Lib文件,加入到工程即可。
drawwingmap 2004-11-04
  • 打赏
  • 举报
回复
在CBUILDER 中绝对要 IMP一个LIB的,
还有从PASCAL到C++ 要注意 STDCALL 和 PASCAL CALL FASTCALL
BenLeak 2004-10-29
  • 打赏
  • 举报
回复
学习
zjqyb 2004-10-21
  • 打赏
  • 举报
回复
imp TFCore.lib TFCore.dll

cb6 Project 加入TFCore.lib 绝对可以
magicsnake 2004-10-21
  • 打赏
  • 举报
回复
收藏
RomanticProgrammer 2004-10-21
  • 打赏
  • 举报
回复
这些天太忙了,顾不上来!

RomanticProgrammer 2004-10-15
  • 打赏
  • 举报
回复
up
Lewolf 2004-10-15
  • 打赏
  • 举报
回复
想起来了,我最早建的dll是C的,后来保存为cpp文件了,就出现了导出的函数有了差别。

不过以前到是没有注意到extern "C"在C原文件和C++原文件中还有这个差别。

在C文件中导出的话,不需要extern "C"
myy 2004-10-15
  • 打赏
  • 举报
回复
extern "C" 这个预编译标识符强行申明C的函数不做C++方式的名字转换
Lewolf 2004-10-15
  • 打赏
  • 举报
回复
这个MessageBoxD是导出了了的啊,不过确实是少了一个 extern "C",这样导出的函数和pascal中的调用规则不一样了,呵呵

呵呵呵呵!
myy 2004-10-15
  • 打赏
  • 举报
回复
extern "C" __declspec( dllexport ) int __stdcall MessageBoxD...

//通过函数名称调用,extern "C"是必须的
myy 2004-10-15
  • 打赏
  • 举报
回复
extern "C" __declspec( dllexport ) __stdcall int MessageBoxD...
Lewolf 2004-10-15
  • 打赏
  • 举报
回复
你弄好了,我倒了,同样的导入方法,系统的dll可以,自己编的就不行!!

代码如下:

作一个dll,名字为dll.dll,源码在DllMain.cpp中:
#include <windows.h>
#pragma argsused

int __stdcall __declspec( dllexport )MessageBoxD(LPCTSTR lpText,LPCTSTR lpCaption,UINT uType)
{
return MessageBox(0,lpText,lpCaption,uType);
}

int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}

编译这个dll,使用其中的MessageBoxD没有问题的。

创建一个工程,其中加入一个自己写的Pas文件TestUnit.pas,这个文件中有两个导入的dll函数,一个是User32.dll的MessageBox,一个dll.dll中的MessageBoxD,并且其中有一个Test1函数分别调用这两个导入的函数,
代码如下:

unit TestUnit;
interface

function MessageBox(HWnd: Integer; Text, Caption: PChar; Flags: Integer): Integer;
stdcall; external 'user32.dll' name 'MessageBoxA';

function MessageBoxD(Text, Caption: PChar; Flags: Integer): Integer;
stdcall; external 'dll.dll' name 'MessageBoxD';

function Test1 : Integer; stdcall;

implementation

function Test1 : Integer;
begin
MessageBox(0,'','',0);
MessageBoxD('','',0);
Result := 0;
end;

end.

编译时会报告MessageBoxD连接出错,

我倒!加入Lib也是不可以的了。
Friecin 2004-10-15
  • 打赏
  • 举报
回复
飘过
myy 2004-10-15
  • 打赏
  • 举报
回复
第2个问题倒是不知道的,应该注意。
Friecin 2004-10-15
  • 打赏
  • 举报
回复
俺没这么干过,友情UP
myy 2004-10-15
  • 打赏
  • 举报
回复
>>VC7编译生成的Lib文件BCB不能用

这是个old问题了,就是 omf 和 coff 两种lib格式不同。
RomanticProgrammer 2004-10-15
  • 打赏
  • 举报
回复
再次感谢myy,李狼等朋友的倾心帮助!
RomanticProgrammer 2004-10-15
  • 打赏
  • 举报
回复
其次有下面两点发现
1:
我用VC7编译生成的Lib文件BCB不能用,必须要用Borland的implib工具从dll里从新生成lib;
2:
如果在delphi的external来导出dll的函数后,可以修改dll的名字.只要external关键字后面的名字和其相同即可.但这个文件一旦要被BCB编译,必须把dll改回原来编译时生成的名字.因为这个名字会在lib文件中做标识.程序无法装载dll.
myy 2004-10-15
  • 打赏
  • 举报
回复
倒,说了半天,不如自己试下先。
加载更多回复(16)
SQLMemTable for Delphi / C++ Builder: README============================================Please read this file carefully (especially the INSTALLATION chapter) before installing the program to your computer.Contents-------- Program information Company information Description Specification Features and Benefits Installation Purchasing / Registration Copyright and licenses Warranty and guarantee Technical support Important note Other products recommended to useProgram information-------------------Program Name: SQLMemTableLicense Types: Personal (for personal use, without source code) Com (for 1 developer, without source code) Pro (for 1 developer, with source code) Team4 (for 4 developers, with source code) Team8 (for 8 developers, with source code) Enterprise (Enterprise License - for entire company, with source code)Program Version: 1.00Program Release Date: 07/15/2003Program Purpose: SQLMemTable is a compact, fast and powerful in-memory table with SQL support. Target Environment: Delphi 4, 5, 6, 7 and C++ Builder 4, 5, 6.Company information-------------------Company Name: AidAim SoftwareContact E-mail Address: support@aidaim.comContact WWW URL: http://www.aidaim.comDescription-----------SQLMemTable is a compact in-memory table with SQL support for Delphi and C++ Builder. SQLMemTable does not require BDE and provides all the TTable‘s functionssuch as Master/Detail relationship, Filtering, Searching, Sorting, Key, Range, BLOB fields, and has some advanced features such as BLOB data compression, multi-indexes and table restructuring, shareable in memory capabilities. It is fully compatible with all standard DB controls, supports calculated and lookup fields as well as internationalization/localization and Unicode, provides data importing from and exporting to any dataset, includes SQLConsole utility with source code, comprehensive help and demos.SQLMemTable provides the following services: - SQL support - Master / detail relationship - Creating, renaming, emptying, deleting and restructuring tables - Creating, editing, deleting, navigating and searching for records - Creating and deleting multiple indexes - Calculated and lookup fields - Filtering support - Using BLOB fields with data compression ability - Importing from and exporting to any dataset in fast and easy way - Internationalization/Localization and Unicode supportSQLMemTable does not require BDE or any external drivers and has small footprint. Its search performance is excellent and data access speed is extremely fast.Specification-------------Data types: ftAutoInc, ftInteger, ftSmallInt, ftFloat, ftDateTime, ftDate, ftTime, ftBLOB, ftMemo, ftGraphic, ftString (any fixed length string), ftCurrency, ftWord, ftBoolean, ftLargeInt, ftFmtMemo, ftBytes, ftWideString.Advanced data types: aftExtended, aftWideMemoMaximum records quantity: up to 2^31 (over 2 billions). Maximum fields per table: 2^31 (over 2 billions). Maximum indexes per table: 2^31 (over 2 billions). Maximum index fields per index: 2^31 (over 2 billions). Maximum field name‘s length: 255 characters.Maximum index name‘s length: 255 characters.BLOB fields block size: > 1 byte, default 100 Kb. BLOB compression: ZLib, BZip, PPM Search operators: <,>,=,<>,<=,>=, like, not like, is null, is not null, and, or, not, (). Features and Benefits---------------------Compactness. - Short compiled code with approximate size 300 Kb, no external drivers (such as BDE) required. - Small memory consumption by SQLMemTable database engine. - Fast BLOB data compression. Your large data fields will need less memory. SQLMemTable can compress data on the fly. The compression routines used in the SQLMemTable are much faster than most of popular archivers like PKZip, WinRar, Arj. High performance. - Fast search by B-tree indexes. At the moment SQLMemTable is one of the fastest existing in-memory tables for Delphi and C++ Builder. - High-speed memory operations performance is achieved by means of using specially optimized memory manager and tuned algorithms. - Quick operations with strings. SQLMemTable compares strings up to 3 times faster than standard Delphi string routines. High performance is achieved by using a special library written in Assembler and an advanced sorting algorithm. - Advanced SQL optimizer often makes query execution several times faster by choosing the best execution plans. Functionality. - A subset of SQL‘92 including DDL operators is supported by TSQLMemQuery component. With SQLMemTable you can create SQL scripts for creating tables, inserting, editing and deleting records, retrieving data by SELECT command. - Advanced search engine. SQLMemTable supports ‘LIKE‘ operator with wildcards ‘%‘ and ‘_‘, as well as ‘IS NULL‘ and ‘IS NOT NULL‘ in filters and queries. - Full multiple index support, i.e. numerous fields in a table may comprise an index. SQLMemTable provides descending and ascending indexes, case-sensitive and insensitive indexes for string fields. - Shareable in-memory tables. SQLMemTable supports simultaneous access to a table by multiple TSQLMemTable components within a single application. - Default values support. - Record-level constraints, i.e. constraints that must be met when editing the data. Compatibility. - SQLMemTable supports most of TTable field data types, including BLOB fields, moreover it allows to create string and wide string fields of any fixed length. - SQLMemTable is fully compatible with standard DB-aware visual controls such as QuickReport, DBGrid, DBNavigator, DBImage, DBMemo, DBRichEdit, as well as with third party vendor‘s products supporting TDataset descendant components - FastReport, DBFlyTreeView and others. - Calculated and lookup fields can be used in the same way as TTable. - Most of TTable functions are supported including Key and Range methods. Convenience. - Table restructuring is being performed in the easiest way keeping all the existing data. - Data importing from and exporting to any dataset is supported. SQLMemTable provides you with the simplest way to import and export tables using ImportTable and ExportTable methods. - Internationalization / localization support. All text search and sorting functions use current system locale, so localizing your program with SQLMemTable is a very simple task. - Unicode support. All the text operations work with multi-byte encoding using ftWideString. - Comprehensive help. SQLMemTable comes with full documentation presented in SQLMemTable Developer‘s Guide and SQLMemTable Reference. Installation------------1) Make sure that all copies of Delphi (or C++ Builder) are currently closed and not running on the target system. Also, if you are replacing an existing version of SQLMemTable, please remove all files and the package of the prior version before running the new setup program.2) Unpack zip archive containing SQLMemTable into any directory. 3) Run the INSTALL.EXE from this directory.4) Follow on-screen instructions of step-by-step setup wizard to install SQLMemTable.5) If after the installation SQLMemTable components don‘t appear in Components Palette of the IDE, please follow the next instructions: * From the IDE, select ‘Component | Install Packages...‘. * Click the ‘Add‘ button. * In the ..SQLMemTableLibDelphi# (or ..SQLMemTableLibC++ Builder#) directory, select the dclSQLMemTableD#.BPL (or dclSQLMemTableB#.BPL) file. * Click the ‘OK‘ button to close the dialog. * Finally, select ‘Tools | Environment Options‘ from the main menu. From this dialog, select the ‘Library‘ tab and insure that the ..SQLMemTableLibDelphi# (or ..SQLMemTableLibC++ Builder#) directory is included in the ‘Library Path‘ line.Purchasing / Registration-------------------------Visit our site http://www.aidaim.com to purchase or register the product.Copyright and license---------------------See "license.txt" file.Warranty and guarantee----------------------See "license.txt" file.Technical support-----------------Before you contact us, please do the following: - Make sure you have performed all the required steps correctly. - Look at the Help files and Demos: it may already contain an answer to your question. A lot of people ask us something like "how do I:", though the complete information is there. - Visit our Internet site at http://www.aidaim.com. It‘s a good chance that you‘ll find the newer version of our product there.If the problem persists, please, inform us about the following: - SQLMemTable version. - Where did you obtain SQLMemTable (http or ftp site). - Compiler information: Delphi or C++ Builder, Version, Edition, Service Pack - Environmental information: your OS and Service Pack - Description of your problem (as much information as possible to retrieve the problem). - Attach a test project where the problem could be reproduced (it helps us to solve your issue as soon as possible)Typically AidAim Software Support Team answer messages in 24 hours, but depending on singularity and difficulty of your question it may take a bit longer.Should you have any ideas on improving the existing functions of this product after you have downloaded and used it, be easy to e-mail us. All registered users who buy this product may also send their offers to add new possibilities and/or to change the product‘s functions.We consider any ideas and we may take them into account while creating new versions of our products.Other products AidAim Software recommended-------------------------------------------All the products in this chapter are fully compatible with SQLMemTable and recommended to work with our product. AidAim Software had tested all these products released by our partner companies for complete compatibility with SQLMemTable. In its turn, all the partner companies have carried out similar testing of the compatibilityof SQLMemTable with their own products. All the companies whose products present here are technology partners of AidAim Software. It means that both partner companies guarantee the correct joint work of the products. In case of encountering bugs in the time of joint work and owing to it, the partners incur the obligation to resolve such problems for their clients for FREE. FastReport Software -------------------Advanced report generators for Delphi and Kylix.Web Site: http://www.fast-report.comFastReport VCL--------------FastReport VCL is reporting tool component for Borland Delphi 2-6 and Borland C++Builder 3-5. It consists of report engine, designer and preview. Some FastReport possibilities are really unique. The generator allows you to create tables, queries and databases in run-time. Built-in dialog designer allows you creation of dialog forms (they can be used for asking some parameters before printing a report). You also able to use built-in Pascal-like interpreter to do rather complex data processing. In spite of power of FastReport, its code is quite small. Probably FastReport is leader in correlation of functionality/size. The FastReport kernel (without designer) adds to your program the small footprint (less than QR3), but its functionality is like in ReportBuilder‘s one.FastReport CLX edition----------------------FastReport CLX edition is powerfull of FastReport for Borland Delphi 6 and Borland Kylix 1-2 for Linux. It use new CLX-library. Do you want to create reports for Linux as well as for Windows? Use FastReport CLX edition!FastReport VCL 2.3 lite-----------------------FreeWare version of FastReport. Imca Systems DevTeam --------------------Imca Systems DevTeam - Flexible and powerful Delphi/C++ Builder/ActiveX trees, grids and editors.Web Site: http://www.9rays.netDBFlyTreeView Suite-------------------Add grid and treeview functionality with a single component. DBFlyTreeView is a fully customizable, data-bound grid and tree view component that allows you to add huge arrays of nodes. OLE drag-and-drop is supported and the component is customizable at both design-time and runtime. DBFlyTreeView supports custom colors, fonts, and alignment for each cell, and you can even create scrollable background wallpapers without creating huge bitmaps.Included: RapidTree, FlyTreeView, PropertiesTree, DBFlyTreeView controls.DBFlyTreeViewPro Suite----------------------Enable your Delphi and C++Builder applications to display and browse hierarchical, table, and list data. DBFlyTreeViewPro Suite is a set of VCL components that are a direct descendent from FlyTreeViewPro. It supports more than 40 types of in place editors plus your custom format. It is data-aware and allows you to draw any array of cells directly to a printer, Metafile, or Bitmap canvas.Included: RapidTree, IsPlugeditor, FlyTreeViewPro, PropertiesTreePro, DBFlyTreeViewPro controls.

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧