Sample Borland C++ Builder Projects Illustrating How to Call the NAG C Library

The information here is applicable to the DLLs supplied with CLDLL084ZL.

If you use Borland C++ Builder and would like to access the NAG C Library Mark 9 please contact us.

This web page contains links to several zip files, each containing a Borland C++ Builder project showing how to call a different NAG C Library function.

The projects were tested using Borland Developer Studio 2006 / Borland C++ Builder Preview Version 10.0 and may not work with other versions of Borland C++ Builder.

Please check that the following project options are set correctly:

  • Under Project | Options, in the C++ Compiler (bcc32) | Paths and Defines section, set Include search path to specify the location of the NAG C Library include folder (the default is ..\..\..\include).

     

  • Under Project | Add to Project, add the Borland specific version of the NAG C import library (the default is ..\..\..\lib\CLDLL084Z_nag_bc.lib).

Note that these example projects contain both C and C++ source files (the C files containing slightly modified versions of the example programs from the examples\source folder). Because the C function is called from C++ code, the C function must be declared as extern "C" in the C++ code. For an example, see the files d01sjce.c and UnitD01sjc.cpp in the d01sjc project folder.

Another important point to note is that the NAG C Library was built on the assumption that enumerated types are compatible with four-byte integers, and so if you wish to call a NAG function which has an enum type as an argument, you MUST ensure that the "Enums always integer sized" box is checked in the C++ Compiler (bcc32) | Compiling section of the Project Options.

Remember also that to be able to run the program after you have compiled it, the NAG C Library DLL will need to appear somewhere in your current path. If the DLL is in C:\Program Files\NAG\CL08\cldll084zl\bin (for example), then your PATH environment variable must contain this folder before starting Borland C++ Builder. If you are using the MKL-based version of the NAG C Library (CLDLL084Z_mkl.dll), then the folder containing the MKL DLLs should also be on your path, but should appear later in the path than the bin folder for the NAG C Library DLLs, e.g.

C:\Program Files\NAG\CL08\cldll084zl\bin;C:\Program Files\NAG\CL08\
cldll084zl\MKL_ia32_8.0\bin;<rest of path>

Occasionally, when using the MKL-based DLL, the handling of floating-point exceptions may cause the program to terminate abnormally; if you experience such problems, it is recommended that you use the self-contained NAG DLL instead.