Creating a QApplication with Matlab Engine

2 次查看(过去 30 天)
I'm trying to create a qt application with matlab engine. The program is throwing Segmentation fault when it tires to create a QApplication object. Following is the sample code that seg faults.
#include <QApplication>
int main(int argc, char **argv)
{
QApplication application(argc, argv);
return 0;
}
Following is the CMakeLists.txt that goes along with this.
cmake_minimum_required(VERSION 3.4)
find_package(Qt5Widgets)
find_package(Matlab REQUIRED COMPONENTS ENG_LIBRARY MX_LIBRARY)
include_directories(${Matlab_INCLUDE_DIRS})
add_executable( example main.cpp)
target_link_libraries(example ${Matlab_LIBRARIES} Qt5::Widgets )
I tried compiling against 2017a and 2018a, but no luck.
Any help would be much appreciated.
  2 个评论
Preetham Chalasani
Preetham Chalasani 2018-4-17
I managed to find the problem. It was linking against different libraries from different matlab versions. After cleaning that up and making sure all the libraries are from 2018a, now the program seg faults at application.exec
#include <QApplication>
int main(int argc, char **argv)
{
QApplication application(argc, argv);
return application.exec();
}
Preetham Chalasani
Preetham Chalasani 2018-4-17
It seems that libQt5XcbQpa.so.5 was creating a problem. It was being dynamically loaded from the $matlabroot/bin/glnxa64 instead from /usr/lib/x86_64-linux-gnu/ and creating a compatibility issue. Renaming $matlabroot/bin/glnxa64/libQt5XcbQpa.so.5 was my temporary fix.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by