I'm trying to build flatbuffers on OSX but I'm not sure how to proceed exactly. According to the doc. I should run cmake -G "Xcode"
. I did that and got the result:
-- The C compiler identification is Clang 5.1.0
-- The CXX compiler identification is Clang 5.1.0
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Xcode
-- Check for working CXX compiler using: Xcode -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: Temp/flatbuffers
However from there I'm not sure what to do. I've tried to run make
but got the error message make: *** No targets specified and no makefile found. Stop.
. Any idea how to build it?
FlatBuffers supports both reading and writing FlatBuffers in C++. To use FlatBuffers in your code, first generate the C++ classes from your schema with the --cpp option to flatc . Then you can include both FlatBuffers and the generated code to read or write FlatBuffers.
A FlatBuffer is a binary file and in-memory format consisting mostly of scalars of various sizes, all aligned to their own size. Each scalar is also always represented in little-endian format, as this corresponds to all commonly used CPUs today.
The flatcc compiler is implemented as a standalone tool instead of extending Googles flatc compiler in order to have a pure portable C library implementation of the schema compiler that is designed to fail graciously on abusive input in long running processes.
Instead make
, just run following command in the shell:
$ cmakexbuild
After it finish you will get flatc
in ./Debug folder.
When you ran cmake, you generated a project for the Xcode IDE (downloadable from the Apple app store).
If you want to build using make, use this command instead:
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
After that,
make
should work as intended.
On OSX it's recommended to use Homebrew to install the flatbuffer schema compiler.
brew install flatbuffers
Usage: Using the schema compiler
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With