Delphi .lib for Using in c++

Abdulatif AL ABDOU
Abdulatif AL ABDOU used Ask the Experts™
I am trying to generate .lib in Delphi (Embarcadero XE3). for using it in c++ program

I made a package project; and successfully, i could generate the .lib and the hpp headers... but, when i edit the .hpp, i found that it includes all files needed but has no fonctions...
namespace Spicecorelib
//-- type declarations -------------------------------------------------------
//-- var, const, procedure ---------------------------------------------------
}      /* namespace Spicecorelib */

** What should i do to make functions exported, i have tried with ( cdecl, stdcall, export)....

thanks for your answers in advance
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Geert GOracle dba
Top Expert 2009

there is a section "exports"
where you list what functions can be used from outside the dll

a .lib ?
you create a .dll to use between different languages


What really i need is the use ( or the generate) of (.lib) not dll, i know how to generate and use .dll...

Is it possible from your point of view?

if found a tutorial but it was not helpful for me, because i do nearly the same!

Here it is:

My problem is that my functions are not exported in the hpp files as wanted!

I really need to solve this issue! Thank you in advance for all answers and suggestions
>> it includes all files needed
Sorry I don't have Delphi experience. But was wondering if these files you refer to are header files, and if so, have you looked at all the included header files?
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.


Thanks for your answer; Yes i looked at all included header, i found that some files (classes) are exported correctly; on the other hand, there are files are not exported; i tried to see the differences between those correctly exported and the others but i did not found any difference... I have no experience on Delphi; Juste I know how the code is organized and i can make some modifications not more than that. I try to generate (.lib) to use it in C++QT.

I tried with the (dll); i could export the code in dll; i could charge the dll in C++QT; but when i call the wanted function; program exit without any message. It even not throw an exception!

So i am trying with (.lib)....
It is strange that you get function api's in other headers but not in all of them. So I am taking a wild guess as to how this could happen:
I learned that Delphi has conditional compilations just like C/C++.
If the missing functions are conditionally not included, then that could be a reason for the missing functions.


Thank you phoffric, i will see this! at least i have an idea to work on...
In your other question, you refer to a 21 year old question:
I don't know whether information from an old question is applicable to your environment.

One interesting item from this link is:
"Delphi 1 supports only pascal (the default) and cdecl, Delphi 2 - pascal, cdecl, stdcall, and register.
Functions written in C are usually cdecl."

More information here:
"Both ways should work. In fact, this happens quite frequently at least in code that interacts with the Windows API, because __cdecl is the default for C and C++ programs according to the Visual C++ compiler and the WinAPI functions use the __stdcall convention."
Re: your DLL issue: Possibly you have a mismatch in calling convention you are using in your C++ environment.

I looked around, and guess that you followed instructions similar on this page:

You could try simpler work-arounds. On this link are options:

- Generate .hpp file.
- C/C++ Output file generation
  -> Generate C++ .objs, headers
   - Generates a header file (.hpp) and an object file (.obj)    ‑JPH


You are may be right; i had to try all different call convention. in fact, when i searched for the solution i found

Which talk about using c++ lib in Delphi, I need the inverse i.e: Use Delphi in C++. Thanks a lot for your help; i will test that one more times and will back to tell you if that works...
Geert GOracle dba
Top Expert 2009

my apologies, i didn't see .lib and .dll as separate things
delphi doesn't create .lib files

see this old q on stack:


Thank you Geert G for your answer; Indeed i use Embarcadero for generating .lib, and i have already generated it! I don't know if it was generated correctly!

In the other hand, i am trying to use the DLL but even thing not work; i have generated the DLL, it is charged with C++QT but when i call the function the program exit with code 250477278
Wish I knew Delphi to be better able to help you. But I wanted to make sure that you know the below information that I looked into.
>> code 250477278
- is a Structured Exception Handler associated with error code 0x250477278 (i.e., its equivalent hex value)
- my searches on this code seem to be related more to python usage of Delphi DLL rather than C++. But if you search on either the decimal or hex value of this code, maybe the python (or also some script issues) might help.

Other references:

That decimal value is, in hex, 0EEDFADE. That is the SEH code for a native Delphi exception. So, it would seem that your program is throwing a native Delphi exception that is not being handled. And it is doing so before the Delphi RTL exception handling mechanism is in place to deal with it.

It's impossible for us to say what in your code is causing this to happen, since we don't have the code. What you need to do is some debugging. You first of all need to identify the exception and work out where and why it is being raised. I would start by adding madExcept (or similar) to the project and collect some more information about this exception.

Have you tried to generate just one header and object file as noted earlier as a possible work-around to help diagnose the problem of getting no functions identified in the header?


Hello phoffric, thank you for your answer, it was helpful;

I found the source of the problem (By Installing madExcept ), indeed my delphi program use devexpress components; in the ribbon component, the skins are not charged; when the program try to use the first skin, it will search for it in a list which is empty!

I know now the source of the problem but i did not find yes how to solve it.


Now I think that the problem comes from la dll (gdiplus); there is a line in the code for exit the charging of the Skins when the program does not find the dll (GdiPlus)... My delphi program on windows 7... my c++ program on window 10
Nice to hear that you could narrow down the problem with madExcept. I know that working with mixed Technologies on multiple platforms can pose a challenge especially when you were not the author of these programs. Perhaps the following link can help you with the dll:
The skins not loading may be due to initialization sections not being called for the DLL's included units.  When you load a DLL statically, there seems to be an issue with Delphi where these do not all get called.  See;

If the controls you are using happen to rely on the initialization sections, this will throw them out of sync.  Try loading your DLL statically, to see if the problem persists.

Also, I am interested in why you feel you need a lib instead of a dll.  Can you enlighten us as to why it makes a difference?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial