"LNK1104: cannot open file mclmcrrtd.lib" Qt Creator 错误
"LNK1104: cannot open file mclmcrrtd.lib" Error in Qt Creator
我通过使用 MRC(MATLAB 运行时编译器)编译我在 MATLAB 中开发的应用程序生成了 *.dll
动态-link 库文件。我在Qt Creator 环境中使用MSVC 编译器和qmake 工具集分发and/or 使用我在Windows OS 环境中用MATLAB 开发的应用程序中的程序。但是我在添加动态-link 库时遇到了问题(例如 mclmcrrt.lib
、libmx.lib
、libmex.lib
、libmat.lib
、libfixedpoint.lib
等.) 由 MATLAB 运行时编译器共享到我的项目。当我在Qt Creator环境中构建项目时,出现如下错误:
* LNK1104: cannot open file 'mclmcrrtd.lib'
* U1077: "\VS\Tools\MSVC\{Version}\bin\HostX86\x64\link.EXE": return code '0x450'
* U1077: "\VS\Tools\MSVC\{Version}\bin\HostX86\x64\nmake.exe": return code '0x2'
如何解决这个问题?
1。错误的定义
我通过启动一个类似的项目来测试这个错误。当我在 Qt Creator 中编译项目时,出现以下错误:
LNK1104: cannot open file 'mclmcrrtd.lib'
2。修复错误的步骤
按照以下步骤解决问题:
- 我没有在QT Creator中手动添加依赖项。我通过右键单击项目名称并转到
Add Library > External Library
添加了一个动态库。我在外部库 window QT Creator中使用了以下设置,我使用这些设置添加了文件和目录:
* Linkage: Dynamic
* Mac: Library
* [✔] Library inside "debug" or "release" subfolder
* [ ] Add "d" suffix for debug version
* [ ] Remove "d" suffix for release version
- 我检查了第二步打开的window是如何将动态库的信息传递给*.pro文件的。我选择了
~/lib/win64/
目录下的mclmcrrt.lib
文件,点击了External Library中的Next按钮window 在 Qt Creator 上。我看到 mclmcrrt.lib
库在 Win32、Win64 和 Unix 系统中的命名不同当以这种方式导入到 Qt Creator 时(如 lmclmcrrt
、lmclmcrrtd
、lmclmcrrt
)。
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
else:win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrtd
else:unix: LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
DEPENDPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
- 这就是我学习如何将文件和目录正确导入到我的项目文件中的方式。我自己手动添加了所有要求;为了避免文件和目录混淆,我没有使用接口。
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
else:win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrtd
else:unix: LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include/win64'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
DEPENDPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
- 在Qt Creator中使用
Build > Rebuild All Projects
命令编译工程时,又报错LNK1104: Cannot open file 'mclmcrrtd.lib'
。我发现这是因为旧的MATLAB Compiler Runtime (MCR) is only suitable for x86 architecture. For this reason, I discovered that many sample QT-Matlab Compiler Runtime projects on the internet use the win32
tag in the descriptions in *.pro files. However, I thought it would not be correct to use the win32
tag because of the phrase HostX64\x64
when called from the C:\Program Files(x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC\{Version}\bin\HostX64\x64\cl.exe
directory of the current MSVC。在包含相关代码块的*.pro文件中最终配置如下,成功
LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include/win64'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
DEPENDPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
3。资源
我通过使用 MRC(MATLAB 运行时编译器)编译我在 MATLAB 中开发的应用程序生成了 *.dll
动态-link 库文件。我在Qt Creator 环境中使用MSVC 编译器和qmake 工具集分发and/or 使用我在Windows OS 环境中用MATLAB 开发的应用程序中的程序。但是我在添加动态-link 库时遇到了问题(例如 mclmcrrt.lib
、libmx.lib
、libmex.lib
、libmat.lib
、libfixedpoint.lib
等.) 由 MATLAB 运行时编译器共享到我的项目。当我在Qt Creator环境中构建项目时,出现如下错误:
* LNK1104: cannot open file 'mclmcrrtd.lib'
* U1077: "\VS\Tools\MSVC\{Version}\bin\HostX86\x64\link.EXE": return code '0x450'
* U1077: "\VS\Tools\MSVC\{Version}\bin\HostX86\x64\nmake.exe": return code '0x2'
如何解决这个问题?
1。错误的定义
我通过启动一个类似的项目来测试这个错误。当我在 Qt Creator 中编译项目时,出现以下错误:
LNK1104: cannot open file 'mclmcrrtd.lib'
2。修复错误的步骤
按照以下步骤解决问题:
- 我没有在QT Creator中手动添加依赖项。我通过右键单击项目名称并转到
Add Library > External Library
添加了一个动态库。我在外部库 window QT Creator中使用了以下设置,我使用这些设置添加了文件和目录:
* Linkage: Dynamic
* Mac: Library
* [✔] Library inside "debug" or "release" subfolder
* [ ] Add "d" suffix for debug version
* [ ] Remove "d" suffix for release version
- 我检查了第二步打开的window是如何将动态库的信息传递给*.pro文件的。我选择了
~/lib/win64/
目录下的mclmcrrt.lib
文件,点击了External Library中的Next按钮window 在 Qt Creator 上。我看到mclmcrrt.lib
库在 Win32、Win64 和 Unix 系统中的命名不同当以这种方式导入到 Qt Creator 时(如lmclmcrrt
、lmclmcrrtd
、lmclmcrrt
)。
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
else:win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrtd
else:unix: LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
DEPENDPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
- 这就是我学习如何将文件和目录正确导入到我的项目文件中的方式。我自己手动添加了所有要求;为了避免文件和目录混淆,我没有使用接口。
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
else:win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrtd
else:unix: LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include/win64'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
DEPENDPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
- 在Qt Creator中使用
Build > Rebuild All Projects
命令编译工程时,又报错LNK1104: Cannot open file 'mclmcrrtd.lib'
。我发现这是因为旧的MATLAB Compiler Runtime (MCR) is only suitable for x86 architecture. For this reason, I discovered that many sample QT-Matlab Compiler Runtime projects on the internet use thewin32
tag in the descriptions in *.pro files. However, I thought it would not be correct to use thewin32
tag because of the phraseHostX64\x64
when called from theC:\Program Files(x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC\{Version}\bin\HostX64\x64\cl.exe
directory of the current MSVC。在包含相关代码块的*.pro文件中最终配置如下,成功
LIBS += -L$$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft/' -lmclmcrrt
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/include/win64'
INCLUDEPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'
DEPENDPATH += $$PWD/'../../../../Program Files/MATLAB/R2018B/extern/lib/win64/microsoft'