You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Qt Creator编译简单项目出现multiple target patterns错误求助

Fixing "multiple target patterns. Stop" Error in Qt Creator with QRC Files

Hey, I’ve run into this exact frustrating issue before with Qt Creator on Windows—those weird extra lines in the Makefile that keep coming back even after you delete them are almost always tied to problems with your .qrc file, path handling, or encoding conflicts. Let’s break down how to fix this properly:

Step 1: Audit Your .qrc File

First, open up stylesheet.qrc and double-check every entry in it:

  • Make sure the path to login.qss is correct (relative to the qrc file’s location). If you moved files around recently, the relative path might be broken.
  • Look for any accidental extra lines in the qrc—like if you pasted a command or system info into the file by mistake. The qrc should only have XML-style entries for your resources, not raw commands like rcc.exe or code page info.
  • If the path has spaces (though your example doesn’t show this), wrap the path in quotes in the qrc to avoid parsing issues.

Step 2: Wipe Build Cache Completely

Don’t just delete the Makefile—nuke the entire build directory for your project:

  • In Qt Creator, go to Build > Clean All first.
  • Then navigate to your project’s build folder (usually something like build-YourProject-Desktop_Qt_5_14_0_MinGW_64_bit-Debug) and delete it manually.
  • Restart Qt Creator, run qmake (right-click project > Run qmake), then build again. This ensures no stale cached configs are generating the broken Makefile lines.

Step 3: Fix Encoding Conflicts

The Active code page: 65001 line hints at UTF-8 encoding issues on Windows:

  • In Qt Creator, go to Tools > Options > Text Editor > Behavior. Set the default encoding to UTF-8 and uncheck "Add UTF-8 BOM" (some Windows tools don’t handle BOM well).
  • Save your .qrc and .qss files again with this encoding. Sometimes mismatched encoding can cause qmake to inject unexpected system info into the Makefile.
  • If you’re feeling bold, temporarily switch your system’s active code page to GBK (run chcp 936 in Command Prompt) and try building—this can work around edge cases where UTF-8 system encoding clashes with Qt’s build tools.

Step 4: Force Proper RCC Command Escaping in .pro File

Add this line to your project’s .pro file to ensure qmake generates a correctly escaped rcc command:

RCC_CMD = $$quote($$[QT_INSTALL_BINS]/rcc.exe)

This tells qmake to wrap the rcc path in quotes, preventing spaces or special characters from breaking the Makefile target definition.

Step 5: Update Qt (If Possible)

Qt 5.14.0 has a few known bugs with Makefile generation for resource files on MinGW. Try upgrading to the latest patch release in the 5.14.x series (like 5.14.2)—the Qt team fixed several path-handling issues that could cause this exact problem.

Why This Happens

The error multiple target patterns occurs because Make expects lines in the format target: dependencies, but the extra lines in your Makefile are mangling that structure. The rcc.exe path and code page info are being incorrectly added as dependencies for qrc_stylesheet.cpp, which Make can’t parse as a valid target pattern. Deleting those lines fixes it temporarily, but qmake regenerates the broken lines from cached configs or flawed qrc/project settings until you address the root cause.

内容的提问来源于stack exchange,提问作者Richard Li

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 20:49:08