Skip to content

Commit

Permalink
Add a warning to building static libraries with naot (#6651)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky authored Feb 14, 2024
1 parent 5a2c34d commit 2890083
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/nativeaot/NativeLibrary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Create a .NET class library project using `dotnet new classlib -o NativeLibrary`
## Building shared libraries

```bash
> dotnet publish /p:NativeLib=Shared --use-current-runtime
> dotnet publish --use-current-runtime
```

The above command will drop a shared library (Windows `.dll`, macOS `.dylib`, Linux `.so`) in `./bin/Release/net8.0/[RID]/publish/` folder and will have the same name as the folder in which your source file is present.
Expand Down Expand Up @@ -85,6 +85,14 @@ The sample [source code](Class1.cs) demonstrates common techniques used to stay

## Building static libraries

> [!WARNING]
> It's preferred to build shared libraries than static libraries:
>
> * All code in the loadable module must be compiled with C/C++ compiler version and options that are compatible with native AOT static libraries.
> * It's also not possible to mix multiple native AOT compiled static libraries within the same loadable module.
>
> These problems don't exist when you build a shared library.
```bash
> dotnet publish /p:NativeLib=Static --use-current-runtime
```
Expand Down

0 comments on commit 2890083

Please sign in to comment.