Using the NAG C Library Mark 9 (or earlier) Windows DLLs
The information on this page is applicable to Mark 9 of the NAG C Library DLLs (shipped with CLW3209DAL) unless otherwise stated.
- Accessing the Library from the Command Line
- Accessing the Library from Other Environments
- General Advice on Accessing the Library
In the following, driver.c represents the name of your application program and install dir is the folder where the NAG C Library DLLs product is installed.
- Microsoft Visual C++
cl /MD /I"install dir\include" driver.c "install dir\lib\CLW3209DA_nag.lib"(on one continuous line).
The "/MD" option should be used to specify linking with MSVCRT.LIB.
Alternatively, if you wish to link to the version of the NAG C Library that uses the Intel® Math Kernel Library 10.2 for Windows (MKL) which is included in this product, you should compile your program in the following manner:
cl /MD /I"install dir\include" driver.c "install dir\lib\CLW3209DA_mkl.lib"
If the folder containing the import libraries has been added to the LIB environment variable and the include folder has been added to the INCLUDE environment variable, these commands may be simplified to
cl /MD driver.c CLW3209DA_nag.liband
cl /MD driver.c CLW3209DA_mkl.librespectively.
Tested with Visual Studio 2005 (VC++ 8*), Visual Studio 2008 (VC++ 9**) and Visual Studio 2010 (VC++ 10***).
- Intel C++
icl /MD /I"install dir\include" driver.c "install dir\lib\CLW3209DA_nag.lib"or, if the LIB and INCLUDE environment variables have set appropriately,
icl /MD driver.c CLW3209DA_nag.lib
Substitute CLW3209DA_mkl.lib to use MKL.
- Borland C++ Applicable to CLDLL084ZL.
If you use Borland C++ and would like to access the NAG C Library Mark 9 please contact us.
Borland import libraries (CLDLL084Z_nag_bc.lib and CLDLL084Z_mkl_bc.lib) are supplied with this implementation and may be found in the install dir\lib folder.
You may compile and link your C application program to the NAG C Library DLL on the command line in the following manner:
bcc32 /I"install dir\include" driver.c "install dir\lib\CLDLL084Z_nag_bc.lib"
Alternatively you may add the location of the NAG header files and the folder containing the import libraries to the -I and -L entries respectively in the configuration file bcc32.cfg. For more details please see the compiler documentation. If you have amended the configuration file then you may simply type:
bcc32 driver.c CLDLL084Z_nag_bc.lib
Substitute CLDLL084Z_mkl_bc.lib to use MKL. 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.
Tested with Borland C++ (bcc32) 5.8 (from Borland Developer Studio 2006 / Borland C++ Builder Preview Version 10.0).
To compile with gcc in a Windows command prompt window:
gcc -I "install dir\include" driver.c "install dir\lib\CLW3209DA_nag.lib" -o driver.exeTo compile with gcc in a Cygwin xterm window:
gcc -I "install dir/include" driver.c "install dir/lib/CLW3209DA_nag.lib" -o driver.exeor
gcc -I install\ dir/include driver.c install\ dir/lib/CLW3209DA_nag.lib -o driver.exe
With older versions of gcc, the -mno-cygwin option may also be required. This option removes dependence on cygwin1.dll, using the MinGW version of gcc instead (which is shipped as part of Cygwin). Because both the NAG C Library DLLs and the executables produced by the MinGW gcc compiler use the Microsoft runtime libraries, I/O issues are less likely to occur. This option is not available (or necessary) with newer versions of gcc (e.g. gcc version 4.3.4).
Substitute CLW3209DA_mkl.lib to use MKL.
The NAG C Library DLLs can also be accessed from many GUI environments. The web pages in the list below contain links to sample projects for Microsoft Visual C++, Borland C++ Builder, Microsoft Visual Basic 6, Microsoft Visual Basic .NET and Borland Delphi, worksheets for Microsoft Excel and some examples showing how to access the NAG C Library from C# and Java applications.
- Microsoft Visual C++
- Microsoft Visual Basic 6
- Microsoft Visual Basic .NET
- Microsoft Visual Basic .NET 64-bit (Information applies to 64-bit library CLW6I09DAL)
- Microsoft Excel
- Microsoft Excel 64-bit (Information applies to 64-bit library CLW6I09DAL)
- Borland C++ Builder (Information applies to Mark 8 DLLs)
- Borland Delphi (Information applies to Mark 8 DLLs)
If you use Borland C++ Builder or Delphi and would like to access the NAG C Library Mark 9 please contact us.
To facilitate calling the NAG C Library DLLs from Visual Basic, header files have been produced, providing declare statements for each function, type / structure definitions, constants, enumerated types and skeleton call-back functions (where appropriate). There are four sets of headers:
- Headers for use with Visual Basic 6 / Visual Basic for Applications and CLW3209DAL
- Headers for use with Visual Basic .NET and CLW3209DAL
- Headers for use with 64-bit Visual Basic for Applications 7.0 (VBA7) and CLW6I09DAL
- Headers for use with 64-bit Visual Basic .NET and CLW6I09DAL
When running any program linked with the NAG C Library the appropriate DLLs need to be accessible.
The .\bin subfolder of the library folder must be included in your PATH to run applications.
The .\MKL_ia32_10.2\bin subfolder of the library folder must be included in your PATH to run applications linked with MKL. This should appear later in your PATH than the .\bin folder containing the NAG DLLs.
The installation script may have attempted to do this for you, but in some cases manual intervention may be required. On most systems this may be effected using the Environment Variables button on the Control Panel | System | Advanced tab (Advanced System Settings on Windows Vista / Windows 7).
To include functions from the Library in projects developed under an integrated development environment (e.g. Microsoft Developer Studio), the project environment must be set to search for include (.h) files in the .\include subfolder of the library folder. Library files must be searched for under the .\lib subfolder of the library folder. In Developer Studio open the Tools | Options dialog box, select the Projects (or Projects and Solutions) | VC++ Directories section and enter the appropriate setting for each type of folder. In this DLL implementation, for convenience, the MKL symbols are exported directly from the NAG import library CLW3209DA_mkl.lib, so it is not necessary to specify the MKL import libraries subfolder (.\MKL_ia32_10.2\lib) as well.
If your machine has more than one processor and you are using Intel MKL, then it is recommended that you set the environment variable OMP_NUM_THREADS to the number of available processors, e.g.
This will enable the Intel MKL BLAS to make use of the extra processor(s) and will thus speed up the computation of many of the NAG library routines. On most systems setting this environment variable may be effected using the Environment Variables button on the Control Panel | System | Advanced tab (Advanced System Settings on Windows Vista / Windows 7).
Normally you are advised to use NAG_ALLOC to allocate memory and NAG_FREE to deallocate memory, however in mixed language programming, these C preprocessor macros are not available. Instead you may call the x04bjc and x04bdc functions directly to allocate and deallocate memory.
The function x04bjc is the NAG memory allocator in this implementation.
Pointer NAG_CALL x04bjc(size_t size);
The function x04bdc is the NAG memory deallocator.
void NAG_CALL x04bdc(Pointer *ptr);
Note: Within a number of NAG C Library functions, memory is allocated internally and returned to the calling function. This allocated memory contains information that is potentially useful to the user. Consequently freeing this memory has been left to user discretion. However, in the context of DLLs such internally allocated memory cannot be freed externally.
For an example of the use of x04bdc, please refer to the g05eac example program.
Note that the NAG C Library DLLs supplied with CLW3209DAL use the __stdcall calling convention for function calls.
Learn more about the NAG DLLs.
* Microsoft C/C++ Compiler Version 14.00 ** Microsoft C/C++ Compiler Version 15.00 *** Microsoft C/C++ Compiler Version 16.00