Search code examples
c++homebrewsnappycapnproto

Linking C++ libraries for Capn Pronto and Snappy


I am trying to compile a c++ project, and it requires capn pronto and snappy. I have installed these using:

brew install capnp
brew install snappy

But I think I now need to link these libraries as I am getting the following error when I attempt to compile my project:

./base/columnfile.h:8:10: fatal error: 'kj/debug.h' file not found

kj is a library included in Capn Pronto. I have tried to link it using the command -lkj when I make, but this does not work.


Solution

  • The error you quote is a compile-time error, not a link-time error. The compiler is unable to find the KJ headers. To fix this, you need to pass -I flags to the compiler indicating where to search for headers. Usually, -I/usr/local/include is what you need, though it depends on where exactly the headers were installed. Or, if you have pkg-config installed, Cap'n Proto registers with it so you can do pkg-config --cflags capnp to determine what flags to pass (and pgk-config --libs capnp for linker flags).