How to use a delphi XE3 obj file in delphi 2007?

Hi,
I'm migrating an application from delphi 2007 to delphi XE3 and I would like to do it in several steps. To do this I need to use a part of my new code (XE3) in the current delphi 2007 application. So I want to use the .obj file from my XE3 file. I know I have to use the {$L 'Filename'} and I know that I have to declare the functions that I want to use in external in my D2007 project.
I wanted to make an easy and simple example to see how it works with only 1 function 'hello world' compiled in obj with XE3 but I can't find the way to use it in D2007.
In D2007 I used the {$L 'Filename'} and declared the function external but the D2007 project doesn't start if in my code I call this function. If I comment the line containing the function in my code the application starts normally but if there is this function it compiles but doesn't start at all (also with the dcu's debug and launching it with F7).
Can anybody give me some tips on how to use the obj's in my D2007 project?
Regards
0
Alain
6/19/2014 11:55:17 AM
📁 embarcadero.delphi.non-tech
📃 5933 articles.
⭐ 1 followers.

💬 6 Replies
👁️‍🗨️ 2310 Views


Am 19.06.2014 13:55, schrieb Alain MILANDRE:
> Hi,
> 
> I'm migrating an application from delphi 2007 to delphi XE3 and I would like to do it in several steps. To do this I need to use a part of my new code (XE3) in the current delphi 2007 application. So I want to use the .obj file from my XE3 file. I know I have to use the {$L 'Filename'} and I know that I have to declare the functions that I want to use in external in my D2007 project.
> 
> I wanted to make an easy and simple example to see how it works with only 1 function 'hello world' compiled in obj with XE3 but I can't find the way to use it in D2007.
> 
> In D2007 I used the {$L 'Filename'} and declared the function external but the D2007 project doesn't start if in my code I call this function. If I comment the line containing the function in my code the application starts normally but if there is this function it compiles but doesn't start at all (also with the dcu's debug and launching it with F7).
> 
> Can anybody give me some tips on how to use the obj's in my D2007 project?
> 
> Regards
> 
Hello,
you might get more and better answers if you ask this question over in
the compiler related newsgroups.
Greetings
Markus
0
Markus
6/19/2014 7:04:19 PM
> {quote:title=Alain MILANDRE wrote:}{quote}
> Hi,
> 
> I'm migrating an application from delphi 2007 to delphi XE3 and I would like to do it in several steps. To do this I need to use a part of my new code (XE3) in the current delphi 2007 application. So I want to use the .obj file from my XE3 file. I know I have to use the {$L 'Filename'} and I know that I have to declare the functions that I want to use in external in my D2007 project.
> 
> I wanted to make an easy and simple example to see how it works with only 1 function 'hello world' compiled in obj with XE3 but I can't find the way to use it in D2007.
> 
> In D2007 I used the {$L 'Filename'} and declared the function external but the D2007 project doesn't start if in my code I call this function. If I comment the line containing the function in my code the application starts normally but if there is this function it compiles but doesn't start at all (also with the dcu's debug and launching it with F7).
> 
> Can anybody give me some tips on how to use the obj's in my D2007 project?
> 
> Regards
Years ago I enhanced a TPW 1.5 with Delphi 1 .... yeah I'm old ... anyway the way I did it then and how you could do it now is use a DLL for you new functionality ... you are going to have massive problems otherwise due to fundamental changes to Delphi around 2010 (double byte chars will be the big one)
--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"
0
Linden
6/19/2014 10:45:00 PM
Alain MILANDRE wrote:
> Can anybody give me some tips on how to use the obj's in my D2007
> project?
It's impossible in general: each new compiler generates version
specific code for classes, RTTI, etc, recent versions has new language
features which are not exist in older versions.
The only reliable way (as Linden said) is creation of DLL with
interface in POD ("plain old data") style.
--
Alex
0
Alex
6/20/2014 2:56:16 AM
> {quote:title=Alex Belo wrote:}{quote}
> The only reliable way (as Linden said) is creation of DLL with
> interface in POD ("plain old data") style.

There are more flexible possibilities: DLL's can also expose functions that return or expect interfaces, all of this without needing ActiveX. That way you can easily pass objects (tInterfacedObjects) between DLL's and executables. I do it all the time. It's also a great way for creating plugins. 
The only things to watch out for are :
  -only use automation-compatible data types (such as interface, widestring, integer, double, wordbool) in the interfaces. These data types make no assumption about the underlying memory manager and memory layout.
  -make sure that the DLL and the executable use identical declarations for the exposed interfaces (for example, by sharing a common declaration unit). 

Now if only Delphi DLL's weren't so absurdly bloated...Sigh.
0
Arthur
6/20/2014 7:07:49 AM
Hi everybody,
thanks for the tips, I will try with a DLL an see if I can do what I want.
Regards
0
Alain
6/20/2014 12:51:00 PM
Hi everybody,
thanks for the tips, I will try with a DLL an see if I can do what I want.
Regards
0
Alain
6/20/2014 1:06:05 PM
Reply: