xoofx/CppAst.NET

clang_EnumDecl_isScoped not found

danyhm opened this issue · 10 comments

Hi,

after a long day, I finally managed to supply the right arguments for the MingW64 8.1.0 Include folders and try to parse a header based on that.

however I think the Enum parser is broken (all other parsers work fine) , and when the parser sees an enum i get this exception in the visual studio 2019 debugger :

System.EntryPointNotFoundException: 'Unable to find an entry point named 'clang_EnumDecl_isScoped' in DLL 'libclang'.'
in CppModelBuilder.cs line 1039:cppEnum.IsScoped = cursor.EnumDecl_IsScoped;

the same error is produced if I try the sample from the main page with an enum in it:

var compilation = CppParser.Parse(@"
enum MyEnum { MyEnum_0, MyEnum_1 };
void function0(int a, int b);
struct MyStruct { int field0; int field1;};
typedef MyStruct* MyStructPtr;
"
);

any ideas?

xoofx commented

Which version of CppAst.NET are you using?

I cloned the git repo, so I'm on the last commit of the master branch.

xoofx commented

Can't reproduce this on master + Windows. Are you running on Linux or MacOS maybe?

xoofx commented

Also inspecting the local libclang.dll file and I can see the symbol clang_EnumDecl_isScoped exported, so I believe that you have something weird on your setup as it doesn't seem to load the correct libclang.dll.

I'm on windows. and you're right the function is exported. this is very strange. i think it has to be something related to .net platform maybe?

xoofx commented

Can you share your csproj?

xoofx commented

Ok, so that's because you need to add this line to your csproj:

  <PropertyGroup>
    <!-- Workaround for issue https://github.com/microsoft/ClangSharp/issues/129 -->
    <RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' AND '$(PackAsTool)' != 'true'">$(NETCoreSdkRuntimeIdentifier)</RuntimeIdentifier>
  </PropertyGroup>

as it is done in the tests, otherwise it won't copy the correct libclang DLL and might start to use another mismatching arch on your path...
Same if you consume the package.

thanks ! that solved the problem !