xamarin - How to add static library(.a) in to .Net Maui iOS application - Stack Overflow
I'm trying to add static library(.a) in to .Net Maui iOS application. I use functions from native binaries via DllImport attributes. So for example:
Inside .a file contains
// add.cpp extern "C" int add(int a, int b) { return a + b; }
After creating c++ project, I am converting into .a file format like below:
g++ -c add.cpp -o add.o
ar rcs libadd.a add.o
Adding libadd.a file in to .Net MAui Application like below:
.Net Maui sample application
inside .csproj
<NativeReference Include="Lib/libadd.a">
<Kind>Static</Kind>
<ForceLoad>True</ForceLoad>
<IsCxx>True</IsCxx>
</NativeReference>
</ItemGroup>
inside .cs file i am accessing the API which is from c++ library as below:
[DllImport("__Internal", EntryPoint = "add")]
public static extern int add(int a, int b);
i am getting below errors/usr/local/share/dotnet/sdk/8.0.404/Microsoft.Common.CurrentVersion.targets(2303,5): error MSB4803: The task "ResolveNativeReference" is not supported on the .NET Core version of MSBuild. Please use the .NET Framework version of MSBuild. See for further details. [/Users/sadeesh.kumar/Desktop/Demo-rk/HelloWordApp/HelloWordApp.csproj::TargetFramework=net8.0-android]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk8.0_18.0/18.0.8319/targets/Xamarin.Shared.Sdk.targets(1648,3): error : clang++ exited with code 1: [/Users/sadeesh.kumar/Desktop/Demo-rk/HelloWordApp/HelloWordApp.csproj::TargetFramework=net8.0-ios]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk8.0_18.0/18.0.8319/targets/Xamarin.Shared.Sdk.targets(1648,3): error : ld: building for 'iOS-simulator', but linking in object file (/Users/sadeesh.kumar/Desktop/Demo-rk/HelloWordApp/Platforms/iOS/Lib/libMathFuncs.a[arm64][2](MyMathFuncs.o)) built for 'iOS' [/Users/sadeesh.kumar/Desktop/Demo-rk/HelloWordApp/HelloWordApp.csproj::TargetFramework=net8.0-ios]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk8.0_18.0/18.0.8319/targets/Xamarin.Shared.Sdk.targets(1648,3): error : clang++: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/sadeesh.kumar/Desktop/Demo-rk/HelloWordApp/HelloWordApp.csproj::TargetFramework=net8.0-ios]
Referred below link but still i am facing error:
1.
2.
Environment:
Visual studio code: Version: 1.96.2
MacOS: 14.7.1
XCode: 16.2
DotNet-SDK: 8.0.404
最新文章
- 以色列导航软件公司Waze被谷歌收购
- 微软Surface平板电脑将于10月份发布
- html - HTML5 Canvas: How to draw on Canvas from Java or C++ server? - Stack Overflow
- azure cosmosdb - Cosmos DB REST API using Resource Token gives 403 Forbidden - Stack Overflow
- python - Arcpy seems to not carry out my SQL clause - Stack Overflow
- c++ - std::rethrow_exception with std::current_exception - Stack Overflow
- reactjs - Flatlist scrolling freeze - Stack Overflow
- Any way to open an SSIS project with a newer version of Visual Studio? - Stack Overflow
- c++ - templates are instantiated despite having extern template - Stack Overflow
- html - django multi-level template extending - Stack Overflow
- c# - Trouble when setting up Serilog in ASP.NET Core Web API - Stack Overflow
- terraform - Restrict Savings Plan creation outside specified subscription in Mgmt group via Azure Policy - Stack Overflow
- innodb - How does MySQL handle lock queuing order for SELECT ... FOR UPDATE? - Stack Overflow
- window - Strawberry Perl doesn't include Win32::shortcut? - Stack Overflow
- python - Problem clearing errorbar artists from dynamic matplotlib figure - Stack Overflow
- javascript - How can I create hyperlinkOrPicture column types on SharePoint Lists with Microsoft Graph API or Sharepoint API? -
- node.js - Nestjs can't find build source after creating workspace - Stack Overflow