Using the Free Borland C++ compiler
If you have access to Visual C++, then compiling C++ to produce an EXE or a DLL isn’t particularly hard. If not, then you either have to use gcc or there is an excellent free C++ compiler provided by Borland. You can download freecommandlinetools.exe from the Borland FTP site.
To install, simply run the EXE and decide where you want to install it. To use it on the command line, you’ll need to add %INSTALL-DIR%\Borland\BCC55\Bin to your path (we have a little batch file that does this for us).
Since you’re likely to want the compiler and linker to include various standard header files and libraries, you can set up a configuration file to do this for you:
- Go to
%INSTALL-DIR%\Borland\BCC55\Binand create abcc32.cfgfile. - To add include directories, you need to specify
-I"<directory>;<directory>..."and to add
library directories, you need to specify-L"<directory>;<directory>...". For our ADSI examples,
we need both the normal include directories and the aditional PSDK library subdirectory. Since we had installed the compiler
intoC:\tools\Borland\our config file looks like this:-I"C:\tools\Borland\Bcc55\include" -L"C:\tools\Borland\Bcc55\lib;C:\tools\Borland\Bcc55\Lib\PSDK"
To compile a simple EXE (such as the ADSI test example) all you need to do is
call:
bcc32 -tWM <yourfile>.cpp
The -tWM tells the linker that we want a 32-bit multi-threaded windows application. For the ADSI example,
we need to add the activeds.lib library to include the ADSI functions. So the command becomes:
bcc32 -tWM activeds.lib getUserGroups.cpp
When building for JNI, we need to add the Java header files. We can either do this in the bcc32.cfg file (by adding the
absolute path the the JDK include directories), or (if JAVA_HOME is set), you can add them to the command line as follows.
bcc32 -tWM -tWD -I%JAVA_HOME%/include -I%JAVA_HOME%/include/win32 <yourfile>.cpp
Here, as well as adding the includes, we’ve added -tWD, this tells the linker that we want to make a DLL.
One of the things that I like about using the Borland compiler is that it’s straight-forward to integrate it into an ANT
build script. So, our build.xml has the following targets to build our JNI DLL:
<target name="makeDLL"
description="build the header file from the class file, then compile the DLL">
<!-- first (re-)make the header file that we include in our C++ file -->
<javah
classpath="${builddir}"
verbose="true"
destdir="${cppdir}"
>
<class name="com.isocra.util.ADSIGetUserGroups"/>
</javah>
<!-- now execute the borland C++ compiler.
NB I had to play around with the env key to make sure it set the
path correctly (in particular the case of the key).
I'm not convinced this will work in all cases -->
<exec dir="${cppdir}" executable="${cppCompilerDir}\bcc32.exe">
<arg line="-tWM -tWD -I${java.include} -I${java.include}/win32 dllGetUserGroups.cpp"/>
<env key="Path" path="${cppCompilerDir}"/>
</exec>
</target>
Tags: C++, free tools
Subscribe to news from Isocra



June 19th, 2008 at 11:19 am
Unfortunately the free Borland C++ compiler is no longer available. However if you need to compile C++ for Windows then there is the new Visual C++ 2008 Express Edition or for alternatives have a look thefreecountry.com.
June 29th, 2008 at 9:03 am
PLS SEND C COMPILER
September 9th, 2008 at 10:26 am
hello,
sir i am a student of M.C.A. in gkv haridwar and i am using your copmilier last 6month i can say that it’s work in very efficent
manner i am thanfull to u sir,.
November 19th, 2008 at 4:43 am
Borland Free Compiler not Dead yet. It’s now Turbo C++ Explorer. Complete IDE (.NET based) free for commercial purpose (single user license).
Try it
February 24th, 2009 at 10:15 am
pls i have down loaded the compiler but can use it how do i do it pls
July 5th, 2009 at 2:59 pm
Hello .I need a compailer.
November 30th, 2009 at 7:51 am
Hello .I need a compailer