- Building Computer Vision Projects with OpenCV 4 and C++
- David Millán Escrivá Prateek Joshi Vinícius G. Mendon?a Roy Shilkrot
- 256字
- 2021-07-02 12:28:31
Creating a library
CMake allows us to create libraries used by the OpenCV build system. Factorizing shared code among multiple applications is a common and useful practice in software development. In big applications, or common code shared in multiple applications, this practice is very useful. In this case, we do not create a binary executable, but instead we create a compiled file that includes all the functions, classes, and so on. We can then share this library file with other applications without sharing our source code.
CMake includes the add_library function to this end:
# Create our hello library add_library(Hello hello.cpp hello.h) # Create our application that uses our new library add_executable(executable main.cpp) # Link our executable with the new library target_link_libraries(executable Hello)
The lines starting with # add comments and are ignored by CMake. The add_library (Hello hello.cpp hello.h) command defines the source files of our library and its name, where Hello is the library name and hello.cpp and hello.h are the source files. We add the header file too to allow IDEs such as Visual Studio to link to the header files. This line is going to generate a shared (.so for Mac OS X, and Unix or .dll for Windows) or static library (.a for Mac OS X, and Unix or .lib for Windows) file, depending on whether we add a SHARED or STATIC word between library name and source files. target_link_libraries(executable Hello) is the function that links our executable to the desired library, in our case, the Hello library.
- Word 2010中文版完全自學手冊
- 輕松學大數據挖掘:算法、場景與數據產品
- Architects of Intelligence
- Access 2007數據庫應用上機指導與練習
- 醫療大數據挖掘與可視化
- WS-BPEL 2.0 Beginner's Guide
- 深入淺出 Hyperscan:高性能正則表達式算法原理與設計
- Google Cloud Platform for Developers
- 區塊鏈+:落地場景與應用實戰
- MySQL技術內幕:InnoDB存儲引擎
- Access 2010數據庫應用技術教程(第二版)
- 量化投資:交易模型開發與數據挖掘
- Trino權威指南(原書第2版)
- 數據產品經理寶典:大數據時代如何創造卓越產品
- SQL Server 2012數據庫技術及應用(第4版)