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.
make: *** No targets specified and no makefile found. Stop.
. Any idea how to build it?
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
Follow the below steps to compile the flatbuffer code
For Mac-OSX
Make sure Xcode is already installed in your machine. If not, install it by executing command xcode-select --install
.
If you need latest changes download source code from repo or to get source code for a particular version download source from here
cd flatbuffers
and execute cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release
If you encounter error like
CMake Warning: No source or binary directory provided. Both will be assumed to be the same as the current working directory, but note that this warning will become a fatal error in future CMake releases. -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:6 (project): No CMAKE_C_COMPILER could be found. CMake Error at CMakeLists.txt:6 (project): No CMAKE_CXX_COMPILER could be found. -- Configuring incomplete, errors occurred! See also "<sourc-code-path>/flatbuffers-1.12.0/CMakeFiles/CMakeOutput.log". See also "<sourc-code-path>/flatbuffers-1.12.0/CMakeFiles/CMakeError.log". Inside the log file CMakeError.log: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
then refer this SO thread
success message is :
-- Configuring done -- Generating done -- Build files have been written to: <source-code-path>/standalone/flatbuffers-1.12.0
./FlatBuffers.xcodeproj
or open project in xcode
Build and Run project from Xcode UI
cd Debug
and you can see all the binaries present.
If you want to to be available globally:
ln -sf <path>/flatbuffers-1.12.0/Debug/flatc /usr/local/bin/flatc
Tried and Tested on
MacOSX: Mojave, version: 10.14.3, 10.14.6
Xcode: Version: 10.2.1(10E1001), 11.1(11A1027)
Note: Make sure you use the same version in a project for compatibility.
If you are not sure which version to pick, then you can clone the repo and go to a specific commit and build.
For eg For version 1.11, Commit version is bf9eb67a.
FlatBuffers for LINUX(Ubuntu 16) install and build:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.