-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generating pinvoke wrappers using ClangSharpPInvokeGenerator generates CXError_Failure errors #283
Comments
My expectation is the failure is caused by a version mismatch. You are running ClangSharpPInvokeGenerator There is a strict requirement that the major version of Aside from that, rolling forward to the latest nightly bits (and
|
Thanks so much. I'll try this out with v12 and see how it goes |
I installed clang v12 on ubuntu 20.04 root@ea89bf12b378:/tmp# clang-12 --version
Ubuntu clang version 12.0.1-++20211029101322+fed41342a82f-1~exp1~20211029221816.4
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin I have
I installed the v12 version of the pinvoke generate tool. dotnet tool install --global ClangSharpPInvokeGenerator --version 12.0.0-beta2 Unfortunately, same issue
I was getting errors about missing apt install --yes libclang-12-dev
root@ea89bf12b378:/tmp# apt install --yes libclang-12-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libclang-12-dev
0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
Need to get 19.8 MB of archives.
After this operation, 194 MB of additional disk space will be used.
Get:1 https://apt.llvm.org/focal llvm-toolchain-focal-12/main amd64 libclang-12-dev amd64 1:12.0.1~++20211029101322+fed41342a82f-1~exp1~20211029221816.4 [19.8 MB]
Fetched 19.8 MB in 4s (5291 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libclang-12-dev.
(Reading database ... 69626 files and directories currently installed.)
Preparing to unpack .../libclang-12-dev_1%3a12.0.1~++20211029101322+fed41342a82f-1~exp1~20211029221816.4_amd64.deb ...
Unpacking libclang-12-dev (1:12.0.1~++20211029101322+fed41342a82f-1~exp1~20211029221816.4) ...
Setting up libclang-12-dev (1:12.0.1~++20211029101322+fed41342a82f-1~exp1~20211029221816.4) ... Thanks again for your help |
As a test, I decided to try a really simple header, so see if I have things set up properly root@ea89bf12b378:/tmp# cat test.h
/* Defines the poppler version. */
#ifndef POPPLER_VERSION
#define POPPLER_VERSION "0.86.1"
#endif Looks like root@ea89bf12b378:/tmp# ClangSharpPInvokeGenerator @generate.rsp
Processing 'test.h'
Diagnostics for binding generation:
Error: System.DllNotFoundException: Unable to load shared library 'libClangSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibClangSharp: cannot open shared object file: No such file or directory
at ClangSharp.Interop.clangsharp.Cursor_getDeclKind(CXCursor C)
at ClangSharp.Interop.CXCursor.get_DeclKind() in /_/sources/ClangSharp.Interop/Extensions/CXCursor.cs:line 522
at ClangSharp.Decl.Create(CXCursor handle) in /_/sources/ClangSharp/Cursors/Decls/Decl.cs:line 148
at ClangSharp.Cursor.Create(CXCursor handle) in /_/sources/ClangSharp/Cursors/Cursor.cs:line 73
at ClangSharp.TranslationUnit.GetOrCreate[TCursor](CXCursor handle) in /_/sources/ClangSharp/TranslationUnit.cs:line 102
at ClangSharp.TranslationUnit.<.ctor>b__9_0() in /_/sources/ClangSharp/TranslationUnit.cs:line 34
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at ClangSharp.PInvokeGenerator.GenerateBindings(TranslationUnit translationUnit, String filePath, String[] clangCommandLineArgs, CXTranslationUnit_Flags translationFlags) in /_/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs:line 316 Sorry for all the questions. |
No worries, not all of this is super clear today. Hopefully the issues can get resolved and the tooling can move to a place where its much simpler to use.
It's supposed to, but there are some issues with native dependencies and NuGet that make this a difficult experience and it doesn't always work (#229 (comment) goes into some more detail). You can manually get the binary from https://www.nuget.org/packages/libClangSharp.runtime.ubuntu.20.04-x64/12.0.0-beta1 and put it next to the tool ( |
Sigh, no luck. I did copy root@ea89bf12b378:~/.dotnet/tools# ldd libClangSharp.so
linux-vdso.so.1 (0x00007ffc1ac65000)
libclang.so.12 => /lib/x86_64-linux-gnu/libclang.so.12 (0x00007f664bf45000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f664bf22000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f664bf06000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f664bed6000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f664bcf4000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f664bba5000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f664bb88000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f664b996000)
/lib64/ld-linux-x86-64.so.2 (0x00007f664feee000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f664b990000)
libLLVM-12.so.1 => /lib/x86_64-linux-gnu/libLLVM-12.so.1 (0x00007f6645e75000)
libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007f6645e69000)
libedit.so.2 => /lib/x86_64-linux-gnu/libedit.so.2 (0x00007f6645e2f000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f6645e24000)
libxml2.so.2 => /lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f6645c6a000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f6645c50000)
libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f6645a6a000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f6645a41000)
libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f6643f7e000) I tried to soft symlink root@ea89bf12b378:~/.dotnet/tools# ll /lib/x86_64-linux-gnu/libclang*
lrwxrwxrwx 1 root root 16 Oct 29 18:18 /lib/x86_64-linux-gnu/libclang-12.so -> libclang-12.so.1
-rw-r--r-- 1 root root 26290256 Oct 29 18:18 /lib/x86_64-linux-gnu/libclang-12.so.1
lrwxrwxrwx 1 root root 33 Oct 29 18:18 /lib/x86_64-linux-gnu/libclang-cpp.so.12 -> ../llvm-12/lib/libclang-cpp.so.12
lrwxrwxrwx 1 root root 16 Oct 31 17:14 /lib/x86_64-linux-gnu/libclang.so.12 -> libclang-12.so.1
lrwxrwxrwx 1 root root 16 Oct 31 17:19 /lib/x86_64-linux-gnu/libclang.so.12.so -> libclang-12.so.1 ah well... |
Hmmm. I just tried on a clean machine and everything looks to work as expected. ClangSharp 13.0.0I did the following
That failed, so I then did:
And everything succeeded. ClangSharp 12.0.0I did the following:
That failed with the type load error, so I did:
And everything succeeded. |
doh 🤦🏽 I guess I'll have to try and simplify why the popper headers fail to parse. Now that I know the basic set up works. Thanks again for your help with this Would you be ok if I submitted a PR for the README with some of these steps in there? Or do you think this would change too often to be useful? |
Another brain fart... |
I'm definitely fine with some additional hints in the docs or even in the failure case on the command line. Most of the time right now we only expose what libClang itself reports, which is often less than helpful. |
I'm trying to generate pinvoke wrappers for poppler cpp header files on ubuntu.
You can see the code for those those headers here
https://gitlab.freedesktop.org/poppler/poppler/-/blob/master/cpp/poppler-font.h
Poppler is installed on my system via apt
I'm running the generate tool as follows
~/.dotnet/tools/ClangSharpPInvokeGenerator @generate.rsp
The response file looks like the following
I'm using the 11.0.0-beta3 tool installed globally
Version of clang is the following
Whenever I run the generator tool, I get the following errors
I'm trying to figure out why this tool is failing, but the errors don't tell me much.
Is there any way for me to get more information? Just trying to figure out what the next steps should be.
Thanks for your help.
The text was updated successfully, but these errors were encountered: