Home > The Unit Test Framework > Compilation > Standalone library compilation
PrevNext

Standalone library compilation

If you opted to link your program with the standalone library, you need to build it first. To build a standalone library the all C++ files (.cpp), that constitute UTF implementation need to be listed as source files in your makefile[3].
如果你選擇將你的程序鏈接到獨立的庫,你首先需要生成它。 要生成獨立的庫,所有組成 UTF實現都需要作為源文件列在你自己的 makefile[3] 中。

The Jamfile for use with Boost.Build system is supplied in libs/test/build directory. The UTF can be built as either static or dynamic library.
Boost.Build 系統使用的 Jamfile 在 libs/test/build 目錄下。 UTF 可以被編譯為 靜態庫或動態庫。

Static library compilation

No special build options or macro definitions are required to build the static library. Using the Boost.Build system you can build the static library with the following command from libs/test/build directory:
生成靜態庫不需要額外的編譯選項或宏定義。使用 Boost.Build 系統你可以從 libs/test/build 目錄運行如下的命令生成靜態庫:

bjam [-sTOOLS=<your-tool-name>] {-sBUILD=boost_unit_test_framework}

Also on Windows you can use the Microsoft Visual Studio .NET project file provided.
Windows 平台上你也可以使用提供的 Microsoft Visual Studio .NET 工程文件。

Dynamic library compilation

To build the dynamic library[4] you need to add BOOST_TEST_DYN_LINK to the list of macro definitions in the makefile. Using the Boost.Build system you can build the dynamic library with the following command from libs/test/build directory:
要生成動態庫[4]你需要在 makefile 的宏定義中加入 BOOST_TEST_DYN_LINK。 使用 Boost.Build 系統你可以從 libs/test/build 目錄運行如下的命令生成動態庫:

bjam [-sTOOLS=<your-tool-name>] {-sBUILD=boost_unit_test_framework}

Also on Windows you can use the Microsoft Visual Studio .NET project file provided.
在 Windows 平台上同樣可以使用提供的 Microsoft Visual Studio .NET 工程文件。

[Important] Important

For test module to successfully link with the dynamic library the flag BOOST_TEST_DYN_LINK needs to be defined both during dynamic library build and during test module compilation.
要使測試模塊能夠成功鏈接到動態庫,標籤 BOOST_TEST_DYN_LINK 需要同時定義在動態庫生成和測試模塊編譯過程中。



[3] There are varieties of make systems that can be used. To name a few: GNU make (and other make clones) and build systems integrated into IDEs (for example Microsoft Visual Studio). The Boost preferred solution is Boost.Build system that is based on top of bjam tool. Make systems require some kind of configuration file that lists all files that constitute the library and all build options. For example the makefile that is used by make, or the Microsoft Visual Studio project file, Jamfile is used by Boost.Build. For the sake of simplicity let's call this file the makefile.
有多種生成系統可以使用。例如:GNU make (包括其它變種) 以及集成在 IDE 中的 (例如 Microsoft Visual Studio)。 Boost 推薦的解決方案是基於 bjam 工具的 Boost.Build 系統。 生成系統都需要某種類型的配置文件列出所有文件和生成選項。 例如 makefile 由 make 使用,Microsoft Visual Studio 工程文件,Jamfile 由 Boost.Build 使用。 為了簡化起見,我們把這類文件都叫做 makefile。

[4] What is meant by the term dynamic library is a dynamically loaded library, alternatively called a shared library.
動態庫指動態加載庫,或者叫做共享庫


PrevUpHomeNext