4

if I have a source of library written in C/C++ (lets say its libxml2), now I'd like to build it, and link it into the delphi application... I know it is possible, since Delphi Zlib does it ( http://www.dellapasqua.com/delphizlib/ ) ... But my question is, how to prepare those .obj files?

Thanks in advance m.

2 Answers 2

6

You would need to use CodeGear's C++ compiler to produce compatible obj files for Delphi. Does your Delphi come with C++ Builder? Otherwise you could try the free (Borland) commandline version. Read more about this subject here.

Sign up to request clarification or add additional context in comments.

3 Comments

I've already read that article. This however doesn't cover the topic of solving C standard library dependencies, I don't find it possible to re-implement so many C standard functions like open,read, recv, memcpy etc etc ... I believe there is a better solution than the one author did proposed.
Maybe it is best if update your question with this new information. Or ask a new question about this specific issue.
tip from Allen's article: add crtl.dcu to your project to solve core C RTL link issues.
1

If you create a dll that adheres to the C Application Binary Interface (ABI), you can dynamically link to it from either a C++ or a Delphi Application.

It is advisable that you do the the following:

  1. Use only C or C style code, do yourself a favour and surround the module with

#ifdef __cplusplus
extern "C"
{
//header file
}
#endif //__cplusplus

This guarantees that the code compiles into the C ABI

  1. it is advisable to make the functions __stdcall

  2. Compile the function as a dll

from here you should be able to link to the dll in the same way that Delphi can link to any windows DLL. (I can't remember what needs to be done from the Delphi side)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.