xoofx/CppAst.NET

Installation guide?

Const-me opened this issue · 3 comments

Trying to use this library on Windows 10, getting the following error message:

Failed to resolve libClang or libClangSharp.
If you are running as a dotnet tool, you may need to manually copy the appropriate DLLs from NuGet due to limitations in the dotnet tool support.
System.DllNotFoundException: Unable to load DLL 'libclang' or one of its dependencies: The specified module could not be found. (0x8007007E)
   at ClangSharp.Interop.clang.createIndex(Int32 excludeDeclarationsFromPCH, Int32 displayDiagnostics)
   at CppAst.CppParser.ParseInternal(List`1 cppFiles, CppParserOptions options)
   at CppAst.CppParser.ParseFiles(List`1 cppFilenameList, CppParserOptions options)

I’m not running as a dotnet tool, using Visual Studio 2022 to run a console app based on .NET 6.0.
The libClang or libClangSharp packages didn’t help, same exception.

Eventually, I’ve solved by installing this package:
https://www.nuget.org/packages/ClangSharp/

Maybe you have forgot to add a dependency?

xoofx commented

Maybe you have forgot to add a dependency?

Don't think so, the dependency is correctly listed but maybe it is related to dotnet/ClangSharp#129

Though the weird thing is that I remember having this running without the workaround on a project, but I did setup it on another project here

So maybe I forgot that it has always to be setup. Probably need to add a notice in the readme.md or add this automatically to the package so that it setups this in case this is not setup.

@xoofx While trying different NuGet packages, I was also changing other settings in my *.csproj file.
Probably, one of these changes did the trick. The *.csproj which I have now has the following elements:

<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Platforms>x64</Platforms>
xoofx commented

Probably, one of these changes did the trick.

As I linked above you can setup it like this. It should be only the RuntimeIdentifier that is required:

https://github.com/xoofx/Monocypher.NET/blob/380711aa4565cd5aa06be9ab5d50df78935fc60f/src/Monocypher.CodeGen/Monocypher.CodeGen.csproj#L6-L7

That way it doesn't hardcode the platform - you can still pass the rid to dotnet when compiling, in case you would need to run on a different platform.