Home >Backend Development >C++ >How Do I Add External Libraries (e.g., Psapi.lib) to My Qt Creator Project?

How Do I Add External Libraries (e.g., Psapi.lib) to My Qt Creator Project?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-18 06:33:091000browse

How Do I Add External Libraries (e.g., Psapi.lib) to My Qt Creator Project?

Incorporating External Libraries into Qt Creator Projects

Adding external libraries to a project created with Qt Creator RC1 (version 0.9.2) requires specific steps for successful integration. This guide will walk you through the process using the example of including the Psapi.lib library for accessing the EnumProcesses() function.

Adding the External Library

To add an external library to your project, modify your project's ".pro" file and specify the library's path and name:

LIBS += -L/path/to -lpsapi

Breakdown:

  • -L: Specifies the directory where the library is located.
  • -l: Specifies the library name without the "lib" prefix or ".dll" extension.

Note: If the library is stored within the project directory, use the $$_PRO_FILE_PWD_ variable to reference its location:

LIBS += -L"$$_PRO_FILE_PWD_/3rdparty/libs/" -lpsapi

This ensures platform compatibility, allowing your project to build correctly across various platforms supported by Qt.

The above is the detailed content of How Do I Add External Libraries (e.g., Psapi.lib) to My Qt Creator Project?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn