To recap the process needed to use a library:
Once per library:
1) Acquire the library. Download it from the website or via a package manager.
2) Install the library. Unzip it to a directory or install it via a package manager.
3) Tell the compiler where to look for the header file(s) for the library.
4) Tell the linker where to look for the library file(s) for the library.
Once per project:
5) Tell the linker which static or import library files to link.
6) #include the library’s header file(s) in your program.
7) Make sure the program know where to find any dynamic libraries being used.
Steps 1 and 2 — Acquire and install library
Download and install the library to your hard disk. See the tutorial on static and dynamic libraries for more information about this step.
Steps 3 and 4 — Tell the compiler where to find headers and library files
We are going to do this on a global basis so the library will be available to all of our projects. Consequently, the following steps only need to be done once per library.
A) Go to the “Tools menu” and pick “Options”.
B) Open the “Projects and Solutions” node, and click on “VC++ Directories”.
C) In the upper right under “Show directories for:”, pick “Include Files”. Add the path to the .h files for the library.
D) In the upper right under “Show directories for:”, pick “Library Files”. Add the path to the .lib files for the library.
E) Click “OK”.
Step 5 — Tell the linker which libraries your program is using
For step 5, we need to add .lib files from the library to our project. We do this on an individual project basis. Visual Studio offers us 3 different methods for adding .lib files to our project.
A) Use a #pragma preprocessor directive to your primary .cpp file. This solution only works with Visual Studio and is non-portable. Other compilers will ignore this line.
B) Add the .lib file to your project as if it were a .cpp or .h file. This solution works with Visual Studio, but not with many other compilers. This is the solution we recommend.
C) Add the library to the linker input. This is the most “portable” solution in the sense that every IDE will provide a similar mechanism. If you ever move to another compiler or IDE, this is the solution you will have to use. This solution requires 5 steps:
C-1) In the Solution Explorer, right click on the bolded project name and choose “Properties” from the menu.
C-2) Under the “Configuration:” dropdown, select “All Configurations”.
C-3) Open the “Configuration Properties” node, the “Linker” node, and click on “Input”.
C-4) Under “Additional Dependencies”, add the name of your library.
C-5) Click “OK”.
Steps 6 and 7 — #include header files and make sure project can find DLLs
Simply #include the header file(s) from the library in your project.
See the tutorial on static and dynamic libraries for more information step 7.
相关推荐
### Visual Studio 2005 下 OpenGL 配置详解 #### 一、概述 在进行图形编程时,OpenGL 是一个非常强大的跨语言、跨平台的图形应用程序接口(API)。为了能够在 Visual Studio 2005 这样的集成开发环境中顺利使用 ...
### 在Visual Studio 2005下建立OpenGL开发环境 #### 一、前言 OpenGL是一种广泛应用于2D和3D图形渲染的强大图形API。它不仅适用于多种操作系统,包括Windows、Unix/Linux等,而且在图形处理领域享有极高的声誉。...
不建议用户安装Visual Studio 2005,因为和Intel Visual Fortran的集成性不是很好;建议完整安装Intel Visual Fortran编译器自带的帮助文件,尤其是Windows窗口程序设计的开发人员。 Intel Visual Fortran中的项目...
在使用Visual Studio创建Qt项目时,可能会遇到一个常见的错误:“Unable to find a Qt build”。这个错误通常表示Visual Studio无法找到已安装的Qt编译环境,导致无法正确配置项目设置。以下是一步步解决这个问题的...
在本文中,我们将深入探讨如何在Visual Studio 2019中配置OpenGL环境,以便能够进行OpenGL编程。OpenGL是一个跨语言、跨平台的图形库,用于渲染2D、3D矢量图形。Visual Studio 2019是Microsoft提供的一款强大的开发...
### Visual Studio 2012 Cookbook 知识点解析 #### 一、书籍基本信息 - **书名**:《Visual Studio 2012 Cookbook》 - **页数**:272页 - **出版社**:Packt Publishing - **出版时间**:2012年9月 - **语言**:...
- Visual Studio 2013和cygwin是构建环境的主要工具。 - 环境搭建是进行webkit开发的第一步,确保后续开发工作的顺利进行。 2. **操作系统版本兼容性问题**: - 说明了在Windows 7和Windows 8.1环境下搭建webkit...
【标题】"Gitee.VisualStudio.rar" 指的是一个包含与Gitee集成的Visual Studio相关资源的压缩文件。Gitee是中国的一个开源代码托管平台,类似于GitHub,它允许开发者存储、管理和协作开发代码。而Visual Studio是...
The biggest problem with the Microsoft default code generator is that the generated constructor is protected, which means that it can’t be used to construct strongly-typed resources in Visual Studio ...
Build Tools for Visual Studio 2015 These Build Tools allow you to build native and managed MSBuild-... There are options to install the Visual C++ compilers and libraries, MFC, ATL, and C++/CLI support.
CMake不直接构建软件,而是生成特定构建工具(如Visual Studio,Makefile或Xcode)所需的本地项目文件。在本示例中,我们将探讨如何使用CMake与Microsoft Visual Studio进行集成开发。 首先,CMake使用CMakeLists....
在这篇文章中,作者Petri Tanska博士为我们详细介绍了如何在Windows 10系统下搭建ABAQUS 2017与Intel Parallel Studio XE2016 (Visual Fortran)的集成开发环境。知识点主要围绕在Windows环境下进行UMAT/VUMAT二次...
### SYSTEMC™ WITH VISUAL ELITE #### 一、概述 **SYSTEMC™ WITH VISUAL ELITE** 是一份由Summit Design, Inc.提供的培训材料,主要针对的是SystemC™与Visual Elite这两种工具的结合使用。该文档包含了多个实验...
Title: Beginning Visual ...* Covers class libraries, Windows Forms, graphics programming, accessing databases, Web programming with ASP.NET and Visual Basic, data access, SQL Server, ADO.NET, and XML
### MeasurementStudio用户控件技术在Visual C++中的应用 #### 概述 本文探讨了Measurement Studio用户控件技术在Visual C++开发环境中的应用。针对专业性较强的测试和控制应用程序开发,Measurement Studio(以下...
It starts with installing and configuring Android Studio. You're getting to know the new IDE and his Editor. You learn how to create new Android projects from scratch, import projects of different ...
注意,不要使用Visual Studio 2005,因为与Intel Visual Fortran的兼容性较差。 2. **创建新项目**:启动Visual Studio 2008后,选择“文件”->“新建”->“项目…”,然后在对话框中选择合适的项目类型和模板。...