• 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有点麻烦,太菜了,就这样了。

  • 相关阅读:
    Part2_扩展MATSIM_Subpart13_开发过程和自己的模块_第45章 如何编写自己的扩展并可能将其贡献给Matsim
    【计算机网络】——数据链路层(应用:局域网、广域网、设备 )
    mongodb(快速上手)(一)
    File的遍历文件
    系统启动流程
    Centos根目录空间占满的解决思路
    电脑重装系统后如何设置 win11 的默认登录方式
    mongodb 性能优化
    CANN算子:利用迭代器高效实现Tensor数据切割分块处理
    【性能测试】JMeter:集合点,同步定时器的应用实例!
  • 原文地址:https://blog.csdn.net/DavieChars/article/details/133929776