# Dynamically Linked Library (DLL) or Shared Object (SO)

MotionSolve supports two separate levels of user DLLs/SOs and the algorithm attempts to resolve the symbols, starting from the most specific library. It is possible to specify an Element Level DLL/SO (most specific) and a Machine Level DLL/SO.

They can be defined as follows:
1. Element level - Specify the name of the DLL/SO in the element definition. For example:
<Constraint_Coupler
id                  = "1"
label               = "TwoJoint"
joint1_id           = "30603030"
joint2_id           = "30602031"
freedom_1           = "T"
freedom_2           = "T"
usrsub_param_string = "USER(-8.5)"
usrsub_dll_name     = "C:/work/testsub.dll"
usrsub_fnc_name     = "coupler_function" >
</Constraint_Coupler>
The usrsub_dll_name argument defines C:/work/testsub.dll as the element level DLL/SO for this coupler element. Any element can be defined pointing to a different DLL/SO.
2. Machine-level DLL/SO

You can create an environment variable called MS_USERSUBDLL and set it to the DLL/SO file. This environment variable is not defined automatically when MotionSolve is installed. However, Fortran and C/C++ DLLs/SOs are provided in the installation in folder <install-path>\hwsolvers\usersub\subdll\<platform>. This is so you can run some of the test models that use user subroutine DLLs.

The selection of what DLL/SO is loaded and used is based on the "most specific" rule: number one overrides number two.