[grpc-io] how to cross compile grpc Server

127 views
Skip to first unread message

Simon Chamlian

unread,
Oct 10, 2018, 11:49:47 AM10/10/18
to grpc.io
Hi,

Is there any instruction on how to cross compile grpc server to port it on an embedded Linux system?
Thanks,
S

yas...@google.com

unread,
Oct 10, 2018, 1:59:46 PM10/10/18
to grpc.io
I don't think we have instructions for this. It would be a good idea to file an issue on github for this.

Simon Chamlian

unread,
Oct 10, 2018, 4:13:16 PM10/10/18
to yas...@google.com, grpc.io
I am surprised that no one has a grpc server on an embedded system.

What is /usr/bin/grpc_cpp_plugin  used for?



--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/7e18a603-1038-483f-a814-4c145047cb79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

yas...@google.com

unread,
Oct 10, 2018, 4:53:14 PM10/10/18
to grpc.io
It's not that no one uses it that way. It's just that we don't have a doc for it at the moment. Creating a github issue for this should help keep track. We do want to improve our documentation :) 
In the mean time, unless someone has a better answer, I would suggest looking at the Makefile to check which configurations you need to modify.

grpc_cpp_plugin is a protobuf plugin for generating gRPC code.

Simon Chamlian

unread,
Oct 11, 2018, 2:16:07 PM10/11/18
to yas...@google.com, grpc.io
I am trying to port the example into an Eclipse environment to cross compile.

Which libraries do I need to include and their path  (`pkg-config --libs protobuf grpc++ grpc`)?

Thanks,
S



Stephan Menzel

unread,
Oct 12, 2018, 5:53:55 AM10/12/18
to grpc.io
I have it running on Raspberry Pi with no problems. If that counts as embedded. Since grpc's build system is so complicated I suppose the easiest way would be to either use supplied packages or compile it on the target system itself.

Cheers,
Stephan

Simon Chamlian

unread,
Oct 12, 2018, 9:33:46 AM10/12/18
to stephan...@gmail.com, grpc.io
Is there binary versions available for different platforms (CPUs)?



--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

Stephan Menzel

unread,
Oct 12, 2018, 11:13:30 AM10/12/18
to grpc.io
Am Freitag, 12. Oktober 2018 15:33:46 UTC+2 schrieb SimonC:
Is there binary versions available for different platforms (CPUs)?


Sure. Raspbian at the very least has grpc and protobuf packages. You may need to include extra repos though.
Look for libgrpc-dev.

> apt search libgrpc-dev 

HTH,
Stephan

Simon Chamlian

unread,
Oct 23, 2018, 11:08:14 AM10/23/18
to Stephan Menzel, grp...@googlegroups.com
Still having lots of issues to cross compile.

Is it a good strategy to give up on libraries and instead compile the source code? 
If so, does anyone knows which source code is required to be able to cross-compile the greeter_server example?

~/grpc/src/cpp$ ls -l
total 32
drwxrwxr-x 2 jay jay 4096 Aug 24 15:04 client
drwxrwxr-x 2 jay jay 4096 Aug 24 15:04 codegen
drwxrwxr-x 2 jay jay 4096 Aug 24 15:04 common
drwxrwxr-x 2 jay jay 4096 Aug 24 15:04 ext
-rwxrwxr-x 1 jay jay 1170 Aug 24 15:04 README.md
drwxrwxr-x 3 jay jay 4096 Oct 23 10:59 server
drwxrwxr-x 2 jay jay 4096 Aug 24 15:04 thread_manager
drwxrwxr-x 2 jay jay 4096 Aug 24 15:04 util
 
Is it source code in ~/grpc/src/cpp/server  directory and ~/grpc/src/cpp/common directory I need to include?

Tx,
S.



--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

Simon Chamlian

unread,
Oct 24, 2018, 3:55:39 PM10/24/18
to Stephan Menzel, grp...@googlegroups.com
I did a cross compilation a grpc within YOCTO and ended up with the following libraries:

libgrpc.a   
libgrpc_cronet.a   
libgrpc++_error_details.a 
libgrpc++_reflection.a 
libgrpc++_unsecure.a 
libprotobuf-c.a
libgrpc++.a 
libgrpc++_cronet.a 
libgrpc_plugin_support.a  
libgrpc_unsecure.a     
libprotobuf.a        
libprotobuf-lite.a


When I compile the greeter_server within Eclipse, I get lots of errors of classes not recognized. I presume these classes are defined in libraries.

Does anyone know which libraries do I need to include in Eclipse project?

Thanks,
S



Simon Chamlian

unread,
Oct 24, 2018, 4:01:24 PM10/24/18
to Stephan Menzel, grp...@googlegroups.com
for example, one of the errors is:

/home/jay/works_Versa_imx7/xgrpc_server/src/libgrpc.a(httpcli.cc.o): In function `append_error':
/usr/src/debug/grpc/1.8.5-r0/git/src/core/lib/http/httpcli.cc:124: undefined reference to `gpr_free'

So inside libgrpc.a(httpcli.cc.o) the function append_error is calling gpr_free.

I guess I am missing some libraries.









Simon Chamlian

unread,
Oct 24, 2018, 4:10:43 PM10/24/18
to Stephan Menzel, grp...@googlegroups.com
This is the makefile generated  by eclipse:

USER_OBJS := /home/jay/works_Versa_imx7/xgrpc_server/src/libprotobuf.a /home/jay/works_Versa_imx7/xgrpc_server/src/libgrpc++.a /home/jay/works_Versa_imx7/xgrpc_server/src/libgrpc.a /home/jay/works_Versa_imx7/xgrpc_server/src/libgrpc++_reflection.a

LIBS := -lpthread -lm -ldl

@echo 'Invoking: GCC C++ Linker'
arm-poky-linux-gnueabi-g++  -march=armv7ve -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.9.11-1.0.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi  -O2 -pipe -g -feliminate-unused-debug-types  -o "xgrpc_server" $(OBJS) $(USER_OBJS) $(LIBS)





robert engels

unread,
Oct 24, 2018, 4:12:27 PM10/24/18
to Simon Chamlian, Stephan Menzel, grp...@googlegroups.com
I think you may just be linking incorrectly, that method is part of the grpc core https://grpc.io/grpc/core/alloc_8h.html

robert engels

unread,
Oct 24, 2018, 4:12:28 PM10/24/18
to Simon Chamlian, Stephan Menzel, grp...@googlegroups.com
I think you may just be linking incorrectly, that method is part of the grpc core https://grpc.io/grpc/core/alloc_8h.html
On Oct 24, 2018, at 3:01 PM, Simon Chamlian <simon.c...@mpbc.ca> wrote:

Simon Chamlian

unread,
Oct 25, 2018, 9:50:15 AM10/25/18
to ren...@earthlink.net, Stephan Menzel, grp...@googlegroups.com
yes my problem is at linking phase of cross-compiling. That is why I was wondering which libraries I should include.

The Makefile on the host (PC)  where it compiles correctly, I see:
g++ -std=c++11 `pkg-config --cflags protobuf grpc`  -c -o greeter_server.o greeter_server.cc
g++ helloworld.pb.o helloworld.grpc.pb.o greeter_server.o -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc` -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl -o greeter_server

what does the `pkg-config --libs protobuf grpc++ grpc` instruction do?

I am including the following libraries:

image.png

libprotobuf.a
libgrpc++.a
libgrpc.a
libgrpc++_reflection.a
Reply all
Reply to author
Forward
0 new messages