5.6. Common Errors When Building and Loading a UDF Library

A common compiler error occurs when you forget to put an #include "udf.h" statement at the beginning of your source file. You’ll get a long list of compiler error messages that include illegal declarations of variables. Similarly, if your function requires an auxiliary header file (for example, sg_pdf.h) and you forgot to include it, you’ll get a similar compiler error message.

Another common error occurs when the argument list for a DEFINE statement is placed on multiple lines. (All DEFINE macro arguments must be listed on the same line in a C file.) The compiler will typically not report any error message but it will report a single warning message in the log file to indicate that this occurred:

  warning: no newline at end of file

If your compiled UDF library loads successfully, then each function contained within the library will be reported to the console (and log file). For example, if you built a shared library named libudf containing two user-defined functions superfluid_density and speed_sound, a successful library load (on a Linux machine) will result in the following message being reported to the console (and log file):

 Opening library "libudf"...
 Library "path/libudf/lnamd64/3d_node/libudf.so" opened
   superfluid_density
   speed_sound 
Done. 

If, instead, no function names are listed, then it is likely that your source file did not successfully compile. In this case, you must consult the log to view the compilation history, and debug your function(s). Note that you must unload the UDF library using the UDF Library Manager dialog box before you reload the debugged version of your library.

Another common error occurs when you try to read a case file that was saved with a shared library, and that shared library has subsequently been moved to another location. In this case, the following error will be reported to the console (and log file) on a Linux machine:

 Opening library "path/libudf"...
 Error: No such file or directory:
 path/libudf/lnamd64/3d_node/libudf.so  

Similarly, you will get an error message when you try to load a shared library before it has been built.

 Error: UDF library "libudf" not available at path 

For more information, see the following section:


Note:  If you have a source file that contains DOS-style line endings, before you can compile the source file in ANSYS Fluent on Linux, you must first run the dos2unix utility (for example, dos2unix filename.c) in the command line in order to make the source file compatible with the ANSYS Fluent Linux compiler.



Release 18.2 - © ANSYS, Inc. All rights reserved.