fluent 编译udf报错link : fatal error lnk1104: cannot open fi
udf吧
全部回复
仅看楼主
level 1
#在fluent里面编译UDF失败, 报错信息如下所示。
解决方案,网上很多经验贴,不胜其烦。
visual studio装了又卸载,卸了又安装。环境变量也添加了,也确保visual studio和fluent装在了同一个盘。然而,然而不解的是,按照Functions-Compiled-souece file name(选择自己的UDF文件,例如filename.c)-Build。还是会报错。
解决方案!!!最后发现!!!UDF里面的中文注释似乎有影响,把注释删除,然后Functions-Interpreted-souece file name(选择自己的UDF文件,例如filename.c)-Interpret。这个时候UDF文件就能正常读取并使用了。
下图是interpret之后的信息:
这是built报错的信息:
“scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\DHF\condensation work restart\example\libudf\win64\2ddp_node\SConstruct", line 20, in <module>
Compiler path: "C:\PROGRA~1\ANSYS2~2\ANSYSI~1\v231\fluent"\ntbin\clang\bin\clang-cl
Linker path: "C:\PROGRA~1\ANSYS2~2\ANSYSI~1\v231\fluent"\ntbin\clang\bin\lld-link
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\DHF\condensation work restart\example\libudf\win64\2ddp_node\SConstruct", line 156, in <module>
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 296: illegal multibyte sequence:
File "C:\DHF\condensation work restart\example\libudf\win64\2ddp_node\SConstruct", line 180:
generate_udf_source(t, s, env)
File "C:\DHF\condensation work restart\example\libudf\win64\2ddp_node\SConstruct", line 91:
for line in f:
Done.”
2023年12月21日 19点12分 1
level 1
也可能是环境变量没有设置好。
UDF 环境变量配置
首先测试环境变量是否设置正确,编写一个
正确的
UDF文件进行测试。
Add… →选中my_udf.c文件→Build
Console 界面里面出现以下信息表示环境变量配置成功:
如果出现如下命令:
或者是下面的信息。
scons: warning: No version of Visual Studio compilerfound - C/C++ compilers most likely not set correctly
File"C:\UDF_temp\libudf\win64\3ddp_node\SConstruct", line 156, in<module>
C sources: ['my_udf.c']
这个时候就需要设置环境变量了。
我的是Fluent2023+Visualstudio2022
找到visualstudio的安装路径,和udf.bat文件
直接双击可能打不开,需要更改扩展名udf.bat→udf.c,或者udf.txt
双击打开做如下更改:将visual studio的安装路径复制替换,然后保存
Ctrl+S保存,然后再将扩展名改为udf.bat
确保勾选这个setupcompilation Environment for UDF.
重新启动fluent。
2023年12月28日 20点12分 2
level 1
以上解决方法来源于两篇公众号。可以复制后浏览器打开
带你迈过Fluent UDF学习的第一道门槛 https://mp.weixin.qq.com/s/8BU9CrS30tONziqaEgR7-w
让网格动起来 | (五)配置UDF编译环境 https://mp.weixin.qq.com/s/tWZH5ASl4j5xW7UfN_XLvQ
2023年12月29日 03点12分 3
level 1
我也试试,我中文注释有很多,一运行,就退出
2024年08月01日 03点08分 4
1