Recent

Author Topic: C++ / Lazarus Integration  (Read 11108 times)

chris.gordon-smith

  • New Member
  • *
  • Posts: 12
    • http://graffiti.virgin.net/c.gordon-smith/index.html
C++ / Lazarus Integration
« on: February 03, 2004, 01:46:43 am »
Since the future of C++ Builder and Kylix is not clear, I am interested in the possibility of Lazarus providing the basis of a platform for code developed for these Borland products.

I have produced a small demo program that shows that:-

*   A C++ main program can invoke a Lazarus based GUI application
*   A Lazarus GUI event (eg on a button) can call a C++ function and pass
arguments to it
*   The called C++ function can pass a return value back to the calling
Lazarus procedure.

The above features provide key capabilities required for a C++ / Lazarus program. They enable GUI events to be handled by C++ code.

For more details, see:-

http://graffiti.virgin.net/c.gordon-smith/SimSoup/Lazarus_Integration.html

As it stands, the C++ / Lazurus integration that is embodied in the demo program would not enable C++ Builder / Kylix(C++) code to be migrated with
no changes. However, I believe that it may well provide the basis for a migration that could be achieved in many cases by making fairly simple and
systematic changes to existing code.

Any comments welcome, especially regarding how the integration could be improved.

Chris Gordon-Smith
London
Homepage: http://graffiti.virgin.net/c.gordon-smith/
Email Address: Please see my Home Page

neli

  • Jr. Member
  • **
  • Posts: 86
C++ / Lazarus Integration
« Reply #1 on: February 03, 2004, 11:08:47 pm »
You posted this BCB NG as well?

Problem with your approach is "... program would not enable C++ Builder / Kylix(C++) code to be migrated with no changes.", which is quite an understatement :D. From C++, no freepascal/lcl component can be accessed, which is a major drawback IMHO.

So we either need a C++ compiler that can understand object pascal "weirdness" (borland c++ alike), or implement an "export" option in freepascal to gcc/g++ compatible classes.

As I said in NG, the first should be doable, but there are probably many freepascal specifics in LCL code, but it's worth a try.
The second needs major support from FreePascal core compiler team. They are open for input, but it won't be a high priority item for them, as they want to release a version 2.0 compiler first, I think.

Hope this is useful.

Micha.

chris.gordon-smith

  • New Member
  • *
  • Posts: 12
    • http://graffiti.virgin.net/c.gordon-smith/index.html
C++ / Lazarus Integration
« Reply #2 on: February 04, 2004, 12:16:34 am »
I think that the ideas you suggest are worth looking into. However, as you say, making changes in Free Pascal for C++ integration may not be the top priority for the Free Pascal project.

Looking at using the Borland compilers might be worth a try.

Even if neither of the above is feasible, I don't think this necessarily rules out finding a workable approach to migrating C++ Builder / Kylix (C++) code to Lazarus.

You have said "From C++, no freepascal/lcl component can be accessed..". I think it may be true that direct access is not possible, but I see no reason why it should not be possible to access freepascal / lcl components through some kind of 'wrapper' layer.

Chris Gordon-Smith
London
Homepage: http://graffiti.virgin.net/c.gordon-smith/
Email Address: Please see my Home Page

neli

  • Jr. Member
  • **
  • Posts: 86
C++ / Lazarus Integration
« Reply #3 on: February 09, 2004, 07:42:00 pm »
Quote from: "chris.gordon-smith"

You have said "From C++, no freepascal/lcl component can be accessed..". I think it may be true that direct access is not possible, but I see no reason why it should not be possible to access freepascal / lcl components through some kind of 'wrapper' layer.


Exactly. It is possible via a "C" style global functions, as you did, but I indeed meant direct access like: Button1->Caption = "Hello";

Micha.

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
C++ / Lazarus Integration
« Reply #4 on: April 13, 2004, 12:06:42 pm »
IMHO Lazarus should not try to be a C++ compiler, too.

But it would be goot if it was possible to link to GNU C++ objects in ether direction. For this the ABI of the object files would need to be compatible with the GNU C++ (3.x) ABI . AFAIK, this is not (yet) the case. Is this planned ? If not, why not ?

-Michael

neli

  • Jr. Member
  • **
  • Posts: 86
C++ / Lazarus Integration
« Reply #5 on: April 13, 2004, 07:01:32 pm »
The C++ ABI still isn't fully stable. G++ abi could change without notice (and it does, AFAIK). I couldn't find any documentation about how they implemented the abi but maybe I didn't look hard enough. There is the Intel IA 64 bit c++ abi (or something alike), which they are implementing I think, but it still has open issues.

Futhermore, it is planned to be done after FreePascal 2.0 has been released: http://www.freepascal.org/future.html

HTH,

Micha

 

TinyPortal © 2005-2018