buck

Difference between cxx_binary() and cxx_library()


What is the difference between the two? On the documentation, they seem to have the same arguments? Do they do the same thing? I haven't been able to find much info about Buck besides the official documentation.


Solution

  • A cxx_library is a C or C++ (or Objective C) library that might be compiled static or shared.

    A cxx_binary is a C or C++ (or Objective C) executable. You can run the result of a cxx_binary, both outside of Buck and inside a genrule.

    A cxx_binary must contain a translation-unit (srcs) that provides a main function, since this will be the entry-point for the executable.

    In terms of arguments, the big difference is that a cxx_library has exported_headers. These are headers that any library that depends on it are provided access to.

    You might find this interesting: https://github.com/njlr/buckaroo-protobuf-example