【问题标题】:How to build flatbuffers on OSX?如何在 OSX 上构建平面缓冲区?
【发布时间】:2014-08-08 04:10:03
【问题描述】:

我正在尝试在 OSX 上构建平面缓冲区,但我不确定如何准确进行。根据the doc。我应该运行cmake -G "Xcode"。我这样做并得到了结果:

-- 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

但是从那里我不知道该怎么做。我尝试运行make,但收到错误消息make: *** No targets specified and no makefile found. Stop.。知道如何构建它吗?

【问题讨论】:

    标签: c++ xcode macos build flatbuffers


    【解决方案1】:

    而不是 make,只需在 shell 中运行以下命令:

    $ cmakexbuild

    完成后,您将在 ./Debug 文件夹中获得 flatc

    【讨论】:

      【解决方案2】:

      当您运行 cmake 时,您为 Xcode IDE 生成了一个项目(可从 Apple 应用商店下载)。

      如果您想使用 make 构建,请改用此命令:

      cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
      

      之后,

      make
      

      应该按预期工作。

      【讨论】:

        【解决方案3】:

        在 OSX 上,建议使用 Homebrew 安装 flatbuffer 架构编译器。

        brew install flatbuffers
        

        用法:Using the schema compiler

        【讨论】:

        • 我不建议这样做。架构编译器与您使用的库源版本相同很重要,因此最好从同一个 git 存储库构建。
        【解决方案4】:

        按照以下步骤编译 flatbuffer 代码

        【讨论】:

          【解决方案5】:

          Mac-OSX
          确保 Xcode 已经安装在你的机器上。如果没有,执行命令xcode-select --install安装。

          1. 如果您需要最新的更改,请从repo 下载源代码或从here 获取特定版本的源代码下载源

          2. cd flatbuffers 并执行cmake -G "Xcode" -DCMAKE_BUILD_TYPE=Release

            如果遇到类似的错误

            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
            
            

            然后参考这个SO thread
            成功消息是:

            -- Configuring done
            -- Generating done
            -- Build files have been written to: <source-code-path>/standalone/flatbuffers-1.12.0
            
          3. ./FlatBuffers.xcodeproj 或在 xcode 中打开项目

          4. 从 Xcode UI 构建和运行项目

          5. cd Debug你可以看到所有的二进制文件。

          6. 如果您想在全球范围内可用:
            ln -sf &lt;path&gt;/flatbuffers-1.12.0/Debug/flatc /usr/local/bin/flatc

          久经考验
          MacOSX:Mojave,版本:10.14.3、10.14.6
          Xcode:版本:10.2.1(10E1001)、11.1(11A1027)

          注意:确保在项目中使用相同的版本以实现兼容性。
          如果您不确定要选择哪个版本,则可以克隆存储库并转到特定的提交和构建。
          例如对于 1.11 版本,Commit version 是 bf9eb67a。

          【讨论】:

            【解决方案6】:

            FlatBuffers for LINUX(Ubuntu 16) 安装和构建:

            1. cd 根项目文件夹
            2. 纱线加扁
            3. 项目的cd node_modules
            4. rm flatbuffers 文件夹(如果存在)
            5. git 克隆https://github.com/google/flatbuffers.git
            6. cd 平面缓冲区
            7. cmake -G "Unix Makefiles"(如果需要,安装 cmake)
            8. 制作
            9. cd 根项目文件夹
            10. 将 package.json 文件中的命令路径从“./flatc”更改为“./node_modules/flatbuffers/flatc”

            【讨论】:

              猜你喜欢
              • 2022-12-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2014-10-10
              • 2012-08-07
              • 1970-01-01
              • 2012-12-08
              • 1970-01-01
              相关资源
              最近更新 更多