Documentation is unclear : what is the use/purpose of flatbuffers.lib ?
Hi!
flatbuffers is working great for me in C++.
But the documentation, that is very clear on almost everything, is unclear to me about flatbuffers.lib and its usage.
https://google.github.io/flatbuffers/flatbuffers_guide_building.html has a section "Using FlatBuffers in your own projects" stating
For C++, there is usually no runtime to compile, as the code consists of a single header, include/flatbuffers/flatbuffers.h.
And obiously it's working fine this way.
If I use some other flatc switch, say --python or --rust, it generates a python module subdirectory or a .rs file.
So what is the use of flatbuffers.lib ? Is it only useful for test as in https://github.com/google/flatbuffers/blob/master/tests/test.cpp ? Or is it only used by language bindings to implement the python module or the rust crate ? What's the use in "everyday" C++ app ?
With help of flatbuffer library you can use generator and parser of flatbuffers out of your executable. For example you can convert bfbs files to json schema, fbs files to generated access header for all programming languages and so on.
If you only want to use a specific flatbuffers in your source code you don't need flatbuffers.lib at all. It's enough to include the generated header or in other languages to use generated files.
Thanks for confirmation !
BTW it's also obvious to me now why there is FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" : One could only use the lib and never compile a .fbs.
I was concerned by the FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library" in CMakeLists.txt when choosing what CMake flags to set.
Why would I build the lib if it is not used in projects (I'm doing neither live parser/generator creation nor introspection) ?
So :
- Maybe be add a one-liner comment in CMakeLists about the purpose of this library ?
- Why is it ON by default ? Aren't most use cases "classic" serialization/deserialization, and live generation or instrospection the exception ?
We can probably default it to OFF, though it may break people now who expect it ON. Though the fix for that is simple.
I would welcome a PR to add the comment and switch the default to OFF.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.
This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.