Setting environment variables for compiling User-Defined Functions ( UDFs ) in Windows


One needs to install Microsoft C compiler in order to be able to compile UDFs in Windows. Microsoft Visual Studio Express with C/C++ compiler is freely available from Microsoft website. In addition, Microsoft Windows Software Development Kit needs to be installed as well. This piece of software is also available from Microsoft website.

Once the above pieces of software are installed one need to set up the environment variables such that the compiler becomes "visible" from every launched session of ANSYS FLUENT.

The step required are as follows:

1) Open a usual DOS Prompt in windows: Start -> Run -> type in 'cmd' (in Windows XP) or Start -> type in 'cmd' in the search line in Windows 7;
2) Print the environment variables into a file by typing: set > original_environment.txt
3) Note the location of that file

4) Open the SDK CMD shell: Start -> All Programs -> Microsoft Windows SDK -> CMD Shell
5) Print the environment variables onto a file by typing: set > sdk_environment.txt
6) Note the location of this second file.

7) Launch the WinDiff utility by going into Start -> All Programs -> Microsoft Windows SDK -> Tools -> WinDiff
8) In WinDiff go and compare the files created in steps (b) and (e)
9) Note the differences of sdk_environment.txt from original_environment and copy them into a separate file environment_differences.txt. There will be a few differencec but the most important ones are

"Include=..;",
"Lib=...;",
"Path=..."

For example, they might look similar to:
===========================================================
INCLUDE=C:Program Files (x86)Microsoft Visual Studio 9.0Include;C:Program Files (x86)Microsoft Visual Studio 9.0VCInclude;C:Program FilesMicrosoft SDKsWindowsv6.1Include;C:Program FilesMicrosoft SDKsWindowsv6.1Includegl;
===========================================================
LIB=C:Program Files (x86)Microsoft Visual Studio 9.0VCLibamd64;C:Program FilesMicrosoft SDKsWindowsv6.1Libx64;
===========================================================
Path=C:Program Files (x86)Microsoft Visual Studio 9.0VCBinamd64;C:Program Files (x86)Microsoft Visual Studio 9.0VCvcpackages;C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDE;C:Program FilesMicrosoft SDKsWindowsv6.1Binx64;C:Program FilesMicrosoft SDKsWindowsv6.1Bin;C:WINDOWSMicrosoft.NETFramework64v3.5;C:WINDOWSMicrosoft.NETFrameworkv3.5;C:WINDOWSMicrosoft.NETFramework64v2.0.50727;C:WINDOWSMicrosoft.NETFrameworkv2.0.50727;
===========================================================

The above lines show the differencies between original_environment.txt & sdk_environment.txt

10) Create environment variable INCLUDE if it does not exist already. If the environment variable INCLUDE exists already then please extend it add the differences in the INCLUDE variable between original_environment.txt and sdk_environment.txt

11) Create environment variable LIB if it does not exist already. If the environment variable LIB exists already then please extend it add the differences in the LIB variable between original_environment.txt and sdk_environment.txt

12) Note the difference in the "Path" environment variable in two files and modify the existing "Path" environment variable.

NOTE: To modify the environment variable please open the

Start -> Control Panel -> System -> Advanced System Settings -> Environment Variables:
Under "System variables" please press "New" to create "LIB" and "INCLUDE" variables. If the LIB and INCLUDE directories exist already then please they need editing in accord with the relevant differencies between original_environment.txt and sdk_environment.txt. The environment variable "Path" would already exist and, therefore, it will need editing to account for the difference between original_environment.txt and sdk_environment.txt.

The environment variable for Compiler is now set. To check this, please type in "nmake" into the standard DOS prompt as well as into the SDK DOS prompt and you should get the same message. Please note that you will need to close the old prompts and open them again for the change of the environment varialbes to become effective.

The UDFs can be compiled now from any open FLUENT session





Show Form
No comments yet. Be the first to add a comment!