Hot questions for Using Cap'n Proto in linux


I think this is a generic problem not specifically related to Cap'n Proto.

My project's build succeeds but on run I get:

error while loading shared libraries: cannot open shared object file: No such file or directory

Maybe I am missing something in CMake?

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lcapnp -lkj")

I verified exists in /usr/local/lib

I also tried adding:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L/usr/local/lib/")


/usr/local/lib needs to be added to /etc/

then run sudo ldconfig to load the changes.


I am new to Cap'n Proto and I was trying to compile the calculator example found here:

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.