2

我在 matlab 中有一个函数,它编写了我在我的 qt 项目中使用的 file.txt。

所以,

当我得到一个使用 unix() 运行的 qt 编译可执行文件时,我有一个 Matlab 文件,但是我收到了一个错误。

编码:

unix('/home/matt/Desktop/PlaneVolumeFinal/PlaneVolumeGui');

错误:

/home/matt/Desktop/PlaneVolumeFinal/PlaneVolumeGui: symbol lookup error: /home/matt/Desktop
/PlaneVolumeFinal/PlaneVolumeGui: undefined symbol: _ZN9QListData7detach3Ev
4

4 回答 4

4

正如@grungetta 所指出的,问题可能与MATLAB 本地库路径没有看到您的Qt 库有关,例如libQtMultimedia.so,它通常应该在任何shell 会话中通过LD_LIBRARY_PATHvar 可见的路径中。

解决此问题的一种方法是LD_LIBRARY_PATH在 MATLAB 运行会话中显式设置 from 的值(如果需要继续,则重新存储它)。您的 MATLAB 脚本的示例命令集可能是:

%*** save local (MATLAB's) LIBRARY PATH
libPathLocal = getenv('LD_LIBRARY_PATH');  

%*** set your global LIBRARY PATH 
PATH_LD_LIBRARY = '/usr/lib/' % or any string containing library files required 
setenv('LD_LIBRARY_PATH', PATH_LD_LIBRARY); 

%*** call binary through 'unix' or 'system'
system('/home/matt/Desktop/PlaneVolumeFinal/PlaneVolumeGui'); 

%*** restore session's MATLAB's library path
setenv('LD_LIBRARY_PATH', libPathLocal); 
于 2012-09-12T17:39:37.410 回答
0

我不完全确定您想以何种方式调用 Qt 项目;但是,MATLAB系统命令可能会有所帮助。该命令用于执行操作系统命令并返回结果。

因此,如果您只是想从 MATLAB 启动一个可执行文件,这可能就是您想要的。

此外,dosunix是两个相关的 MATLAB 命令,根据您的情况可能更合适。

于 2012-09-10T18:28:28.070 回答
0

我没有任何使用 Matlab 的经验,但这是我的 2 美分。

  1. If /home/matt/Desktop/PlaneVolumeFinal/PlaneVolumeGui works OK from command prompt then it seems that MatLab is not able to find the libQtCore.so (I am not exactly sure about how the library is named, but I am referring to QtCore library). In that case copy the Qt's Core library to one of the MatLab's search locations and try. If it gives you same error from the command prompt then it means that Qt's libraries are not in search path. May be you can add PATH_TO_QTLIBS in LD_LIBRARY_PATH.

  2. One other reason could be that you might have more than one versions of Qt on your system and the loader is trying to reference a different version when you try running the application.

Hope this helps.

于 2012-09-13T09:39:34.913 回答
0

It could be a problem with library versions. The binary was compiled with a QT version different from the QT on system? How many library versions are in system? What output gives when executing "ldd /home/matt/Desktop/PlaneVolumeFinal/PlaneVolumeGui"?

于 2012-09-13T13:43:12.250 回答