Re: Pascal/Delphi and XCode
Re: Pascal/Delphi and XCode
- Subject: Re: Pascal/Delphi and XCode
- From: Jonas Maebe <email@hidden>
- Date: Wed, 7 Feb 2007 13:28:20 +0100
On 7 feb 2007, at 13:06, Dave wrote:
2. Try to Compile the Delphi/Pascal code under MacOS X and
include it in my XCode C/C++ project.
Since I don't really want to have to re-write the code if I don't
have to, I decided to investigate option 2 and was quite pleased to
find a Free Pascal Compiler for Intel/MacOS X. I have managed to
compile the module into a Dynamic Library. I then included it into
my XCode Project and it seemed to accept the file ok, however when
I build the project I get undefined errors on the Link phase.
I'm now not sure if the problem lies in the Library file created by
Free Pascal or if I have to do something extra in XCode in order to
link my C code to the Dynamic Library.
One thing to take into account is that since Pascal has a different
namespace for each compilation unit, the default symbol names are
different than those which are expected by GCC. If you want to export
functions from a Pascal unit/shared library for C use, make sure you
do the following:
a) add {$calling cdecl} to all Pascal sources to make sure the used
calling conventions matches what GCC expects
b) In your main library Pascal file, specify all exported functions
like this:
exports
AddRTFBibToClipContents name '_AddRTFBibToClipContents',
AddToTermLists name '_AddToTermLists',
combineStyledTextDataRB name '_combineStyledTextDataRB',
ConvertToRTF name '_ConvertToRTF',
CopyStylesToClipRB name '_CopyStylesToClipRB',
FormatLib name '_FormatLib',
... ;
(don't forget the extra _ at the start of each name). This will set
the name of the exported functions to the symbol names that GCC will
use.
Jonas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden