Using clibgen.ge​nerateLibr​aryDefinit​ion on QT inclusive libaries

6 views (last 30 days)
The error is similar to the one recieved in VS2022 when the project type is set incorrectly. I have the additional compiler flags added into additionalCompilerFlags, but they seem to do nothing.
Code:
headerFile = "C:\MYAPP\my_driver.h";
libFile = "C:\MyAPP\my_driver.dll";
includePath = ["C:\Qt\Qt6.7.0\6.7.0\msvc2019_64\include",...
"C:\Qt\Qt6.7.0\6.7.0\msvc2019_64\include\QtCore",...
"C:\Qt\Qt6.7.0\6.7.0\msvc2019_64\include\QtSerialPort",...
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"];
additionalCompilerFlags = "/std:c++17 /Zc:rvalueCast /Zc:inline /Zc:strictStrings /Zc:throwingNew /permissive- /Zc:__cplusplus /Zc:externConstexpr /utf-8 /w34100 /w34189 /w44996 /w44456 /w44457 /w44458";
libName = "MYLIB";
clibgen.generateLibraryDefinition(headerFile, "Libraries", libFile, "PackageName", libName, "IncludePath", includePath, 'AdditionalCompilerFlags', additionalCompilerFlags)
Error:
Errors parsing interface generation files.
C:\Qt\Qt6.7.0\6.7.0\msvc2019_64\include\QtCore\qcompilerdetection.h(460):
warning: this feature-test macro is ignored (and returns 0) in the current compilation mode
C:\Qt\Qt6.7.0\6.7.0\msvc2019_64\include\QtCore\qcompilerdetection.h(1257):
error: #error directive: "Qt requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus
option to the compiler."

Answers (1)

Kautuk Raj
Kautuk Raj on 22 May 2024
I can observe that you are facing compilation errors due to Qt's C++17 requirements and potentially incorrect compiler flag settings in MATLAB.
From the information provided, I can see that the IncludePath refers to this path:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include". Here, Visual Studio 14.0 refers to Visual Studio 2015, which is not supported by MATLAB R2023b.
Reproducing from the above document: Visual Studio Community, Professional, and Enterprise editions are supported. The “Desktop development with C++” workload is required for MEX and associated functionality.
I trust this response will guide you towards resolving your problem.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!