How to Fix 'Permission Denied' Error When Using Boost Libraries in a qmake Project with Qt Creator (Boost 1.53.0, VS2012)
Integrating Boost libraries into a Qt Creator project using qmake is a common task for C++ developers, but it can sometimes lead to frustrating errors like "Permission Denied." This error is particularly tricky because it rarely stems from actual OS-level permission issues alone; instead, it often masks underlying problems with library paths, build configurations, or compiler/linker mismatches.
If you’re working with Boost 1.53.0, Qt Creator, and Visual Studio 2012 (VS2012), this guide will walk you through diagnosing and resolving the "Permission Denied" error step-by-step. We’ll cover everything from verifying your Boost installation to configuring your qmake project file and ensuring compatibility between toolsets.
Table of Contents#
- Understanding the "Permission Denied" Error
- Prerequisites
- Step-by-Step Troubleshooting
- Common Pitfalls to Avoid
- Conclusion
- References
Understanding the "Permission Denied" Error#
In the context of Qt Creator and Boost integration, "Permission Denied" is often a misleading error message. While it can indicate OS-level file access issues (e.g., read/write restrictions), it more commonly signals:
- The linker cannot find Boost libraries (due to incorrect paths or missing files).
- Mismatched build configurations (e.g., 32-bit vs. 64-bit, debug vs. release).
- Corrupted or improperly built Boost libraries.
- Typos in library names or paths in the qmake project file.
Boost 1.53.0 and VS2012 add specific nuances: Boost libraries for VS2012 use the vc110 toolset tag (e.g., libboost_system-vc110-mt-gd-1_53.lib), and Qt Creator must use the same MSVC 2012 compiler to link successfully.
Prerequisites#
Before troubleshooting, ensure you have:
- Qt Creator installed (tested with 4.8+, but compatible versions should work).
- Boost 1.53.0 built with VS2012 (see Boost’s installation guide for build steps).
- Visual Studio 2012 (or the MSVC 2012 compiler tools) installed (required for linking Boost libraries).
- A basic understanding of qmake syntax (e.g.,
INCLUDEPATH,LIBSvariables).
Step-by-Step Troubleshooting#
3.1 Verify Boost Installation and Library Paths#
First, confirm Boost is installed and built correctly.
3.1.1 Locate Boost Files#
Boost libraries are typically installed in a directory like:
C:\boost_1_53_0
Within this, you’ll need:
- Include files:
C:\boost_1_53_0\boost(header-only libraries live here). - Compiled libraries:
C:\boost_1_53_0\lib32-msvc-11.0(for 32-bit) orlib64-msvc-11.0(for 64-bit).
3.1.2 Check Library Naming Conventions#
Boost libraries for VS2012 follow a strict naming pattern. For example:
- Debug, static, multi-threaded:
libboost_system-vc110-mt-gd-1_53.libvc110: Toolset (VS2012 = MSVC 11.0).mt: Multi-threaded.gd: Debug build (omit for release:mt-instead ofmt-gd-).1_53: Boost version (1.53.0).
If your project uses, say, Boost.System, ensure libboost_system-vc110-mt-gd-1_53.lib (debug) or libboost_system-vc110-mt-1_53.lib (release) exists in the lib32-msvc-11.0 folder.
3.2 Check qmake Project File (.pro) Configuration#
The qmake .pro file tells Qt Creator where to find Boost headers and libraries. A misconfigured .pro is the most common cause of "Permission Denied."
3.2.1 Set INCLUDEPATH for Boost Headers#
Add the Boost include directory to INCLUDEPATH so the compiler can find Boost headers:
INCLUDEPATH += "C:/boost_1_53_0" # Path to your Boost root 3.2.2 Set LIBS for Boost Libraries#
Use LIBS to specify the Boost library directory and individual libraries. For 32-bit debug builds:
# Replace with your Boost library path
LIBS += -LC:/boost_1_53_0/lib32-msvc-11.0
# List required Boost libraries (example: Boost.System and Boost.Thread)
LIBS += -lboost_system-vc110-mt-gd-1_53
LIBS += -lboost_thread-vc110-mt-gd-1_53 -L: Specifies the library directory (note the forward slashes, even on Windows).-l: Links against a specific library (omit the.libextension).
For Release Builds: Use non-debug libraries (remove -gd):
LIBS += -lboost_system-vc110-mt-1_53
LIBS += -lboost_thread-vc110-mt-1_53 3.2.3 Example .pro File#
A complete example for a debug project using Boost.System:
QT += core
QT -= gui
TARGET = BoostTest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
# Boost configuration
INCLUDEPATH += "C:/boost_1_53_0"
LIBS += -LC:/boost_1_53_0/lib32-msvc-11.0
LIBS += -lboost_system-vc110-mt-gd-1_53 3.3 Inspect File and Directory Permissions#
Even with correct paths, "Permission Denied" can occur if Qt Creator lacks read access to Boost files or write access to the build directory.
3.3.1 Check Boost Directory Permissions#
- Right-click your Boost root folder (e.g.,
C:\boost_1_53_0) → Properties → Security. - Ensure your user account has Read & execute permissions.
- If missing, click Edit → Add, enter your username, and grant
Read & executeaccess.
3.3.2 Check Build Output Directory Permissions#
Qt Creator outputs binaries to a debug or release folder in your project directory. Ensure this folder is not read-only:
- Right-click the
debugfolder → Properties → Uncheck "Read-only" → Apply.
3.4 Ensure Build Configuration Compatibility#
Mismatched configurations (e.g., 32-bit vs. 64-bit, debug vs. release) will prevent linking and may trigger "Permission Denied."
3.4.1 Verify Qt Kit Compiler#
Qt Creator uses "kits" to manage compilers and build tools. Ensure your kit uses the MSVC 2012 compiler:
- Open Qt Creator → Tools → Options → Kits.
- Select your active kit (e.g., "Desktop Qt 5.9.9 MSVC2012 32bit").
- Under "Compiler," confirm "C++ Compiler" is set to "Microsoft Visual C++ Compiler 11.0 (x86)".
3.4.2 Match Boost Architecture and Build Type#
- If Boost is built for 32-bit (in
lib32-msvc-11.0), use a 32-bit Qt kit. - Use debug Boost libraries (with
-gd) only in Qt’s Debug mode; use release libraries in Release mode.
3.5 Clean and Rebuild the Project#
Stale build files can cause misleading errors. Clean and rebuild to ensure a fresh build:
- In Qt Creator: Build → Clean All (removes old object files).
- Build → Rebuild All (recompiles and relinks from scratch).
3.6 Test with a Minimal Example#
Isolate the issue by creating a minimal project. Create a new "Qt Console Application" and replace main.cpp with:
#include <boost/system/error_code.hpp>
#include <iostream>
int main() {
boost::system::error_code ec;
std::cout << "Boost error code: " << ec.value() << std::endl;
return 0;
} Configure the .pro file as in 3.2.3 and build. If the error persists, the issue is systemic (e.g., Boost not built correctly). If it works, the problem lies in your original project’s configuration.
Common Pitfalls to Avoid#
- Typos in Library Names: Boost library names are case-sensitive and use hyphens/underscores (e.g.,
vc110notvc11,1_53not1.53). - Incorrect Boost Build: Forgetting to build Boost with
--toolset=msvc-11.0(runbootstrap.batthenb2 toolset=msvc-11.0in the Boost root). - Mixing Debug/Release Libraries: Using debug Boost libraries in a Qt release build (or vice versa) causes linker failures.
- 64-bit/32-bit Mismatch: Boost built for 64-bit (in
lib64-msvc-11.0) won’t link with a 32-bit Qt kit.
Conclusion#
Fixing "Permission Denied" when integrating Boost 1.53.0 with Qt Creator and VS2012 requires methodical checks:
- Verify Boost is installed, built, and named correctly.
- Ensure the
.profile has validINCLUDEPATHandLIBSentries. - Confirm file/directory permissions and build configuration compatibility.
- Clean, rebuild, and test with a minimal example to isolate issues.
By following these steps, you’ll resolve the error and ensure smooth Boost integration.