Skip to content
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

IOS: Symbol not found: _grpcsharp_redirect_log #20

Closed
Rurouni opened this issue Mar 20, 2017 · 14 comments
Closed

IOS: Symbol not found: _grpcsharp_redirect_log #20

Rurouni opened this issue Mar 20, 2017 · 14 comments

Comments

@Rurouni
Copy link

Rurouni commented Mar 20, 2017

Hi,
I have tried to run it in IOS and it fails with
dyld: lazy symbol binding failed: Symbol not found: _grpcsharp_redirect_log

in that function:

// System.Void Grpc.Core.Internal.NativeMethods/Delegates/grpcsharp_redirect_log_delegate::Invoke(Grpc.Core.Internal.GprLogDelegate)
extern "C"  void grpcsharp_redirect_log_delegate_Invoke_m3963642216 (grpcsharp_redirect_log_delegate_t2162057115 * __this, GprLogDelegate_t430330606 * ___callback0, const MethodInfo* method)
{
	if(__this->get_prev_9() != NULL)
	{
		grpcsharp_redirect_log_delegate_Invoke_m3963642216((grpcsharp_redirect_log_delegate_t2162057115 *)__this->get_prev_9(),___callback0, method);
	}
	il2cpp_codegen_raise_execution_engine_exception_if_method_is_not_found((MethodInfo*)(__this->get_method_3().get_m_value_0()));
	bool ___methodIsStatic = MethodIsStatic((MethodInfo*)(__this->get_method_3().get_m_value_0()));
	if (__this->get_m_target_2() != NULL && ___methodIsStatic)
	{
		typedef void (*FunctionPointerType) (Il2CppObject *, void* __this, GprLogDelegate_t430330606 * ___callback0, const MethodInfo* method);
		((FunctionPointerType)__this->get_method_ptr_0())(NULL,__this->get_m_target_2(),___callback0,(MethodInfo*)(__this->get_method_3().get_m_value_0()));
	}
	else if (__this->get_m_target_2() != NULL || ___methodIsStatic)
	{
		typedef void (*FunctionPointerType) (void* __this, GprLogDelegate_t430330606 * ___callback0, const MethodInfo* method);
		((FunctionPointerType)__this->get_method_ptr_0())(__this->get_m_target_2(),___callback0,(MethodInfo*)(__this->get_method_3().get_m_value_0()));
	}
	else
	{
		typedef void (*FunctionPointerType) (void* __this, const MethodInfo* method);
		((FunctionPointerType)__this->get_method_ptr_0())(___callback0,(MethodInfo*)(__this->get_method_3().get_m_value_0()));
	}
}

I wonder if I hasn't done some magic configuration on the Native dlls or something, but gRPC/Native/iOS/libgrpc_csharp_ext.a and others there are configured to be included in IOS build...

@neuecc
Copy link
Member

neuecc commented Mar 21, 2017

I do not know the solution to the problem.
googled:"dyld: lazy symbol binding failed" find some (same?) faq but I can not understand whether it is suitable or not.

@Rurouni
Copy link
Author

Rurouni commented Mar 21, 2017

Have you managed to run it in IOS? I wonder if it's actual issue or I haven't done something in Unity...

@neuecc
Copy link
Member

neuecc commented Mar 21, 2017

Yes, it is running on iOS (It is being built everyday in our game under development now)
As I update to 1.3 soon, can you see it at that time?
The custom code of gRPC is here.
https://github.com/grani/gRPC/tree/UnityClient
We've modified some of issue, including freeze of Unity Editor.

@Rurouni
Copy link
Author

Rurouni commented Mar 21, 2017

You use il2cpp backend for IOS right?

As I update to 1.3 soon, can you see it at that time?

Do you mean that you are in the progress of updating to 1.2 grpc?

@neuecc
Copy link
Member

neuecc commented Mar 21, 2017

Yes, I use IL2CPP backend only.

Ah, sorry, '1.2'.
Yes, I plan to upgrade this week or next week.

@Rurouni
Copy link
Author

Rurouni commented Mar 21, 2017

Cheers, that would be great. In the meantime I will try to build native dlls manually from your UnityClient branch

@Rurouni
Copy link
Author

Rurouni commented Mar 22, 2017

I have tried running unaltered latest MagicOnion and I can't even build it for IOS/IL2CPP/Simulator

IL2CPP error for method 'System.Int32 MessagePack.LZ4.LZ4Codec::Encode32(System.Byte*,System.Byte*,System.Int32,System.Int32)' in LZ4Codec.Unsafe.cs:83
Additional information: Exception of type 'System.Exception' was thrown.

I have then tried mono backend instead of il2cpp and it builds and deploys to simulator but then any access to NativeMethods yields EntrypointNotFoundException that looks like same root cause as in my original case with il2cpp

I am also struggling to build native dependencies for IOS. When I am building grpc from the branch you have given I can see libs like libgrpc.a or libboringssl.a and some more but not libgrpc_csharp_ext.a or libgRPC-Core.a. Can you advise please on how you build them?

@neuecc
Copy link
Member

neuecc commented Mar 23, 2017

Oh, sorry, I've fixed MessagePack for C# + IL2CPP compile issue on MessagePack repository
but it is not yet moved on MagicOnion repository.

// old, MagicOnion
https://github.com/neuecc/MagicOnion/tree/master/src/MagicOnion.Client.Unity/Assets/Scripts/MessagePack/LZ4/Codec

// new, MessagePack
https://github.com/neuecc/MessagePack-CSharp/tree/master/src/MessagePack/LZ4/Codec

@neuecc
Copy link
Member

neuecc commented Mar 23, 2017

Environment:

  • Mac (Sierra 10.12)
  • Xcode (8.1)
  • CocoaPods (1.1.1)

build shell.
https://github.com/grani/grpc/blob/UnityClient/build_grpc_cshap_ext.sh

our ci command:

build_type="Debug"
# build_type="Release"
output_dir="./out/${build_type}"

chmod +x ./build_grpc_cshap_ext.sh
./build_grpc_cshap_ext.sh "$output_dir" $build_type

@Rurouni
Copy link
Author

Rurouni commented Mar 23, 2017

whilst building I have run into such issue:

GPR_EXPORT grpc_event GPR_CALLTYPE
grpcsharp_completion_queue_next(grpc_completion_queue *cq) {
  return grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME),
                                    NULL);
}

magicgrpc/xcprojects/grpc_csharp_ext_ios/src/csharp/ext/grpc_csharp_ext.c:380:41: Too few arguments to function call, expected 4, have 3

I have put NULL in there for now, and managed to build it. But using static libs that I build hasn't helped.

After digging some more I have run nm on the libs and realised that there are no symbols for x86_64 architecture(only arm64) and that was my problem because apparently simulator of IOS uses x86_64 architecture(same as mac). So that's is the root case. That would also explain why I couldn't make it work in editor on mac as well. I have tested in real device and it found all entrypoints - hooray!

To make it work in editor I have tried to build x86_64 but when I change in xcode to different architecture for grpc_csharp_ext and run build script I get some cryptic

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-grpc_csharp_ext
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-grpc_csharp_ext is not an object file (not allowed in a library)

Sadly, as a windows user that's all a bit over my head.
If it's possible after you upgrade to grpc 1.2 can you please include both ARM and x86_64 static libs for IOS?

Thank you

@neuecc
Copy link
Member

neuecc commented Apr 3, 2017

I've uploaded v0.4.0 and its .unitypackage on releases page.

@Rurouni
Copy link
Author

Rurouni commented Apr 4, 2017

I have upgraded to latest. 1.2 works perfectly. 👍
Though I still can't figure out how to run it in editor on mac. I can see there is now Native/Mac folder that contains some .bundle_ file but it doesn't look like object library file and when I run in editor it still complains that it can't find entrypoints for native methods. Should it work out of the box or do I need some additional configuration?

@neuecc
Copy link
Member

neuecc commented Apr 5, 2017

Sorry, .bundle_ is .bundle file, please rename it and is it work?
Bundle was recognized as a folder and could not be packaged, it was included as bundle_.
I've take it from NuGet, 1.2.0/runtimes/osx/native/libgrpc_csharp_ext.x64.dylib and renamed.
I am not familiar with plugins in Mac Editor, so I can not confirm whether it actually works.

@Rurouni
Copy link
Author

Rurouni commented Apr 5, 2017

It started to work as soon as I renamed to .bundle.
Thank you for your help!

@Rurouni Rurouni closed this as completed Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants