Using Borland C++ BuilderX 1.5 On Linux
Using Borland C++ BuilderX 1.5 On Linux
By Daniel Horn
Abstract:
This paper shows how to install Borland C++ BuilderX 1.5 Mobile Edition, a
Windows hosted product, on Linux and how to take advantage of additional
toolsets in an IDE that targets only mobile development.
Introduction:
At the time of this writing, Borland C++ BuilderX 1.5
(BCBX1.5) is available only as an IDE that is hosted on the Windows OS and
targets mobile development.
Since version 1 of BCBX is available on multiple platforms
because its core is written in Java, it seemed reasonable to assume that one
should be able to run BCBX1.5 on other platforms as well. Also, since
BCBX1 has an architecture that allows adding support for multiple
compilers/toolsets, it made sense that the support would still exist in BCBX1.5.
This paper consists of three parts:
-
instructions on installing BCBX1.5 on Linux;
-
information on getting a non-Windows hosted toolset
(GNU C++ for Linux) to build and debug from within the IDE; and
-
a few insights into how I figured this out (for those
who wish to further extend the usability and functionality of BCBX1.5 on
other platforms).
As a result of all this, I am now able to take advantage of
the bug fixes and new functionality in version 1.5 for the Linux development I
started with version 1.
Caveats:
This work was done using Borland C++ BuilderX 1.5 Mobile Edition, originally
installed on Windows XP and moved to Red Hat Linux 9.
The Java Runtime Environment (JRE) used on Linux was version 1.4.2-b28.
More specifically, it was the Java Development Kit (JDK) that was installed with
Borland C++BuilderX Version 1 on my Linux system.
The only toolset used to compile, run, and debug with in
this example is GNU C++ for Linux. To take advantage of other toolsets or
features and functionality of the BCBX IDE, you may have to do some additional
tweaking to achieve the builds that you want.
To help you overcome the issues you need to do your work
(e.g., at least as much work you could do with version 1 of BCBX on Linux), I
refer you to the third section of this paper and to the references at the end of
the paper.
The Borland product, C++ BuilderX 1.5 Mobile Edition, is released and
supported as a Windows hosted product. Borland had nothing to do with the work contained in this
paper, and no official endorsement by them should be assumed.
Installing BCBX1.5 on Linux:
Here are the steps for installing and starting up the
BCBX1.5 IDE on Linux:
1) Install BCBX1.5 on a Windows system using the CDs
provided with the product.
2) Copy the
entire CBuilderX1.5 directory tree from your Windows system to your Linux
system.
(I did not want to have to think about any of the permission issues, so I just
copied it to a subdirectory of my home directory).
3) You will need a Java Runtime Environment (JRE) to
launch BCBX1.5 on Linux.
As I already had BCBX 1 installed, I used the JDK (Java
Development Kit) installed as a subdirectory of "CBuilderX".
(You may also want to have BCBX1 installed as a source from which to copy the
pre-installed toolsets).
If you have JBuilder installed on Linux, you could equally
well use its JDK subdirectory.
Alternatively, if no JDK or JRE is already installed on
your Linux system, you could download and install an appropriate version
directly. In particular, the work I did used version 1.4.2-b28.
4) Download the zip file associated with this article
(http://codecentral.borland.com/codecentral/ccWeb.exe/listing?id=21774). Extract the runBCBX1.5 file and place in your
CBuilderX1.5 directory on Linux. Run
chmod +x runBCBX1.5
to make the file into an executable script.
5) Edit the runBCBX1.5 file to change the paths
listed inside it as appropriate. In
particular, set the directory to the version of the Java executable you intend
to use and change the directories in the classpath (-cp) to use the CBuilderX1.5/lib
subdirectory.
6) Then just run:
./runBCBX1.5
CBuilderX1.5 should now start up.
7) If any error
messages appear in your terminal window, you may need to make adjustments to the
"run" command line, such as adding additional jar files or defining
system properties (using the Java -D command line option). In particular, the
only error message seen when I started BCBX1.5 using "runBCBX1.5" was:
*** OpenTool
com.borland.primetime.teamdev.starteam.StarTeamVCS failed to initialize
See the section on how I figured all this out for the
meaning of the contents of the batch/script file and for tips on
how to workaround those messages that indicate problems for you. (Since I
was not using the Star Team version control system, the message was not a
problem for me).
Compiling and Debugging using Toolsets:
Using the environment we have just installed, here's how to
build the Hello World program in the "Welcome" sample project
that comes with BCBX.
You will notice that the Run and Debug icons in the toolbar
are disabled after opening the project from the samples subdirectory. The
reason is that the target platform is set to "Windows".
Click on the Windows target item in the toolbar and choose
Platforms from the menu that appears. In the ensuing dialog box,
select the Linux checkbox and also, if necessary, the GNU C++ Compiler
Tools checkbox. Then choose
OK to close the Platforms panel in the Project Properties
dialog.
To compile the program in the Welcome sample project,
you will need to make a change to its build options.
For whichever configuration you choose, Debug or Release, you will need
to change the include path for the project to /usr/include from /usr/include:/usr/include/g++-3;
you can do this with the Build Options Explorer. Without making this
change, compiler errors will result (in fact, the same compiler errors occur in
BCBX version 1 for the Release configuration of the Welcome project).
You should now be able to build, run, and debug the program
in the BCBX 1.5 IDE.
To add a new toolset, the basic idea is to copy the set of
configuration files for an existing toolset that is similar to your new toolset
and modify them. Adding additional toolsets -- for example, those
provided by BCBX version 1 for Linux -- is a straightforward procedure and
covered in the BCBX help (further references are listed at the end of this
article).
How I Did It:
Here are some insights into how I figured this out that I
hope you will find useful if you need to extend these ideas further.
Since BCBX is written in Java, it seemed reasonable to
assume that getting it to work should consist mostly of getting the Java classes
for the IDE to load using a Linux JVM and then adding the BCBX 1 toolsets.
Unfortunately, CBuilderX is started using a native Windows executable (probably
created using InstallAnywhere). There
is no batch or script file indicating how to start the IDE with a Java command
line statement that describes a classpath and a class to execute.
(A Java application is typically distributed as a jar file
or a collection of jar files. "Jar" stands for "Java
Archive" which is a collection of Java class files; basically, it's a zip
file by another name. To launch a Java application, you run the Java
virtual machine (JVM), the java executable with some command line that tells the
class name of the entry point of the application plus some other JVM parameters
telling things like the classpath which is a list of directories and jar files
containing classes used by the application.)
So how do you start it?
If you look in the CBuilderX1.5/bin directory you will see
a couple of ".config" files. In particular, "cbuilder.config"
seemed like an obvious place to start with for finding out information on how
Java loads the application.
The lines
# Start C++BuilderX using the main class
mainclass com.borland.cbuilder.CBuilder
made it pretty clear where to find the "main" routine for starting the
application.
And fortunately the lines
addpath ../lib/primetime.jar
addpath ../lib/cbuilder.jar
indicated the names of the jar files that contained the
classes providing the top level functionality.
The "addjars" lines seemed to indicate the
directories containing the additional relevant jar files needed to launch the
application.
However, there are many of these and I came across a
simpler way to get the list of necessary jar files. Launch BCBX1.5
normally (i.e., using the usual menu item or icon on Windows) and look at the
"Info" tab of its "About" box (choose the Help | About
C++BuilderX ... menu item) which lists the Java system properties. Double click on the value of the "java.class.path"
item and a text pane appears that contains an ordered list of the jar files
contained in the classpath used to load BCBX. Note that the first two
items are primetime.jar and cbuilder.jar, probably reflecting the ordering of
information in the config file.
I copied this list of jar files and the "mainclass"
information" to create the runBCBX1.5.bat batch file. Running it from
a command line, I was able to see any initialization/warning/error messages and
successfully start the BCBX1.5 IDE on Windows.
The batch file also includes two JVM parameters -Xms and -Xmx
for setting the initial and maximum Java heap size; the values chosen are based
on settings provided in cbuilder.config.
It was then a simple matter of creating a Linux command
equivalent of that batch file that became the "runBCBX1.5" script.
One thing to note about the files is that the order of
listing the jar files is relevant. If, say, you try listing them in
alphabetical order (that is, move the primetime and cbuilder jar files from the
front), you will receive exception messages about class definitions not being
found.
If you suspect you may need to make additional changes to
the startup command, I suggest looking that the About box as a starting
point. For example, if there are any system properties such as extensions
or library settings you need to add, once you know the desired value, it is easy
to add it to the java command line using "-D".
Adding "-verbose" to the end of the command line
in "runBCBX1.5.bat" or "runBCBX1.5" gives more information
about the classes loaded when launching the application.
What's Next:
With the exception of the separator character used in the "run"
script above, there is practically nothing specific to the operating system or
shell. In other words, even though my discussion is in the context of
Linux, you can probably apply this same information to getting BCBX to work on
any platform that supports an appropriate JRE. (However, full disclosure
requires noting that this has not been tried on Solaris or Macintosh, only on
Linux; if you try this on any other platforms, send me an email to let me know
how things went).
For more information and a further example on adding toolsets to BCBX, see my
article Installing
the Cygwin Toolset in Borland C++ BuilderX. In this specific example, even though we take a specific toolset, Cygwin,
and add it to BCBX under Windows, the ideas discussed apply to all platforms.
For more authoritative information on toolsets, look for the "Build Tools and Toolsets" and "Adding
Custom Toolsets" topics in the BCBX help. Also, the toolsetdoc.html and tooldoc.html files in the
/CBuilderX/toolsets directory document the XML schemas used in .toolset and .tool files.
Questions, comments, and suggestions may be sent to the
author at dan@nerds.com ; use the title of the article or the words BDN
Article in the email subject.