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

Linking against gRPC::grpc++ vs gRPC::grpc++_unsecure #61

Closed
reusing-code opened this issue Jan 23, 2023 · 6 comments
Closed

Linking against gRPC::grpc++ vs gRPC::grpc++_unsecure #61

reusing-code opened this issue Jan 23, 2023 · 6 comments

Comments

@reusing-code
Copy link

reusing-code commented Jan 23, 2023

Hi,

we have a project that already uses grpc and we link against gRPC::grpc++. We now want to introduce asio-grpc, which links against gRPC::grpc++_unsecure when using the generated asio-grpcConfig.cmake. This leads to problems, apparently it is not possible to link against both targets in the same binary.

I found this commit: 2731e5b
So first of all the question would be: Why was this changed? Why is the default the _unsecure target?

We can fix our build by manually patching the asio-grpcConfig.cmake.in file and making sure that asio-grpc also links against gRPC::grpc++, but this is quite ugly and will break on any changes to that file.
Would it be possible to add a cmake config variable so that we can optionally link asio-grpc against gRPC::grpc++ instead of the default of gRPC::grpc++_unsecure?

@Tradias
Copy link
Owner

Tradias commented Jan 23, 2023

As an immediate workaround you can set the CMake variable ASIO_GRPC_DISABLE_AUTOLINK before calling find_package/add_subdirectory for asio-grpc. Then it won't link with anything.

I changed it because I though that _unsecure is the baseline and that everything else depends on it. Seems like that is not the case.

@reusing-code
Copy link
Author

reusing-code commented Jan 24, 2023

Thank you for the quick response!

I'll try that, thanks.

I changed it because I though that _unsecure is the baseline and that everything else depends on it. Seems like that is not the case.

Yeah, and there is not a lot of documentation what those different grpc targets are and when to use what. It doesn't even lead to link errors, when both are linked in the same binary, it just leads to grpc calls hanging indefinitely.

This is the issue that happens in that case: grpc/grpc#24422 (comment)

@Tradias
Copy link
Owner

Tradias commented Feb 24, 2023

I will change the default linkage back to gRPC::grpc++ in v3 of asio-grpc and let power users utilize ASIO_GRPC_DISABLE_AUTOLINK + gRPC::grpc++_unsecure as they see fit.

Did my suggestion regarding ASIO_GRPC_DISABLE_AUTOLINK work for you?

@reusing-code
Copy link
Author

Thank you, sounds great!

To be honest, I have yet to try ASIO_GRPC_DISABLE_AUTOLINK , currently still working with my ugly workaround.

@Tradias
Copy link
Owner

Tradias commented Apr 7, 2024

Asio-grpc v3 now links with gRPC::grpc++ by default. I am also changing that in conan-center conan-io/conan-center-index#22910.

@reusing-code
Copy link
Author

Cool, thank you! I'll look into migrating to v3

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