• VS2019编译一个带qrc项目时出现的问题


    问题

    跑中科大付老师的一个参数化的代码,原来的项目可能是用VS2015写的,编译的时候报错

    严重性	代码	说明	项目	文件	行	禁止显示状态
    错误	MSB8066	“surfacemeshprocessing.qrc”的自定义生成已退出,代码为 3。	Surface_Mesh	C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets	249	
    
    • 1
    • 2

    查了半天始终找不到解决方案,后来在log里发现执行这句的时候实际上执行的是

    \bin\rcc.exe surfacemeshprocessing.qrc balabala
    
    • 1

    在项目设置里始终找不到在哪里有相关的设置,实在没办法直接用VSCode打开项目文件夹,全局搜索surfacemeshprocessing.qrc,找到了下面的内容:

      <ItemGroup>
        <CustomBuild Include="surfacemeshprocessing.qrc">
          <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(FullPath);%(AdditionalInputs)AdditionalInputs>
          <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Rcc%27ing %(Identity)...Message>
          <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)Outputs>
          <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cppCommand>
          <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(FullPath);%(AdditionalInputs)AdditionalInputs>
          <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Rcc%27ing %(Identity)...Message>
          <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)Outputs>
          <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cppCommand>
          <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(FullPath);%(AdditionalInputs)AdditionalInputs>
          <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Rcc%27ing %(Identity)...Message>
          <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)Outputs>
          <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cppCommand>
          <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(FullPath);%(AdditionalInputs)AdditionalInputs>
          <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Rcc%27ing %(Identity)...Message>
          <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)Outputs>
          <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cppCommand>
        CustomBuild>
      ItemGroup>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    在这里看得就比较清晰了,原因是 $(QTDIR) 这个变量是空的,但很奇怪的是我安装了QT VS tools扩展,并且正确设置了QT路径:
    在这里插入图片描述

    在Visual Studio的开发者powershell里 $(QTDIR) 也是正确的值。
    再进一步查看了一下原始的内容,发现是要在.user文件里设置了旧的环境变量,或者叫宏,要更新一下。

    解决方案

    要么把原来的.user文件删掉,在系统环境变量里自己加 $QTDIR 。要更改我也不知道咋整,直接改文件可能可以,通过GUI有点麻烦,太菜了,就这样了。

  • 相关阅读:
    vue开发,如何结合chatgpt
    淘宝开店装修教程 (2023新版)
    内核驱动踩坑记录
    SpringBoot整合minio分布式文件实操
    Linux:CentOS7 开启路由转发
    深入理解操作系统——cpu处理机调度详解
    lift-splat-shoot(LSS)代码详解
    Python实现Stacking回归模型(随机森林回归、极端随机树回归、AdaBoost回归、GBDT回归、决策树回归)项目实战
    一键自动化数据分析!快来看看 2022 年最受欢迎的 Python 宝藏工具库!
    计算数组中各元素的平方numpy.square()
  • 原文地址:https://blog.csdn.net/DavieChars/article/details/133929776