Fluids

Fluids

UDF compilation problem

    • Arianna
      Subscriber

      Hello everyone!
      I am working to write a UDF that uses external functions to parse a .json file and read velocity data to impose at a domain boundary.
      The UDF uses a DEFINE_PROFILE macro. All the headers needed (such as json.h) are included at the beginning of the file.
      I launch fluent through Visual Studio as per regular UDF compilation.
      However, I get this error:
      udf.obj: error LNK 2019: unresolved external symbol

      The error refers to the symbols I’m using to parse the .json file and its structure.
      It is definitely a linker/compilation error but I can’t figure out how to fix it or if I am missing a compilation step.

      Does anyone know how to solve this issue or have experience with a similar error?

      Thank you in advance for any suggestion or help!

    • DrAmine
      Ansys Employee
      Include the header file in the compilation procedure.
    • Arianna
      Subscriber

      Dear Amine,


      thank you for your reply! The header file is included (#include) at the top of the UDF file. 


      I am trying to precomile in visual studio cmd now, with nmake as described here https://www.afs.enea.it/project/neptunius/docs/fluent/html/udf/node133.htm. I am also including this line in the make file:


      LIBS = json-c.lib


      link $(LIBS)/dll/debug/out:$(TARGET) $(OBJECTS) $(FLUENT_LIB) $(GPU_LIB)


       


      this actually seemed to solve the LNK error. The compilation goes through and the final output is:


      # Linking libudf.dll because of makefile user_ntf.udf udf_names.obj boundary_condition.obj


      However the libudf.dll file is not created in the folder, and that is what I would need in order to load the UDF in Fluent. DO you have any suggestion?


       


      Thank you again for your help and availability!


      Best,


      Arianna

    • DrAmine
      Ansys Employee
      In the compile window add header files. That is all what I can now say on this open community.
    • Arianna
      Subscriber

      Hi Amine,


      Thank you again for following up! 


      I just tried what you suggested, I get the same error LNK2019.


      Going through precompilation as described in the link I shared seems the best way so far. Do you have any suggestion about precompiling in order to generaet the libudf.dll file that can then be loaded through user-defined>functions>manage?


      Thank you again for your help!

    • DrAmine
      Ansys Employee
      I guess some env variables have not been set and that is why you require running from VS command prompt. Please follow this first

      1/compile dummy udf directly in Fluent does it work if not
      2/compile from x64 cross VS prompt it should work. Now get the list of environment variables and compare it to the list you get from NORMAL windows command prompt. Focus on Inckude Lib and Path env variables.
    • Arianna
      Subscriber

      Hi Amine,


      Thank you again for your help and time!


      I believe the enviromental variables have been properly set because I can successfully compile other simple UDFs in Fluent.


      I think I didn't explain my problem in the right way. In this specific UDF I'm trying to include external functions to read .json files. I am not required to compile from VS command prompt, the reason why I'm doing that is because I'm trying to pre-compile the UDF and then load it in Fluent (as described here  https://www.afs.enea.it/project/neptunius/docs/fluent/html/udf/node133.htm and here https://www.researchgate.net/post/How_to_configure_ANSYS_Fluent_UDF_makefile_for_linking_to_a_static_library_lib) so that I can include external libraries. 


      The issue I'm running into is that the precomplilation in VS command prompt goes through and the final output is:


      # Linking libudf.dll because of makefile user_ntf.udf udf_names.obj boundary_condition.obj 


      but the libudf.dll and libudf.lib files are not generate in the folder. It is a very specific problem I guess, do you have any suggestion?


      Thank you again, I really appreciate your help!


      Arianna

    • DrAmine
      Ansys Employee
      Then please check more actual help documentation.
Viewing 7 reply threads
  • You must be logged in to reply to this topic.