I want to know if there any possibility to import/open DLLs in F# (binary, not script).
open SDL2
open ...
opens a namespace/module. It does not reference an assembly.
Assuming you are intending to use a C#/.NET version of SDL2 you will need to reference that assembly. If it is available as a nuget package, then you can add it as a dependency in visual studio(manage nuget packages
in dependencies context menu) or use the following command line dotnet add package <packagename>
. If it is not a nuget package, then you can still reference the assembly directly. In visual studio you should be able to select add project reference
in the dependencies context menu after which you can select browse to select the dll you want to use.
You can also add DLL file directly to your project file. First copy DSL2.dll
into a know location such as lib
folder inside project folder (with dependencies if needed), then edit project file to include the following:
<ItemGroup>
<Reference Include="SDL2"> <!--the name here can be anything-->
<HintPath>lib\SDL2.dll</HintPath>
</Reference>
</ItemGroup>
After that you should be able to open the namespace(open SDL2
) or directly call the various functions/types by using its fully qualified name(e.g. let x = SDL2.SDL.SDL_...
)