https://github.com/secana/native-fsharp-library
Create a DLL in F# that can be called by native C++
https://github.com/secana/native-fsharp-library
corert cplusplus dotnet dotnet-core dotnetcore fsharp
Last synced: 2 months ago
JSON representation
Create a DLL in F# that can be called by native C++
- Host: GitHub
- URL: https://github.com/secana/native-fsharp-library
- Owner: secana
- License: apache-2.0
- Created: 2020-02-01T15:40:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-01T22:16:07.000Z (over 5 years ago)
- Last Synced: 2025-04-05T10:51:09.049Z (3 months ago)
- Topics: corert, cplusplus, dotnet, dotnet-core, dotnetcore, fsharp
- Language: F#
- Size: 13.7 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Native F# Library
This example shows, how you can build an native Windows x64 DLL with *F#* that can be called from native *C++* code.
Blog post which explains how it works: [Writing a native library in F# which can be called from C++](https://secanablog.wordpress.com/2020/02/01/writing-a-native-library-in-f-which-can-be-called-from-c/)
The example is based on the *C#* version by *Muhammad Azeez* which can be found here: [Writing native libraries in C#](https://mazeez.dev/posts/writing-native-libraries-in-csharp)
## Build & Run
First, the native library has to be build from the *F#* project *NativeLib* in the *src* folder.
Switch to the *NativeLib* folder and run:```powershell
> dotnet publish /p:NativeLib=Shared -r win-x64 -c Release
```This creates a native library under `$(SolutionDir)src\NativeLib\bin\Release\netstandard2.0\win-x64\native`.
Now, you can build and run the *Console C++* application in *Visual Studio*, which will use the *NativeLib.dll* written in *F#*.
The output will be:
```powershell
3
Hello World!
```