Using the NAG C Library Mark 26 Windows DLLs
The information on this page is applicable to Mark 26 of the NAG C Library DLLs (shipped with CLW3226DEL) unless otherwise stated. For the latest information on calling the NAG C Library DLLs from various environments, or for sample projects for a specific Mark of the NAG C Library, please go to the main NAG C Library DLL support index page.
- 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\CLW3226DE_nag.lib"
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 11.3.3 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\CLW3226DE_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 CLW3226DE_nag.lib
cl /MD driver.c CLW3226DE_mkl.lib
- Intel C++
icl /MD /I"install dir\include" driver.c "install dir\lib\CLW3226DE_nag.lib"
or, if the LIB and INCLUDE environment variables have set appropriately,
icl /MD driver.c CLW3226DE_nag.lib
Substitute CLW3226DE_mkl.lib to use MKL.
To compile with gcc in a Windows command prompt window:
gcc -I "install dir\include" driver.c "install dir\lib\CLW3226DE_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 CLW3226DE_mkl.lib to use MKL.
(Note that if you are using the shipped C examples as a basis for your code when calling from gcc, you will need to replace any calls to
scanf_s()by calls to scanf().)
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 Basic .NET, worksheets for Microsoft Excel and some examples showing how to access the NAG C Library from C# and Java applications.
- Microsoft Visual Basic .NET
- Microsoft Visual Basic .NET 64-bit (Information applies to 64-bit library CLW6I26DEL)
- Microsoft Excel
- Microsoft Excel 64-bit (Information applies to 64-bit library CLW6I26DEL)
- C# 64-bit (Information applies to 64-bit library CLW6I26DEL)
If you use Visual Basic 6, Borland C++ Builder or Delphi and would like to access the NAG C Library Mark 26 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 for Applications and CLW3226DEL
- Headers for use with Visual Basic .NET and CLW3226DEL
- Headers for use with 64-bit Visual Basic for Applications 7.0 (VBA7) and CLW6I26DEL
- Headers for use with 64-bit Visual Basic .NET and CLW6I26DEL
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_11.3.3\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.
You may also need to add the rtl\bin subfolder if the required runtime libraries are not already on your PATH.
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 (under Advanced System Settings on Windows Vista / Windows 7 / Windows 8 / Windows 10).
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 CLW3226DE_mkl.lib, so it is not necessary to specify the MKL import libraries subfolder (.\MKL_ia32_11.3.3\lib) as well.
With the version of Intel MKL supplied, if the environment variable OMP_NUM_THREADS is undefined, MKL may create multiple threads to speed up computation on systems with more than one processor or a multicore chip. If you do not want MKL to make use of multiple cores or processors, OMP_NUM_THREADS must be set to 1. On most systems setting this environment variable may be effected using the Environment Variables button on the Control Panel | System | Advanced tab (under Advanced System Settings on Windows Vista / Windows 7 / Windows 8 / Windows 10).
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.
Note that the NAG C Library DLLs supplied with CLW3226DEL use the __stdcall calling convention for function calls.
Learn more about the NAG DLLs.