How do I port code for Borland C++ builder to Linux?
Asked Answered
J

6

6

I have source code for a Windows DLL that is written in C++ and uses Visual Component Library. Now my task is to port that to Linux, but I don't have source code for the VCL itself, or any kind of documentation (and I have never worked with Borland C++; in my Windows days I used MFC).

This should not be all that hard, since my DLL does not have any GUI: as far as I can see, it mostly uses VCL for multithreading. I ran into a class that inherits from TThread and that is where I got stuck. I did some search on the Internet, but found no documentation for VCL so far. I would like to avoid buying a book on Borland C++ Builder, because I don't have time to wait for it to arrive from the Amazon. I cannot consider buying the package for Windows, because at work I only have a Linux box.

Any suggestions?

Jorum answered 2/4, 2009 at 17:1 Comment(1)
Now that some time has gone by, it's worth commenting that Delphi XE3 and C++ Builder XE3 will probably be able to target (but not install the IDE onto) Linux. You would still need a Windows box to build and develop, but the creation of Linux executables will probably become possible in some future Delphi or C++Builder version (2012 or 2013 perhaps). This question seems to only need a reimplementation of TTHread. But I would suggest refactoring OUT the TThread, and replacing it with Boost thread libraries.Telford
L
3

The VCL is documented on CodeGear's web site. TThread in particular is described here.

I've found the documentation on the threading-related components of the VCL to be rather sparse. This site has a much better description of the Delphi/VCL approach to threading.

Lamelli answered 2/4, 2009 at 17:18 Comment(0)
S
5

The Boost libraries, and wxWidgets, will provide analogs to the VCL classes.

Simulacrum answered 2/4, 2009 at 17:4 Comment(2)
This is the right approach. Refactor out the TThread, replace with Boost threading classes.Telford
I second the above comment. If Embarcadero were smart, they would have built the latest incarnation of their C++ IDE with Boost libs underpinning it.Plantagenet
P
5

You should be aware that the VCL used by C++ Builder is written entirely in Delphi/ObjectPascal. c++ builder apps all involve c++ making use of delphi-based libraries.

The FreePascal/Lazarus open source project has reverse-engineered most of the VCL (almost all of the non-visual stuff and much of the visual stuff) and it runs natively on Linux. The non-visual VCL-compatible stuff is known as the "Free Component Library" ("FCL") http://www.freepascal.org/ http://www.freepascal.org/fcl/fcl.var

The source of the TThread implementation in the FCL should be easy enough to find.

One option would be to rewrite in FreePascal, where language would change to ObjectPascal but calls to the VCL and usage of VCL components would be virtually identical.

Another option might be to port to c++ on Linux and somehow make use of FreePascal's VCL from c++. I'm not sure of the practicality/feasibility of that. Someone at FreePascal's forums should be able to help answer that.

So another option as someone has mentioned would just be to rewrite using some other threading library.

Pavla answered 2/4, 2009 at 17:56 Comment(0)
L
3

The VCL is documented on CodeGear's web site. TThread in particular is described here.

I've found the documentation on the threading-related components of the VCL to be rather sparse. This site has a much better description of the Delphi/VCL approach to threading.

Lamelli answered 2/4, 2009 at 17:18 Comment(0)
C
2

You can download their free compiler and try experimenting with it. It should be possible to run it under WINE at least. Maybe even under FreeDOS.

It should be related to the TThread class in Delphi/Kylix. That is another alternative for exploring it. I do believe that the most important methods were run() and sync() but it's been ages since I used it.

However, if you plan to cleanly port the code to Linux, it may help to re-implement the TThread class yourself, using some boost libraries or something.

Caesaria answered 2/4, 2009 at 17:8 Comment(0)
T
2

Many years ago, Borland released a version of their IDE for linux, marketed as Kylix. I'm not sure if it is still supported, but that might be the path of least resistance, for you.

Trill answered 2/4, 2009 at 17:34 Comment(0)
C
1

There are several libraries that provide frameworks like threading e.g. Boost (www.boost.org) or ACE (http://www.cs.wustl.edu/~schmidt/ACE.html)

It should be fairly easy to port the code to use one of these threading infrastructures.

Cycle answered 6/4, 2009 at 2:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.