{"action":"created","issue":{"url":"https://api.github.com/repos/grpc/grpc/issues/14402","repository_url":"https://api.github.com/repos/grpc/grpc","labels_url":"https://api.github.com/repos/grpc/grpc/issues/14402/labels{/name}","comments_url":"https://api.github.com/repos/grpc/grpc/issues/14402/comments","events_url":"https://api.github.com/repos/grpc/grpc/issues/14402/events","html_url":"https://github.com/grpc/grpc/issues/14402","id":296200392,"number":14402,"title":"Compiling grpc_csharp_ext for Android .so file (for use in Unity)","user":{"login":"zaneclaes","id":2084821,"avatar_url":"https://avatars0.githubusercontent.com/u/2084821?v=4","gravatar_id":"","url":"https://api.github.com/users/zaneclaes","html_url":"https://github.com/zaneclaes","followers_url":"https://api.github.com/users/zaneclaes/followers","following_url":"https://api.github.com/users/zaneclaes/following{/other_user}","gists_url":"https://api.github.com/users/zaneclaes/gists{/gist_id}","starred_url":"https://api.github.com/users/zaneclaes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaneclaes/subscriptions","organizations_url":"https://api.github.com/users/zaneclaes/orgs","repos_url":"https://api.github.com/users/zaneclaes/repos","events_url":"https://api.github.com/users/zaneclaes/events{/privacy}","received_events_url":"https://api.github.com/users/zaneclaes/received_events","type":"User","site_admin":false},"labels":[{"id":168238370,"url":"https://api.github.com/repos/grpc/grpc/labels/lang/C%23","name":"lang/C#","color":"fad8c7","default":false}],"state":"closed","locked":false,"assignee":{"login":"jtattermusch","id":9939684,"avatar_url":"https://avatars1.githubusercontent.com/u/9939684?v=4","gravatar_id":"","url":"https://api.github.com/users/jtattermusch","html_url":"https://github.com/jtattermusch","followers_url":"https://api.github.com/users/jtattermusch/followers","following_url":"https://api.github.com/users/jtattermusch/following{/other_user}","gists_url":"https://api.github.com/users/jtattermusch/gists{/gist_id}","starred_url":"https://api.github.com/users/jtattermusch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtattermusch/subscriptions","organizations_url":"https://api.github.com/users/jtattermusch/orgs","repos_url":"https://api.github.com/users/jtattermusch/repos","events_url":"https://api.github.com/users/jtattermusch/events{/privacy}","received_events_url":"https://api.github.com/users/jtattermusch/received_events","type":"User","site_admin":false},"assignees":[{"login":"jtattermusch","id":9939684,"avatar_url":"https://avatars1.githubusercontent.com/u/9939684?v=4","gravatar_id":"","url":"https://api.github.com/users/jtattermusch","html_url":"https://github.com/jtattermusch","followers_url":"https://api.github.com/users/jtattermusch/followers","following_url":"https://api.github.com/users/jtattermusch/following{/other_user}","gists_url":"https://api.github.com/users/jtattermusch/gists{/gist_id}","starred_url":"https://api.github.com/users/jtattermusch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtattermusch/subscriptions","organizations_url":"https://api.github.com/users/jtattermusch/orgs","repos_url":"https://api.github.com/users/jtattermusch/repos","events_url":"https://api.github.com/users/jtattermusch/events{/privacy}","received_events_url":"https://api.github.com/users/jtattermusch/received_events","type":"User","site_admin":false}],"milestone":null,"comments":14,"created_at":"2018-02-11T15:56:04Z","updated_at":"2018-03-02T16:44:43Z","closed_at":"2018-03-02T16:44:42Z","author_association":"NONE","body":"### Should this be an issue in the gRPC issue tracker?\r\n No; probably not a bug, just can't figure it out.\r\n\r\n### What version of gRPC and what language are you using?\r\n1.8.3, C# w/ .NET 4.6 and Unity 2017.3.0p4 \r\n \r\n### What operating system (Linux, Windows, …) and version?\r\n OSX High Sierra 10.13.3\r\n \r\n### What runtime / compiler are you using (e.g. python version or version of gcc)\r\n`arm-linux-androideabi-gcc` in attempts to compile `/src/csharp/ext/grpc_csharp_ext.c` into a `.so` that may be linked with Unity. Also tried running the csharp `py` test/build script as well as the Visual Studio project.\r\n \r\n### What did you do?\r\nI am attempting to use GRPC with Unity. I'm stuck compiling a libgrpc_csharp_ext.so file which will successfully work with the `arm-v7a` Android architecture. The NuGet package ships with both an x86 and an x64 binary; neither works on `arm-v7a`.\r\n\r\nI've tried two approaches. One is to modify the `Makefile` to have it produce the correct `.so` file, but since I'm on OSX (Darwin) I'm struggling to find the right flags.\r\n\r\nThe other is using the Android NDK directly. I expected the following command to work from the GRPC repository root:\r\n```\r\narm-linux-androideabi-gcc -I. -I./include -fPIC -o libgrpc_csharp_ext.o -c src/csharp/ext/grpc_csharp_ext.c\r\narm-linux-androideabi-gcc -I. -I./include -shared libgrpc_csharp_ext.o -o libgrpc_csharp_ext.so\r\n```\r\nIt compiles successfully and Unity recognizes the file when placed in /Plugins/Android as an arvm7 library. However, it does not have all of the required symbols.\r\n \r\n### What did you expect to see?\r\nA successful `DllImport(\"grpc_csharp_ext\")` and a connection to a GRPC server in the same Unity project which successfully does so on iOS, Linux, etc.\r\n \r\n### What did you see instead?\r\n \r\nWhen GRPC attempts to `DllImport(\"grpc_csharp_ext\")` on an actual Android device, I get an error:\r\n\r\nUnable to load library '/data/app/PACKAGE/lib/arm/libgrpc_csharp_ext.so', native render plugin support disabled: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol \"grpc_slice_from_copied_buffer\" referenced by \"/data/app/PACKAGE/lib/arm/libgrpc_csharp_ext.so\"...\r\n\r\nFollowed by:\r\n\r\nUnable to find grpc_csharp_ext\r\n\r\nI know this is possible because [this](https://github.com/neuecc/MagicOnion) open-source project has successfully cross-compiled the necessary files. When I download the .so file from their project and drop it into mine it successfully loads, except it was compiled with a very old version of GRPC and I therefore do not wish to use it. Furthermore, I've already successfully created an .a file for iOS which works well with a similar strategy. When I check my file with `file libgrpc_csharp_ext.so` I see that it is `ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, with debug_info, not stripped`. This matches the type of the file obtained from the open-source repository.\r\n\r\nIt seems like the appropriate symbols are not included in the resulting .so, based upon the error message above and also that the .so is ~36kb, but the \"correct\" .so from the open-source project is >5mb. I guess I'm compiling a dynamic library that doesn't include all the necessary symbols, but I'm not enough of a compiler guru to find the correct options.\r\n \r\n### Anything else we should know about your project / environment?\r\nc.f. this Stack Overflow: https://stackoverflow.com/questions/48727035/compiling-grpcs-csharp-extensions-with-ndk-for-android\r\n"},"comment":{"url":"https://api.github.com/repos/grpc/grpc/issues/comments/369978293","html_url":"https://github.com/grpc/grpc/issues/14402#issuecomment-369978293","issue_url":"https://api.github.com/repos/grpc/grpc/issues/14402","id":369978293,"user":{"login":"jtattermusch","id":9939684,"avatar_url":"https://avatars1.githubusercontent.com/u/9939684?v=4","gravatar_id":"","url":"https://api.github.com/users/jtattermusch","html_url":"https://github.com/jtattermusch","followers_url":"https://api.github.com/users/jtattermusch/followers","following_url":"https://api.github.com/users/jtattermusch/following{/other_user}","gists_url":"https://api.github.com/users/jtattermusch/gists{/gist_id}","starred_url":"https://api.github.com/users/jtattermusch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtattermusch/subscriptions","organizations_url":"https://api.github.com/users/jtattermusch/orgs","repos_url":"https://api.github.com/users/jtattermusch/repos","events_url":"https://api.github.com/users/jtattermusch/events{/privacy}","received_events_url":"https://api.github.com/users/jtattermusch/received_events","type":"User","site_admin":false},"created_at":"2018-03-02T16:44:42Z","updated_at":"2018-03-02T16:44:42Z","author_association":"CONTRIBUTOR","body":"I guess it's safe to close this issue now (as we have a way to compile now)."}}
{"actor":{"display_login":"jtattermusch"}}