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

[Help] Error complier UDF Fluent C++

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 1 Post By pakk
  • 1 Post By AlexanderZ
  • 1 Post By pakk
  • 2 Post By SSG_NJ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 28, 2021, 09:43
Default [Help] Error complier UDF Fluent C++
  #1
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Hi Guys! I'm a student. I tried defining the UDF properties of steam follow IF97. But When I Complier I Had an error :


\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\src\u e -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\s rc\dpm -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\s rc\dbns -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\c ortex\src -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\c lient\src -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\t grid\src -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\m ultiport\src -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\fluent21.1.0\m ultiport\mpi_wrapper\src -I"C:\PROGRA~1\ANSYSI~1\v211\fluent"\include ..\..\src\testif97.cpp ..\..\src\IF97.h
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

cl : Command line warning D9024 : unrecognized source file type '..\..\src\IF97.h', object file assumed
cl : Command line warning D9027 : source file '..\..\src\IF97.h' ignored
testif97.cpp
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\sys/stat.h(239): error C2375: '_stat64i32': redefinition; different linkage
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\sys/stat.h(185): note: see declaration of '_stat64i32'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.EXE"' : return code '0x2'
Stop.

Done.


Can you help me fix it?. Thankfully!


cudau.95 is offline   Reply With Quote

Old   July 28, 2021, 13:16
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
What is in IF97.h?

Normally, I never add a header file...
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   July 28, 2021, 22:08
Default
  #3
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by pakk View Post
What is in IF97.h?

Normally, I never add a header file...
I already copied the header file to the \fluent\fluent21.1.0\src folder. But when I compile I still get the following error:

Code:
testif97.cpp
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\sys/stat.h(239): error C2375: '_stat64i32': redefinition; different linkage
C:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt\sys/stat.h(185): note: see declaration of '_stat64i32'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.EXE"' : return code '0x2'
Stop.

cudau.95 is offline   Reply With Quote

Old   July 29, 2021, 00:52
Default
  #4
Senior Member
 
rupak504's Avatar
 
Lolita
Join Date: Aug 2016
Posts: 118
Rep Power: 10
rupak504 is on a distinguished road
its showing Nmake error, why don't you try in-built compiler
rupak504 is offline   Reply With Quote

Old   July 29, 2021, 02:32
Default
  #5
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by rupak504 View Post
its showing Nmake error, why don't you try in-built compiler
it got the following error:

cudau.95 is offline   Reply With Quote

Old   July 29, 2021, 02:58
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Have you successfully compiled UDFs in the past, or is this the first time you try it (on this computer)?
cudau.95 likes this.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   July 29, 2021, 03:19
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
looks like there is some problem with compiler, may be x32 x64 version problem
cudau.95 likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 29, 2021, 05:14
Default
  #8
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Have you successfully compiled UDFs in the past, or is this the first time you try it (on this computer)?
Thank you! This is the first time I compiling.

This is my file. please help me compile it.

udf.zip
cudau.95 is offline   Reply With Quote

Old   July 29, 2021, 05:17
Default
  #9
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
looks like there is some problem with compiler, may be x32 x64 version problem
Let me know How do I fix that? Thankfully!
cudau.95 is offline   Reply With Quote

Old   July 29, 2021, 06:58
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by cudau.95 View Post
Thank you! This is the first time I compiling.

This is my file. please help me compile it.

Attachment 85631
Then first try a UDF from the manual, just to make sure your code is not the problem. You use C++, but all examples in the manual are C.
cudau.95 likes this.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   July 29, 2021, 07:22
Default
  #11
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by pakk View Post
Then first try a UDF from the manual, just to make sure your code is not the problem. You use C++, but all examples in the manual are C.

Thank you!. For the *.C file I compiled successfully. So how do I compile the *.CPP file?


cudau.95 is offline   Reply With Quote

Old   July 30, 2021, 02:43
Default
  #12
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
call your udf as *.c file and compile
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   July 30, 2021, 03:42
Default
  #13
New Member
 
Nam
Join Date: Jan 2021
Posts: 16
Rep Power: 5
cudau.95 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
call your udf as *.c file and compile
Please! Can you help me complier my udf ?

udf.zipudf.zip
cudau.95 is offline   Reply With Quote

Old   February 22, 2023, 10:29
Default Solved?
  #14
New Member
 
xicheng wang
Join Date: Sep 2019
Posts: 3
Rep Power: 7
xicheng is on a distinguished road
Hi, cudau.95

Have you finally solved this issue?

I also want to include IF97 in my UDF but meet the same error.

Best regards,
Xicheng
xicheng is offline   Reply With Quote

Old   July 6, 2023, 10:26
Exclamation Is anyone able to find a solution? Need help asap
  #15
New Member
 
Join Date: May 2020
Posts: 21
Rep Power: 6
SSG_NJ is on a distinguished road
Hi folks,

I'm trying to build and load my UDF in Fluent 2023 R1. I have tried installing Visual Studio 2019 Professional and Visual Studio 2017 Community. The error still persists.

I have compiled UDFs successfully in Fluent before and I've made necessary changes in the "Environment Variables" path in 'This PC' but to no avail. I've had faced the infamous 'nmake error' that plagues a lot of people and I managed to fix that by making the changes I mentioned earlier.

The strange part of this is that for whatever reason the UDF compiles, builds and loads with no problem on my laptop but it doesn't on my PC. I've made the exact same changes on them both, both run Windows 10, both have the same Visual Studio version (2017), with the only difference that the desktop PC has a Fluent 2023 R1 version while my laptop has Fluent 2022 R1 version.

The error I get when trying to build the UDF is:

NMAKE : U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bi n\HostX86\x64\cl.EXE"' : return code '0x2'
Stop.

The UDF is coded in 'C' and works flawlessly on my laptop so I know that the code is not the problem.

Kindly help as soon as you can ! Thanks a lot!
Attached Images
File Type: png fluent_udf_nmake_error.PNG (32.0 KB, 14 views)

Last edited by SSG_NJ; July 6, 2023 at 12:08.
SSG_NJ is offline   Reply With Quote

Old   July 6, 2023, 12:07
Default NMAKE: U1077 .... return code '0x2'
  #16
New Member
 
Join Date: May 2020
Posts: 21
Rep Power: 6
SSG_NJ is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
call your udf as *.c file and compile
Can you please see the post I made above about the same error and see if you could help me please?

I just tried with Visual Studio 2022 Community Edition but the error still persists as can be seen in the attached screenshot.

I should also mention that apart from changing the Path in Environment Variables, I also tried launching Fluent via the "Cross Tools" command prompt of Visual Studio - both x86 to x64 and x64 to x86. Even that didn't help either!
Attached Images
File Type: png fluent_udf_nmake_error2.PNG (54.7 KB, 9 views)

Last edited by SSG_NJ; July 6, 2023 at 15:26.
SSG_NJ is offline   Reply With Quote

Old   July 6, 2023, 15:23
Thumbs up Solution
  #17
New Member
 
Join Date: May 2020
Posts: 21
Rep Power: 6
SSG_NJ is on a distinguished road
I was FINALLY able to figure it out after trying out almost everything that is known.

This applies to Fluent 2023 R1 which is what I'm working on

1. Install Visual Studio 2017 Community edition (This link works as of today 6-Jul-2023: https://visualstudio.microsoft.com/t...mmunity&rel=15 ) [2019 version might also work, I'm not sure]

2. Ensure Universal Windows Platform development and Desktop development with C++ are installed in Visual Studio. These are the ONLY two main packages you need. Keep the default individual components checked and ONLY add Windows 8 SDK as the extra component (you'll find this under 'Desktop development with C++') and install and launch Visual Studio 2017

3. Restart the system (not absolutely necessary but just in case)

4. Change the UDF file extension from .c to .cpp

5. Build and load the .cpp file in Fluent

And Presto!... Fluent now compiles your code.

Took me 11 hours or so of grueling troubleshooting but it finally works!

Enjoy!
AlexanderZ and AaronFann like this.
SSG_NJ 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
how to run fluent from matlab without using aas toolbox? artemis96 ANSYS 7 May 23, 2022 13:16
Fluent UDF for moving laser heating of a solid block Cooper24 Fluent UDF and Scheme Programming 7 July 9, 2021 06:56
Problem running fluent with udf on batch tobi b. Fluent UDF and Scheme Programming 3 April 14, 2016 14:54
Running UDF with Supercomputer roi247 FLUENT 4 October 15, 2015 14:41
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 11:16


All times are GMT -4. The time now is 18:03.