Linking C .obj files into Delphi application, resolving standard C dependencies?

Depending on the version of Delphi you have, there should be a unit called crtl. Dcu with which you can link. Just use the $L directive for each .

Obj file in a unit that also uses crtl. You may also need to "use" other various units like Windows, WinSock, etc... The point is to provide the symbols and functions to resolve during the link phase.

Up vote 2 down vote favorite 4 share g+ share fb share tw.

I compiled libxml2 with BCC 5.5 command line compiler, now I have lots of . Obj files which I'd like to link into my Delphi application. Unfortunately, I get lots of "Unsatisfied forward or external declaration" errors, pointing to standard C library functions like memcpy, open, recv etc ... What should I do to compile it correctly?

I'd like to avoid depending on msvcrt. Dll or any other external libraries. Thanks in advance!

C delphi . Obj link|improve this question edited Jan 13 '11 at 9:56skaffman114k8135227 asked Dec 27 '09 at 18:46migajek2,11311434 98% accept rate.

Depending on the version of Delphi you have, there should be a unit called crtl. Dcu with which you can link. Just use the $L directive for each .

Obj file in a unit that also uses crtl. You may also need to "use" other various units like Windows, WinSock, etc... The point is to provide the symbols and functions to resolve during the link phase. This is the same technique used to statically link in the DataSnap TClientDataSet code used to also build midas.dll.

Unfortunately, there is no crtl unit in my Delphi installation... it's Delphi7 PE. – migajek Dec 27 '09 at 19:50 Sounds like an excellent reason to upgrade to at least D2007 ;-) – Allen Bauer Dec 28 '09 at 20:22 +1. Cool tip.

Thanks Allen. – Warren P Jan 4 '10 at 16:37.

You should read article of Rudy here "Using C object files in Delphi.

1 Welcome to Stack Overflow. That's a good article, but to make this a better answer, you should explain why that's a good article to read. Tell what to expect.

In particular, that article describes two techniques for solving the problem. One is to manually implement all the missing functions. (The article demonstrates.

) The other way is to link with msvcrt. Dll, which already has implementations of all the missing functions. (The article demonstrates that, too.

) The second way is especially good for functions like printf, which can't be implemented easily in Delphi. – Rob Kennedy Dec 28 '09 at 17:32.

Don't use those functions, but rewrite them to call operating system functions (kernel32/system32) directly.

The C code I'm compiling is libxml2 which is quite complex, I'd like to avoid any changes there. – migajek Dec 27 '09 at 19:51 @michal: You are aware that there are a couple of dozen free Delphi wrappers available for LibXML2, right? Here's one, recommended by Marco Cantu: URL1. Marco's blog recommendation for this implementation can be found at blog.marcocantu.com/blog/delphicomps.html – Ken White Dec 29 '09 at 14:48 For which libxml2 exactly?

There are heaps of builds. – Marco van de Voort Dec 29 '09 at 21:01 Huh I had no idea ... the one checked out from libxml2 page? – migajek Dec 31 '09 at 13:30 Ken I know that.

I just want to avoid additional dlls. – migajek Dec 31 '09 at 13:32.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions