EmbeddedRPC / erpc

Embedded RPC
https://github.com/EmbeddedRPC/erpc/wiki
BSD 3-Clause "New" or "Revised" License
776 stars 213 forks source link

How to generate only C code for erpc file #400

Closed pioneerAlone closed 9 months ago

pioneerAlone commented 10 months ago

I am using erpc 1.12 version, but when using erpcgen to generate code, no matter whether "-g c" is specified or not, it always generates the code as shown below. I want to know what codes I need if I only use C, or all of them It is a must, I checked the guide on the wiki, they seem to have not been updated for a long time, which is not very friendly to newbies

image

github-actions[bot] commented 10 months ago

Hi eRPC user. Thank you for your interest and welcome. We hope you will enjoy this framework well.

Hadatko commented 10 months ago

Hi @pioneerAlone , all these files are necessary for running C erpc functions. Implementation is in C++. C generated files contains C wrapper functions which are calling C++ functions inside.

pioneerAlone commented 10 months ago

Got ot, Is there an example of compiling demo? I tried to compile them but got the following error.

g++ -Wall -I. -I/usr/local/include/erpc -L/usr/local/lib c_hello_server.cpp hello_server.cpp  -lerpc -lpthread -o server
g++ -Wall -I. -I/usr/local/include/erpc -L/usr/local/lib c_hello_client.cpp hello_client.cpp -lerpc -lpthread -o client

q@q-OptiPlex-5050:~/bakewell/gitprj/hello_erpc$ ./build.sh /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function_start': (.text+0x24): undefined reference to main' /usr/bin/ld: /tmp/ccp55hAR.o: in functionHello_server::~Hello_server()': c_hello_server.cpp:(.text._ZN12Hello_serverD2Ev[_ZN12Hello_serverD5Ev]+0x26): undefined reference to erpcShim::Hello_interface::~Hello_interface()' /usr/bin/ld: /tmp/ccp55hAR.o: in functionHello_server::sayHello(binary_t const)': c_hello_server.cpp:(.text._ZN12Hello_server8sayHelloEPK8binary_t[_ZN12Hello_server8sayHelloEPK8binary_t]+0x24): undefined reference to sayHello' /usr/bin/ld: /tmp/ccp55hAR.o: in functionerpcShim::Hello_interface::Hello_interface()': c_hello_server.cpp:(.text._ZN8erpcShim15Hello_interfaceC2Ev[_ZN8erpcShim15Hello_interfaceC5Ev]+0xf): undefined reference to vtable for erpcShim::Hello_interface' /usr/bin/ld: /tmp/ccp55hAR.o:(.data.rel.ro._ZTI12Hello_server[_ZTI12Hello_server]+0x10): undefined reference totypeinfo for erpcShim::Hello_interface' /usr/bin/ld: /tmp/cc6z8YJQ.o: in function `erpcShim::Hello_service::sayHello_shim(erpc::Codec, erpc::MessageBufferFactory, erpc::Transport, unsigned int)': hello_server.cpp:(.text+0x2e2): undefined reference to nestingDetection' /usr/bin/ld: hello_server.cpp:(.text+0x313): undefined reference tonestingDetection' collect2: error: ld returned 1 exit status /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function _start': (.text+0x24): undefined reference tomain' /usr/bin/ld: /tmp/ccFGWu3n.o: in function erpcShim::Hello_client::~Hello_client()': hello_client.cpp:(.text+0x188): undefined reference toerpcShim::Hello_interface::~Hello_interface()' /usr/bin/ld: /tmp/ccFGWu3n.o: in function erpcShim::Hello_interface::Hello_interface()': hello_client.cpp:(.text._ZN8erpcShim15Hello_interfaceC2Ev[_ZN8erpcShim15Hello_interfaceC5Ev]+0xf): undefined reference tovtable for erpcShim::Hello_interface' /usr/bin/ld: /tmp/ccFGWu3n.o:(.data.rel.ro._ZTIN8erpcShim12Hello_clientE[_ZTIN8erpcShim12Hello_clientE]+0x10): undefined reference to typeinfo for erpcShim::Hello_interface' collect2: error: ld returned 1 exit status

Hadatko commented 10 months ago

See my comments here: https://github.com/EmbeddedRPC/erpc/issues/399 and https://github.com/EmbeddedRPC/erpc/issues/398

pioneerAlone commented 10 months ago

Hello ,

Thanks, I am trying hello_world example on #398 , but I can't resolve the compilation issue below:

error: /usr/bin/ld: build/.objs/main_server/linux/x86_64/release/shim/c/hello_world_server.cpp.o: in functionerpcShim::TextService_service::printText_shim(erpc::Codec, erpc::MessageBufferFactory, erpc::Transport*, unsigned int)': hello_world_server.cpp:(.text+0x1e6): undefined reference to nestingDetection' /usr/bin/ld: hello_world_server.cpp:(.text+0x213): undefined reference tonestingDetection' collect2: error: ld returned 1 exit status `

Hadatko commented 10 months ago

I see, it is possible there is an issue within configuration try disable nested calls detection. Or enable if it is already disabled:

define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED)

Anyway sounds like a bug to me. I will take a look on that.

pioneerAlone commented 10 months ago

I resolved it with the code below, It seems that I should disable or enable when compiling the library?

#define ERPC_NESTED_CALLS_DETECTION 1

#if ERPC_NESTED_CALLS_DETECTION
bool nestingDetection;
#endif