I am new to Cap'n Proto and I was trying to compile the calculator example found here: https://github.com/capnproto/capnproto/blob/master/c%2B%2B/samples/calculator.capnp
I used this command capnp compile -oc++ calculator.capnp
to generate the calculator.capnp.c++
and calculator.capnp.h
files.
I tried to compile the calculator.capnp.c++
file using the following command: g++ -o calc calculator.capnp.c++ -lcapnp -lkj -lcapnp-rpc -lkj-async
but I received this error message:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function '_start': (.text+0x20): undefined reference to 'main' collect2: error: ld returned 1 exit status
I went over the official documentation and other resources, but I haven't found instructions on how to run this example (or anything similar). How can I proceed and run it?
You're not building the whole sample, only the generated protocol files.
Notice how the repo also has calculator-server.c++
and calculator-client.c++
, both of which contain the main
entrypoint function. Pick one and link it into your program.
If you use the CMakeLists.txt already provided, this is done for you.