开发者

Is it possible to get a delphi project to create a lib file as the output of the project?

I want it to create dll and LIB. because this dll is statically linke开发者_Go百科d to another CPP dll. so I must have the lib file.

i'm using the IDE of delphi 4


Using in C++ DLLs created in Delphi (as vice-versa) is pretty easy, but you need to follow simple rules. I assume you are trying to use Delphi DLL in C++ project:

  1. You must use the same calling convention. By default, Delphi uses register convention (__fastcall in C++ terminology). Default calling convention for all Windows DLLs is __stdcall, so first modify the function declaration in your Delphi source file as follows:

    function DoSomething(x, y: Integer): Integer; stdcall;

  2. When you use __stdcall, C++ expects exported functions in the DLL to have the names followed by the postfix designating the overall size of the params passed to it. Thus, your DoSomething routine should become DoSomething@8, taking into account that the size of Integer is 4 bytes and your exports section in the .dpr file should look like:

    exports
    DoSomething name 'DoSomething@8'

  3. Create C++ header with function declaration and include it to your C++ project:

    int __declspec(dllimport) __stdcall DoSomething(int x, int y);

  4. If you use C++ Builder or Visual C++, utilize implib utility which creates import library (.lib). There is also a lib tool coming with VC++ which can do the same. Then link with that .lib file instead of .dll.


No, Delphi does not generate lib files. It has no use for them.

There are ways to create a lib file from a DLL. For example, you can use implib, if it came with your version of Delphi.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜