简体   繁体   中英

How Should I Include Bond in C++ Visual Studio Project?

I'm following the C++ on Windows instructions on https://github.com/Microsoft/bond/ but it isn't clear how to include and use Bond from a native C++ project in Visual Studio. I've read both that Bond needs to be compiled as part of my project and that I should use Bond's .lib file to speed up builds. What are the correct steps after I download all the dependencies and get CMake to build Bond so that I can get sample code from the documentation working in my project? I want to run and debug code which uses Bond from within Visual Studio. Thanks

This answer has now been incorporated into the Bond C++ documentation: Integrating Bond into your build . Relevant excerpts:

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 (eg, 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> .

You will need to adapt these for your chosen build system.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM