Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pascal/Delphi and XCode



Hi All,

Thanks Chris and Jonas. I did a lot of tweaking with Free Pascal and eventually got it to work!

One more thing though, do I need to do anything special in order to get the Dynamic Library to Load? Does it need to be in the same folder as the place it is used from? I am developing a Plug-In that calls the Pascal library. When I don't use the pascal library my PlugIn loads and works ok (except that the functionality of the Pascal Library isn't there!!!) but when I make it call and reference the pascal library is doesn't load so I am guessing that the problem is that it is not finding the Pascal library correctly.

All the Best
Dave

On 7 Feb 2007, at 12:28, Jonas Maebe wrote:


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:
http://lists.apple.com/mailman/options/xcode-users/dave% 40looktowindward.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden
References: 
 >Help Regarding Xcode 2.4 (From: "Lijith P" <email@hidden>)
 >Pascal/Delphi and XCode (From: Dave <email@hidden>)
 >Re: Pascal/Delphi and XCode (From: Jonas Maebe <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.