qt creator编译时出现了错误:error: LNK1181: cannot open input file 'debug\main.obj'
问题描述
error: LNK1181: cannot open input file ‘debug\main.obj’。无法打开输入文件debug\main.obj
This is most likely caused by an error in the project settings. Source files (.cpp) are compiled into object files (.o) which are then all linked together. Somehow the linker is failing to find the object files compiled from your source files. I can tell it is looking into debug, but they are being stored somewhere else. Do you have write permissions to that directory?
This problem also occurs if the path of your project (name of any folder) contains a white space.
'The error occurs because the linker in VS2015 can not find the file or the file path defined in the project properties. However, the file path or file in the properties is correct because the linker can handle space character in the file path.
To solve the issue, you just avoid to use space character in the file path or add quotation around file path in project properties.
解决方法
方法一
构建-清理项目,因为一些配置qmake等与源目录相关,直接运行的话会在原来的拷贝目录下生成debug目录和调试文件,切若原目录不存在的话也将重新创建。而不是在当前新文件夹下生成调试文件。
方法二
如果“方法一”不管用,使用重新构建、清楚等命令也无法解决。
当.pro或者.pri文件中的头文件出现如下情况(两个反斜杠)时会出现该问题。
删除一个\即可解决。
HEADERS += \ \
XX1.h \
xx2
# OR
SOURCES += \ \
XX1.cpp \
xx2.cpp \
yy.cpp
方法三
如果“方法一、二”都不管用,可以试试在“项目”设置页面中,取消勾选Shadow build,然后对项目执行qmake”再“构建”,应该能解决。
更新于:5个月前相关文章
- 【说站】java中HttpClient的错误处理
- PHP程序员经常碰到的11个MySQL错误
- uniapp 微信小程序 控制台警告和错误处理
- EasyWeChat 生成小程序码报错 cURL错误 60
- 微擎后台登陆:输入密码错误次数超过5次,请在1小时后再登录
- apache常见错误:VC运行库(找不到 VCRUNTIME140.dll)
- c++运行时报错误:there is a mismatch in alloc and dealloc
- 使用Python的错误计算器
- Python 错误类型
- 修复 Ubuntu 上“E: 无法找到软件包”错误的 5 种方法
- 整数向下转型在运行时遇到错误
- git RPC failed; curl 18 transfer closed with outstanding read data remaining 是什么错误?
- Qt编译报错:error: LNK1181: cannot open input file 'debugmain.obj'
- vscode通过Remote-SSH插件连接Linux时报Error: XHR failed错误
- 独立页管理生成静态后的图片路径错误问题
- 单篇文章独立页面管理生成静态后的图片路径错误问题