I generated *.dll
dynamic-link library file by compiling the application I developed in MATLAB using MRC (MATLAB Runtime Compiler). I'm using the MSVC compiler and qmake toolset in the Qt Creator environment to distribute and/or use the procedures in the application I developed in MATLAB in the Windows OS environment. But I'm having trouble adding the dynamic-link libraries (for example mclmcrrt.lib
, libmx.lib
, libmex.lib
, libmat.lib
, libfixedpoint.lib
, etc.) shared by the MATLAB Runtime Compiler to my project. When I build the project in the Qt Creator environment, I get the following error:
* 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'
How do I solve this problem?
I tested this bug by starting a similar project. When I compile the project in Qt Creator I got the following error:
LNK1104: cannot open file 'mclmcrrtd.lib'
Follow the steps below to fix the problem:
Add Library > External Library
. I used the following settings in the External Library window in QT Creator, I added files and directories using these settings: * Linkage: Dynamic
* Mac: Library
* [✔] Library inside "debug" or "release" subfolder
* [ ] Add "d" suffix for debug version
* [ ] Remove "d" suffix for release version
mclmcrrt.lib
file in the ~/lib/win64/
directory and clicked the Next button in the External Library window on Qt Creator. I saw that the mclmcrrt.lib
library was named differently in Win32, Win64 and Unix systems when imported to Qt Creator in this way (like 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'
Build > Rebuild All Projects
command in Qt Creator to compile the project, I got the error LNK1104: Cannot open file 'mclmcrrtd.lib'
again. I found out that this is because the old 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 Studio\2019\Community\VC\Tools\MSVC\{Version}\bin\HostX64\x64\cl.exe
directory of the current MSVC. The final configuration in the *.pro file containing the relevant code block is as follows and successfullyLIBS += -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'