Results 1 to 3 of 3

Thread: QT 5 Matlab Compiler Runtime Static Library Linking Problem

  1. #1
    Join Date
    Jul 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QT 5 Matlab Compiler Runtime Static Library Linking Problem

    Hi All,

    I have migrated from QT 4.7 to QT 5.1. I have a code for compiling a .dll file for a plugin in my software. The .pro file is here.

    Qt Code:
    1. DccSrc = ../../
    2. include($$DccSrc"DccGlobals.pri")
    3.  
    4. TEMPLATE = lib
    5. CommonPath = $$DccSrc"Common"
    6. DEPENDPATH += . Interface $$CommonPath
    7. DLLDESTDIR = $$DCC_BIN/plugins
    8.  
    9. DEFINES += MTF_LIBRARY
    10. DEFINES += QT __LCC__
    11.  
    12. SOURCES += MTF.cpp \
    13. LibTI_MTF.c \
    14. LibTI_MTF_mcc_component_data.c
    15.  
    16. HEADERS += MTF.h \
    17. LibTI_MTF.h \
    18. ../../../Common/ctypes.h
    19.  
    20. INCLUDEPATH += . $$CommonPath ../../MatLabHFilesForQT "C:\Program Files\MATLAB\MATLAB Compiler Runtime\v713\extern\include"
    21.  
    22.  
    23. LIBS += -L"C:/Program Files/MATLAB/MATLAB Compiler Runtime/v713/extern/lib/win32/microsoft" -lmclmcrrt
    To copy to clipboard, switch view to plain text mode 

    It gets compiled in QT 4.7.3. But in QT 5 it is not able to find the symbols for MCR library functions.
    D:\QT\DCC_TuningTool\plugins\MTF\MTF.cpp:50: error: undefined reference to `mxCreateDoubleScalar_proxy(double)'
    D:\QT\DCC_TuningTool\plugins\MTF\MTF.cpp:51: error: undefined reference to `mxCreateDoubleScalar_proxy(double)'
    D:\QT\DCC_TuningTool\plugins\MTF\MTF.cpp:52: error: undefined reference to `mxCreateDoubleScalar_proxy(double)'
    D:\QT\DCC_TuningTool\plugins\MTF\MTF.cpp:55: error: undefined reference to `mxCreateString_proxy(char const*)'

    and so on..

    all these symbols exist on mclmcrrt.lib

    If I do a static linking
    Qt Code:
    1. DEFINE += static
    To copy to clipboard, switch view to plain text mode 
    it gets compiled. But I need dynamic linking for this plug in.

    I have other plug-ins, where I don't have the any CPP source file, there static/dynamic both linking works.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,552
    Thanks
    13
    Thanked 1,579 Times in 1,508 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QT 5 Matlab Compiler Runtime Static Library Linking Problem

    Line 23 is missing a hyphen.

  3. #3
    Join Date
    Jul 2013
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QT 5 Matlab Compiler Runtime Static Library Linking Problem

    Hi Chris,

    Thanks for your answer, but I am sorry, I can't find any missing hyphen on line 23.
    Qt Code:
    1. LIBS += -L"C:/Program Files/MATLAB/MATLAB Compiler Runtime/v713/extern/lib/win32/microsoft" -lmclmcrrt
    To copy to clipboard, switch view to plain text mode 

    My MTF.cpp file is

    Qt Code:
    1. #include "MTF.h"
    2.  
    3. int MaxX = 255;
    4.  
    5.  
    6. Chart * chart;
    7. Chart::Chart(PluginAnalysisIO * IO): QObject(IO)
    8. {
    9. pluginIO = IO;
    10. // return;
    11. //QWidget * parentWidget = pluginIO->outputWidgets[0];
    12.  
    13. // QVBoxLayout *layout1 = new QVBoxLayout(parentWidget);
    14. // layout1->addWidget(plot);
    15. // QGridLayout * grid = new QGridLayout(parentWidget);
    16. // layout1->addLayout(grid);
    17. // if(!LibTI_MTFInitializeWithHandlers(DefaultErrorHandler, DefaultPrintHandler)) {
    18. if(!LibTI_MTFInitialize()){
    19. //mclTerminateApplication();
    20. QMessageBox::critical(0,"Error", "Error initializing Matlab engine!\nPlease try to restart application.");
    21. //return 2;
    22. } else{
    23. //return 0;
    24. }
    25. }
    26.  
    27. int main(int a,char** ){ return 0;}
    28.  
    29. Chart::~Chart(){
    30. LibTI_MTFTerminate();
    31. }
    32.  
    33.  
    34.  
    35. void Chart::showChart(){
    36.  
    37. QString imageFileName = pluginIO->imageFileName.toLower();
    38. QDir tempDir(QDir::tempPath());
    39. // QString tempPath = tempDir.canonicalPath();
    40. QString tempPath = tempDir.absolutePath();
    41.  
    42. QString outPrefix = tempPath+"/MTF_Images_";
    43. QString CoordinatesFile = outPrefix + "coordinates.txt";
    44. #if defined(Q_OS_WIN)
    45. outPrefix.replace("/","\\");
    46. imageFileName.replace("/","\\");
    47. CoordinatesFile.replace("/","\\");
    48. #endif
    49.  
    50. mxArray * cols = mxCreateDoubleScalar(pluginIO->rawWidth);
    51. mxArray * rows = mxCreateDoubleScalar(pluginIO->rawHeight);
    52. mxArray * phase = mxCreateDoubleScalar(pluginIO->rawColorPattern);
    53. mxArray * dcsub = mxCreateDoubleScalar(0);
    54. mxArray * R = NULL;
    55. mxArray * infilename = mxCreateString(imageFileName.toStdString().c_str());
    56. mxArray * rotate = mxCreateDoubleScalar(0);
    57. mxArray * figurePref = mxCreateString(outPrefix.toStdString().c_str());
    58. mxArray * filename_coords = mxCreateString(CoordinatesFile.toStdString().c_str());
    59. QFile::remove(pluginIO->fileNames[0]);
    60. QFile::remove(pluginIO->fileNames[1]);
    61. pluginIO->fileNames[0] = "";
    62. pluginIO->fileNames[1] = "";
    63.  
    64. FILE* coordinates = fopen(CoordinatesFile.toStdString().c_str(),"w");
    65. if (coordinates != NULL){
    66. fprintf(coordinates,"%d, %d, %d, %d\r\n",pluginIO->selectedRect.topLeft().x(), pluginIO->selectedRect.bottomRight().x(),pluginIO->selectedRect.topLeft().y(), pluginIO->selectedRect.bottomRight().y());
    67. fclose(coordinates);
    68. if (imageFileName.endsWith(".raw",Qt::CaseInsensitive)|| imageFileName.endsWith(".rawle",Qt::CaseInsensitive)){
    69. mlfRawmtfse(1, &R, infilename, cols, rows, phase, dcsub, figurePref, filename_coords);
    70. } else
    71. if (imageFileName.endsWith(".jpg",Qt::CaseInsensitive)|| imageFileName.endsWith(".bmp",Qt::CaseInsensitive)||imageFileName.endsWith(".jpeg",Qt::CaseInsensitive)){
    72. mlfImgmtfse(1, &R, infilename, rotate, figurePref, filename_coords);
    73.  
    74. } else {
    75. QMessageBox::critical(0,"Error", tr("Improper image type selected! \nAcceptable file extensions are: \n *.jpg, *.bmp, *.raw, *.rawLE") );
    76. goto end;//-->
    77. }
    78.  
    79. if (R == NULL){
    80. QString parameters = "\nFile = " + QString(mxArrayToString(infilename));
    81. parameters += " \nfigurePref = " + QString(mxArrayToString(figurePref));
    82. parameters += " \nfilename_coords = " + QString(mxArrayToString(filename_coords));
    83. parameters += " \ncols = " + QString::number(* mxGetPr(cols));
    84. parameters += " \nrows = " + QString::number(* mxGetPr(rows));
    85. parameters += " \nphase = " + QString::number(* mxGetPr(phase));
    86. parameters += " \ndcsub = " + QString::number(* mxGetPr(dcsub));
    87. QFile coordinates_txt(CoordinatesFile);
    88. coordinates_txt.open(QIODevice::ReadOnly);
    89. QString coords(coordinates_txt.readAll());
    90. coordinates_txt.close();
    91. parameters += "\nRect: "+ coords;
    92. QMessageBox::critical(0,"Error", tr("MatLab returned error!") + parameters);
    93. }else
    94. if (* mxGetPr(R) != -1){
    95. pluginIO->fileNames[0] = outPrefix+"figure_1.jpeg";
    96. pluginIO->fileNames[1] = outPrefix+"figure_2.jpeg";
    97. mxDestroyArray(R);
    98. }
    99. else if (* mxGetPr(R) == -1){
    100. QMessageBox::critical(0,"Error", tr("Cannot evaluate function! \nPlease try selecting another area!"));
    101. }
    102. else QMessageBox::critical(0,"Error", tr("Unrecognized error!"));
    103. } else {
    104. QMessageBox::critical(0,"Error",tr("Error creating coordinates file: ") + CoordinatesFile);
    105. }
    106. end:
    107. mxDestroyArray(infilename);
    108. mxDestroyArray(rotate);
    109. mxDestroyArray(figurePref);
    110. mxDestroyArray(filename_coords);
    111.  
    112. }
    113.  
    114. extern "C"
    115. {
    116. MTFSHARED_EXPORT int init(PluginAnalysisIO * IO){
    117. chart = new Chart(IO);
    118. return 0;
    119. }
    120.  
    121. MTFSHARED_EXPORT void show(){
    122. chart->showChart();
    123. }
    124. }
    125.  
    126. int DefaultPrintHandler(const char *s)
    127. {
    128. return strlen(s);//->
    129. return mclWrite(1 /* stdout */, s, sizeof(char)*strlen(s));
    130. }
    131.  
    132. int DefaultErrorHandler(const char *s)
    133. {
    134. int written = 0;
    135. size_t len = 0;
    136. len = strlen(s);
    137.  
    138. return len;//->
    139. written = mclWrite(2 /* stderr */, s, sizeof(char)*len);
    140. if (len > 0 && s[ len-1 ] != '\n')
    141. written += mclWrite(2 /* stderr */, "\n", sizeof(char));
    142. return written;
    143. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 11th August 2012, 17:37
  2. Replies: 4
    Last Post: 14th January 2011, 23:44
  3. Linking a foreign static library using QtCreator
    By gib in forum Qt Programming
    Replies: 0
    Last Post: 22nd September 2010, 02:52
  4. Linking to a static library on Windows
    By rexi in forum Qt Programming
    Replies: 9
    Last Post: 27th July 2009, 19:54
  5. Trouble linking static library
    By russdot in forum Qt Programming
    Replies: 3
    Last Post: 17th May 2009, 10:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.