Creating a QApplication with Matlab Engine

2 views (last 30 days)
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 Comments
Preetham Chalasani
Preetham Chalasani on 17 Apr 2018
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 on 17 Apr 2018
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.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!