CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Trouble with compiling UDFs in FLUENT

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 22, 2014, 15:03
Default Trouble with compiling UDFs in FLUENT
  #1
New Member
 
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13
cp703 is on a distinguished road
Hi everyone,

I know that this topic has been covered to death on this forum, but I'm still having a lot of trouble with it and would really appreciate any input. I am using ANSYS 14.0 and I have a couple different versions of Microsoft Visual Studio installed on my computer (Microsoft Visual Studio 2012, 2012 express for desktop and 213 express for desktop) since I'm not sure which is the most appropriate for my system as far as compatibility. My operating system is Windows 7 (64 bit). I'm not super familiar with Windows OS's so let me know if this is not enough information!

I've been going through the Horizontal Film Boiling tutorial provided by ANSYS. This process is presented as straightforward in the tutorials, but I have been seeing a lot of people struggle with it. As of right now, when I try to compile the boiling.c UDF, I get an error that says:

’nmake’ is not recognized as an internal or external command, operable program, or batch file.

I looked around online (mostly this forum) and found that this problem tends to stem from a lack of communication between the C compiler (Microsoft Visual Studio?) and FLUENT. I have tried a few things to rectify this problem with mixed success:

1. The FLUENT FAQ here has a list of things to do to get UDFs to compile on Windows 7 x64 systems. I went through the process of adding "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin;C:\Program Files\ANSYS Inc\v120\fluent\ntbin\win64" to the Path system variable as instructed. Unfortunately after doing this, I still got the 'nmake' error.

2. I found many, many recommendations to start FLUENT through Visual Studio’s command prompt. I did that (both with and without the added locations to the Path system variable) and the 'nmake' error went away but then I was running into different errors " error LNK2019: unresolved external symbol" for several different variables in the UDF. Right not I'm not able to reproduce this error because I can't seem to get FLUENT to run from my MSVS command prompt anymore.

At this point, I have not been able to find a satisfactory solution to my problems. I get the feeling that it is stemming from my lack of understanding about the relationship between MSVS and SDK and FLUENT. I don't really understand why I need an SDK installed in addition to MSVS or what MSVS's actual role is in the whole process of compiling within FLUENT. Does anyone have any thoughts or resources they can point me to? Thank you!

The experience documented by user trollreign is very similar to what I've been experiencing, though he/she does not seem to have had any of the LNK2019 errors as I have:
http://www.cfd-online.com/Forums/blo...pile-udfs.html
If I can figure out what's going on for me, I would love to do a similar blog post just to get the info out there for people!
cp703 is offline   Reply With Quote

Old   January 23, 2014, 05:06
Default how to solve nmake problems
  #2
New Member
 
Happy_weekend
Join Date: Jan 2014
Posts: 21
Rep Power: 12
Messi is on a distinguished road
I once also met the problems like you. visual studio 2012 is ok for fluent 14.0.

I think you need to add some system variables to your computer, not only path.
Generally, there are four variables needed to be added, inclued, lib, path, and libpath.

The values of them are listed as follows. I think you need to change the related address because these files may be in different addresses.
name: Include

value: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include

Second:

name: Lib

value: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\lib;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib

Third:

name: Libpath

value: C:\Windows\Microsoft.NET\Framework64\v3.5;C:\Windo ws\Microsoft.NET\Framework64\v2.0.50727;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\lib;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib


Fourth:

name: Path

value: C:\Program Files\ANSYS Inc\v140\fluent\ntbin\win64;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Windows\Microsoft.NET\Framework64\v3 .5;C:\Windows\Microsoft.NET\Framework64\v2.0.50727 ;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin

After you have done this, the nmake problem can be solved.

Good Luck!
jyothsna k likes this.
Messi is offline   Reply With Quote

Old   January 23, 2014, 10:44
Default
  #3
New Member
 
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13
cp703 is on a distinguished road
Thank you so much for responding! I did as you recommended and you were right - I did have to change some of the folder names like the Visual Studio version (from 9.0 to 12.0) and the Windows SDKs version (from 6.0A to 7.1A). I was not able to find the following folder anywhere:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc

So I left that value out of the Include, Lib, and Libpath variables. I went to compile the UDF with the defined/updated system variables and I didn't get the 'nmake' error! That's pretty refreshing! Unfortunately, I got hit with a whole new set of errors that I can make NO sense of:

Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(482) : error C2059: syntax error : ','
Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(482) : error C2143: syntax error : missing ')' before 'constant'
Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(482) : error C2143: syntax error : missing '{' before 'constant'
Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(482) : error C2059: syntax error : 'constant'
Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\math.h(482) : error C2059: syntax error : ')'

It doesn't seem appropriate for me to go into that math.h header file and change things since it came with MSVS. I'm wondering if it has to do with the file path that I left out because I couldn't find it. I will try to look around!


Quote:
Originally Posted by Messi View Post
I once also met the problems like you. visual studio 2012 is ok for fluent 14.0.

I think you need to add some system variables to your computer, not only path.
Generally, there are four variables needed to be added, inclued, lib, path, and libpath.

The values of them are listed as follows. I think you need to change the related address because these files may be in different addresses.
name: Include

value: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include

Second:

name: Lib

value: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\lib;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib

Third:

name: Libpath

value: C:\Windows\Microsoft.NET\Framework64\v3.5;C:\Windo ws\Microsoft.NET\Framework64\v2.0.50727;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\lib;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib


Fourth:

name: Path

value: C:\Program Files\ANSYS Inc\v140\fluent\ntbin\win64;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Windows\Microsoft.NET\Framework64\v3 .5;C:\Windows\Microsoft.NET\Framework64\v2.0.50727 ;C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin

After you have done this, the nmake problem can be solved.

Good Luck!
cp703 is offline   Reply With Quote

Old   January 23, 2014, 11:57
Default
  #4
New Member
 
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13
cp703 is on a distinguished road
Oh my goodness! I got it to work! It's a miracle! For you future people searching desperately for a solution to your UDF compiling issues:

1. I updated the Path variable as instructed by user Messi.
2. I added new variables Include, Lib, and Libpath variables as instructed by user Messi.
3. I used the VS2012 x64 Cross Tools Command Prompt to open FLUENT (after first navigating to my working directory). ***THIS DID NOT WORK WITH ANY OTHER COMMAND PROMPT I TRIED!***
cp703 is offline   Reply With Quote

Old   January 28, 2014, 06:35
Default
  #5
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
Quote:
Originally Posted by cp703 View Post
Oh my goodness! I got it to work! It's a miracle! For you future people searching desperately for a solution to your UDF compiling issues:

1. I updated the Path variable as instructed by user Messi.
2. I added new variables Include, Lib, and Libpath variables as instructed by user Messi.
3. I used the VS2012 x64 Cross Tools Command Prompt to open FLUENT (after first navigating to my working directory). ***THIS DID NOT WORK WITH ANY OTHER COMMAND PROMPT I TRIED!***
Hi guys,

I have fluent 14 on win 7 OS. I have Visuald Studio from 2008 to 2012 installed.
I've been dealing with the x64 system problem exposed by trollreign in http://www.cfd-online.com/Forums/blo...pile-udfs.html
Error message:

Code:
Opening library "c:\users\<working directory>libudf"... Error: The UDF library you are trying to load (C:\Users\<working directory>\libudf) is not compiled for 3d on the curent platform (win64).
Even if I started from VS2012 x64 Cross Tools Command Prompt I continued to get the same error.
I then decided to update environment variables as exposed by Messi in http://www.cfd-online.com/Forums/flu...tml#post471365
I changed SDK version from 6.0A to 7.1A and VS from 2009 to 2011 (I haven't been able to find a VS2012 folder in my pc, even if I have it correctly installed.)
I started from VS2012 x64 Cross Tools Command Prompt and I get this error:
Code:
c:\program files\ansys inc\v140\fluent\fluent14.0.0\src\global.h(10) : fatal error C1083: Cannot open the include archive: 'stdio.h': Invalid argument
And the again the former (win64 libudf) error.

What can be wrong? I've also tried the other command prompts in VS2012 with similar result. I've tried serial and parallel modes.

What can I try next?

Please help, I'm in a hurry.

Thanks a lot!!
Bollonga is offline   Reply With Quote

Old   January 28, 2014, 09:12
Default
  #6
New Member
 
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13
cp703 is on a distinguished road
When you say you're starting from MSVS Command Prompt, what exactly are you typing into the command prompt?


Quote:
Originally Posted by Bollonga View Post
Hi guys,

I have fluent 14 on win 7 OS. I have Visuald Studio from 2008 to 2012 installed.
I've been dealing with the x64 system problem exposed by trollreign in http://www.cfd-online.com/Forums/blo...pile-udfs.html
Error message:

Code:
Opening library "c:\users\<working directory>libudf"... Error: The UDF library you are trying to load (C:\Users\<working directory>\libudf) is not compiled for 3d on the curent platform (win64).
Even if I started from VS2012 x64 Cross Tools Command Prompt I continued to get the same error.
I then decided to update environment variables as exposed by Messi in http://www.cfd-online.com/Forums/flu...tml#post471365
I changed SDK version from 6.0A to 7.1A and VS from 2009 to 2011 (I haven't been able to find a VS2012 folder in my pc, even if I have it correctly installed.)
I started from VS2012 x64 Cross Tools Command Prompt and I get this error:
Code:
c:\program files\ansys inc\v140\fluent\fluent14.0.0\src\global.h(10) : fatal error C1083: Cannot open the include archive: 'stdio.h': Invalid argument
And the again the former (win64 libudf) error.

What can be wrong? I've also tried the other command prompts in VS2012 with similar result. I've tried serial and parallel modes.

What can I try next?

Please help, I'm in a hurry.

Thanks a lot!!
cp703 is offline   Reply With Quote

Old   January 28, 2014, 09:55
Default
  #7
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
Quote:
Originally Posted by cp703 View Post
When you say you're starting from MSVS Command Prompt, what exactly are you typing into the command prompt?
I type: c:\Program Files\Ansys inc\v140\fluent\ntbin\win64 fluent

But I see now there's some message in the Command Prompt before I write anything:

ERROR: Cannot determine the location of the VS Common Tools Folder.

Can this be related to my problem? I guess it does. How can I solve it?

Thanls a lot!
Bollonga is offline   Reply With Quote

Old   January 28, 2014, 10:15
Default
  #8
New Member
 
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13
cp703 is on a distinguished road
Okay here's what I did.

cd C:\filmboiling
(this is changing the directory to my working directory, the folder containing my mesh file and my .c file)

fluent
(this opens up the FLUENT launcher directly, and you can see under the General Options that the working directory has been changed accordingly)

Then I followed the instructions for compiling a UDF and it works fine. Is that how you did it?
cp703 is offline   Reply With Quote

Old   January 28, 2014, 10:18
Default
  #9
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
Quote:
Originally Posted by cp703 View Post
Okay here's what I did.

cd C:\filmboiling
(this is changing the directory to my working directory, the folder containing my mesh file and my .c file)

fluent
(this opens up the FLUENT launcher directly, and you can see under the General Options that the working directory has been changed accordingly)

Then I followed the instructions for compiling a UDF and it works fine. Is that how you did it?
No, I don't refer to my working directory. I'm gonna try your way and let you know the result. Thanks.
Bollonga is offline   Reply With Quote

Old   January 28, 2014, 10:24
Default
  #10
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
I get the same error even if I type my working directory.
Bollonga is offline   Reply With Quote

Old   January 28, 2014, 10:32
Default
  #11
New Member
 
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13
cp703 is on a distinguished road
Okay, I was looking over trollreign's blogpost again and the error you're getting about libudf not being compiled for 3d on the current platform seems like a 64 bit problem? You didn't mention in your original post if your copies of MSVS for 64 bit - are they? Maybe that's the problem.

As you can see I am in no way an expert on this kind of stuff so if anyone else wants to chime in, please do!
cp703 is offline   Reply With Quote

Old   January 28, 2014, 10:52
Default
  #12
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
Quote:
Originally Posted by cp703 View Post
Okay, I was looking over trollreign's blogpost again and the error you're getting about libudf not being compiled for 3d on the current platform seems like a 64 bit problem? You didn't mention in your original post if your copies of MSVS for 64 bit - are they? Maybe that's the problem.
I downloaded MSVS2012from this link,I think it is 64 bits, however it is installed in Program Files (x86).

http://www.microsoft.com/en-us/downl....aspx?id=30678

Do you have the error message when you start your command prompt?

ERROR: Cannot determine the location of the VS Common Tools folder.
Bollonga is offline   Reply With Quote

Old   January 28, 2014, 11:03
Default
  #13
New Member
 
Christina P.
Join Date: Oct 2012
Posts: 22
Rep Power: 13
cp703 is on a distinguished road
No, I never got that error. That might be the problem! What does the Path variable value look like in your system variables? Maybe one of your folder locations got messed up.
cp703 is offline   Reply With Quote

Old   January 28, 2014, 13:15
Default
  #14
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
My environment variables are the followings, I've checked that every folder really exist in my pc:

Code:
name: include

value: C:\Program Files\Microsoft SDKs\Windows\v7.1A\Include;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include



name: lib

value: C:\Program Files\Microsoft SDKs\Windows\v7.7A\Include;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include



name:libpath

value: C:\Windows\Microsoft.NET\Framework64\v3.5;
C:\Windows\Microsoft.NET\Framework64\v2.0.50727;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\lib;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib




name: path

value: C:\Program Files\ANSYS Inc\v140\fluent\ntbin\win64;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin;
C:\Windows\Microsoft.NET\Framework64\v3.5;
C:\Windows\Microsoft.NET\Framework64\v2.0.50727;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcpackages;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools;
C:\Program Files\Microsoft SDKs\Windows\v7.1A\Bin\x64;
C:\Program Files\Microsoft SDKs\Windows\v7.1A\Bin
I don't know why I don't have a VS2012 folder, just a 2011 one so that's why I've chosen this one for the environment variables.
Bollonga is offline   Reply With Quote

Old   January 30, 2014, 05:13
Default
  #15
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
It looks like I have some trouble with my SDK and VS2012. When I try to execute the Windows SDK Command Prompt it appears an error message:

Code:
The x64 compilers are not currently installed
Please go to add/remove programs to update the installation.

Setting SDK environments relative to C:Program Files\Microsoft SDKs\Windows\v7.0

El sistema no encuentra la etiqueta por lotes especificada: Set_x64
I've tried to repair the SDK, uninstall-reinstall, install an update (http://www.microsoft.com/en-us/downl...s.aspx?id=4422) but nothing works.

How can I solve my sdk problem? Which versions of SDK, V and c++ compiler should I try? Anything that works!

Thanks.
Bollonga is offline   Reply With Quote

Old   January 30, 2014, 10:52
Default
  #16
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
I solved the SDK issue, now I have SDK 7.1. I've installed a patch and now there's no message of x64 compilers on the SDK 7.1 command prompt.

But, neither I start from SDK command prompt nor VS2012 command prompt my udf is able to be compiled. Always the same messege:

Code:
fatal error 1083: cannot open the file include: stdio.h invalid argument

Error: The UDF library you are trying to load (libudf) is not compiled for 3d on the curent platform (win64).
Any idea why this happens?

Cp703 which is your setup? which are the Visual Studio and SDK versionsworking for you? SDK 7.1 ans MS VS 2012 Ultimate?
Should I uninstall former versions of this softwares? Which environment variable should I choose?

Thank you!
Bollonga is offline   Reply With Quote

Old   January 30, 2014, 11:12
Default
  #17
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
Quote:
Originally Posted by Bollonga View Post
But I see now there's some message in the Command Prompt before I write anything:

ERROR: Cannot determine the location of the VS Common Tools Folder.

Can this be related to my problem? I guess it does. How can I solve it?

Thanls a lot!
The error message on the VS2012 command prompt is already solved.

I've gone on and there's a new error when building:

Code:
inlet_x_profile.c(23) : error C2064: term does not evaluate to a function taking 1787 arguments
I guess it's an error in line 23 of my inlet_x_profile.c fucntion, right?

And then there's the persistent x64 error when compiling.
Bollonga is offline   Reply With Quote

Old   January 31, 2014, 03:06
Default
  #18
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15
Bollonga is on a distinguished road
Quote:
Originally Posted by Bollonga View Post

I've gone on and there's a new error when building:

Code:
inlet_x_profile.c(23) : error C2064: term does not evaluate to a function taking 1787 arguments
I guess it's an error in line 23 of my inlet_x_profile.c fucntion, right?

And then there's the persistent x64 error when compiling.
Well I got it! This last error was just a ";" missing on my code, and now I've built and compiled it without any errors starting it from the SDK 7.1 command prompt.

Thank you cp703 for your help!
Bollonga is offline   Reply With Quote

Old   March 10, 2014, 12:02
Default Error
  #19
New Member
 
Afshin
Join Date: Mar 2014
Posts: 2
Rep Power: 0
Afshin2008 is on a distinguished road
Hello Experts

I followed all the instructions mentioned, however when I compile the udf file I get the following error:

Opening library "D:\WS7b\libudf"...
Error: The UDF library you are trying to load (libudf) is not compiled for 2ddp on the current platform (win64).

The system cannot find the file specified.

I should mention that among all the values mentioned by messi there is one that I cannot find : c:\Program files(x86)\Microsoft SDKs\Windows\V7.0A\Include

Your help is highly appreciated.
Afshin
Afshin2008 is offline   Reply With Quote

Old   March 10, 2014, 12:04
Default
  #20
New Member
 
Afshin
Join Date: Mar 2014
Posts: 2
Rep Power: 0
Afshin2008 is on a distinguished road
One more

I'm using ANSYS 15 and Windows 7 Ultimate, I installed VS2012,

Thanks
Afshin
Afshin2008 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Environment variables- to solve problems in compiling UDF in Fluent Modest Cat Fluent UDF and Scheme Programming 39 May 18, 2016 10:33
Error while compiling udf in fluent 13.0.0 siddharth12 FLUENT 0 December 3, 2013 16:46
Possible Bug in pimpleFoam (or createPatch) (or fluent3DMeshToFoam) cfdonline2mohsen OpenFOAM 3 October 21, 2013 09:28
Compiling UDFs under Windows XP Hannah FLUENT 3 February 13, 2005 08:16
Compiling and Running UDFs on an IBM Power3 S. Hollman FLUENT 0 January 6, 2005 11:23


All times are GMT -4. The time now is 22:54.