一、现象
在本地打开一个其他工作站上的Qt工程,按运行提示错误信息如下:
21:30:20: 为项目timer执行步骤 ...
21:30:20: Could not create directory "E:\program\qt\timer\build-E:programqtu0009imeru0009imeru0009imer-Desktop_Qt_5_9_9_MSVC2015_64bit-Debug"
Error while building/deploying project timer (kit: Desktop Qt 5.9.9 MSVC2015 64bit)
When executing step "qmake"
21:30:20: Elapsed time: 00:00.
21:30:20: 为项目timer执行步骤 ...
21:30:20: Could not create directory "E:\program\qt\timer\build-E:programqtu0009imeru0009imeru0009imer-Desktop_Qt_5_9_9_MSVC2015_64bit-Debug"
Error while building/deploying project timer (kit: Desktop Qt 5.9.9 MSVC2015 64bit)
When executing step "qmake"
21:30:20: Elapsed time: 00:00.
二、分析
首先明确此错误在run时触发,其次在run前的build阶段出错,接着是执行qmake时触发,最后提示使用的kit是Desktop Qt 5.9.9 MSVC2015 64bit。
三、解决
3.1开发栏中切换至设计模式
如图:
此处根据shadow build的path可以知道,在本地是使用5.9.9进行build。
3.2打开文件夹目录
可看到曾经build过5.14.2版本程序且有发布release版本,因此确定是build版本问题。
3.3将shadow build关闭,使用本地环境重新build
3.4按F5尝试运行
运行正常:
21:30:04: Debugging E:\program\qt\timer\timer\debug\timer.exe ...
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
21:30:07: Debugging of E:\program\qt\timer\timer\debug\timer.exe has finished.
21:40:54: Debugging E:\program\qt\timer\timer\debug\timer.exe ...
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
21:30:04: Debugging E:\program\qt\timer\timer\debug\timer.exe ...
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
21:30:07: Debugging of E:\program\qt\timer\timer\debug\timer.exe has finished.
21:40:54: Debugging E:\program\qt\timer\timer\debug\timer.exe ...
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
四、总结
在不同工作站上使用工程时,应首先注意版本问题,特别是在低版本打开高版本这种情况下极易发生各种兼容性问题。因此,能本地重新编译就重新编译,只要源码没问题就行。
另外,shadow build的作用是将build前后的代码文件分隔开,使工程看起来更立体,方便源码文件管理而已,默认开启。也有一种说法是可以使用一份源码文件编译出不同环境的文件。