gpt4 book ai didi

c++ - 我应该如何在 C++ Visual Studio 项目中包含 Bond?

转载 作者:行者123 更新时间:2023-11-28 04:52:46 24 4
gpt4 key购买 nike

我在 https://github.com/Microsoft/bond/ 上遵循 Windows 上的 C++ 说明但不清楚如何在 Visual Studio 中包含和使用 native C++ 项目中的 Bond。我读过 Bond 需要作为我的项目的一部分进行编译,并且我应该使用 Bond 的 .lib 文件来加速构建。在我下载所有依赖项并让 CMake 构建 Bond 之后,正确的步骤是什么,以便我可以从我的项目中工作的文档中获取示例代码?我想在 Visual Studio 中运行和调试使用 Bond 的代码。谢谢

最佳答案

此答案现已合并到 Bond C++ 文档中:Integrating Bond into your build .相关摘录:

To consume Bond, you will need to integrate it into your build somehow. If you are using one of these C++ package managers, Bond is available as a package that you can consume:

What follows are build-system agnostic instructions for consuming C++ Bond.

These instructions assume that you have used Bond's CMake-based build to compile and install (make install/cmake --build . --target INSTALL) Bond into your development environment somewhere. The CMake variable CMAKE_INSTALL_PREFIX can be used to control where the install target places the output files.

(The Bond CMake files can't currently be consumed by another CMake project via add_directory. Contributions encouraged to help improve this situation.)

After you've built and installed Bond, you can use whatever build system you need by

  1. teaching it how to automatically run code generation on .bond files;
  2. configuring your C++ compiler's #include search path to point at Boost and Bond; and
  3. configuring your linker's library path to have the Boost and Bond libraries on its search path.

Step #1 is very build system dependent. Contributions of these build systems rules to the Bond repository will be happily accepted.

When building the library/executable that is going to use Bond, you'll need to set your compiler's #include search path to point to:

  • where your version of Boost is installed
  • where your version of Bond is installed

If you use any types from bond.bond (e.g., by using an import statement in your .bond file or by using the C++ RuntimeSchema APIs), you will also need to link the library/executable with Bond (The names may vary depending on platform/toolset.):

  • libbond.a/bond.lib and
  • optionally, libbond_apply.a/bond_apply.lib, if you plan to #include <bond/core/bond_apply.h>.

您需要为您选择的构建系统调整这些。

关于c++ - 我应该如何在 C++ Visual Studio 项目中包含 Bond?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47804181/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com