Matlab Compiler App - compile GUI that calls shared libraries: dll has to be in the final .exe folder?

12 次查看(过去 30 天)
Hey experts,
as the long title stated, I need help with a compiled standalone application. First of all a little introduction:
I wrote a gui-based tool in GUIDE.
This tool invokes shared libraries. I did everything according to the documentations
everything works, when I run it under MATLAB.
It also works smoothly if i compile it in a standalone .exe (using the MATLAB Compiler app) - but only when the dll-files are in the same directory as the .exe file.
even the documentation says (i don't know how to quote in this editor):
3. Compile and deploy the application.
  1. If you are integrating the library into a deployed application, specify the library’s .dll along with library_thunk_pcwin64.dll, if created, using the -a option of mcc command. If you are using Application Compiler or Library Compiler apps, add the .dll files to the Files required for your application to run section of the app.
  2. If you are providing the library as an external file that is not integrated with the deployed application, place the library .dll file in the same folder as the compiled application. If you are on Windows, you must integrate library_thunk_pcwin64.dll into your compiled application.
  • I am doing exactly as stated in 3.1. I add the dll's to the "Files required for your application to run" section:
  • I show this for a demo-gui. and the size of the resulting .exe file is 14MB (if i don't add the dll's it is about 2mb).
  • the packaging log is given as:
mcc -o demo_ziqi -W 'main:demo_ziqi,version=1.0' -T link:exe -d C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\demo_ziqi\for_testing -v C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\demo_ziqi.m -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\boost_chrono-vc140-mt-1_65_1.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\boost_date_time-vc140-mt-1_65_1.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\boost_system-vc140-mt-1_65_1.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\boost_thread-vc140-mt-1_65_1.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\ibeo-common-logging.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\ibeo-common-sdk-core.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\ibeo-common-sdk-data.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\ibeo-common-sdk-devices.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\idc2caligraph.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\idc2caligraph_thunk_pcwin64.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\jpeg8.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\next-interpreter-plugin.dll -a C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\tinyxml2.dll -r 'C:\Program Files\MATLAB\R2019b\toolbox\compiler\Resources\default_icon.ico'
Compiler version: 7.1 (R2019b)
Dependency analysis by REQUIREMENTS.
Parsing file "C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\demo_ziqi.m"
(referenced from command line).
Generating file "C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\demo_ziqi\for_testing\readme.txt".
Packaging...
Creating the bundle...
Creating the install agent URL file...
Web based installer created at C:\Users\MAJ\Desktop\Temp_Analysis\idc2csv_demi_qiao\demo_ziqi\for_redistribution\MyAppInstaller_web.exe.
Packaging complete.
Elapsed packaging time was: 8 seconds.
  • if I run it, I got this error in windows command window:
Error using loadlibrary There was an error loading the library "idc2caligraph" Das angegebene Modul wurde nicht gefunden. Error in demo_ziqi>pushbutton1_Callback (line 87) Error in gui_mainfcn (line 95) Error in demo_ziqi (line 42) Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)demo_ziqi('pushbutton1_Callback',hObject,eventdata,guidata(hObject)) Caused by: Error using loaddefinedlibrary Das angegebene Modul wurde nicht gefunden. Error using waitforallfiguresclosed (line 14) Error while evaluating UIControl Callback.
  • here is an example code on how I invoke the shared libraries
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% demo parameters
[filename, pathname] = uigetfile('*.idc','Please choose an IDC file to load:');
idc_file_fullpath = [pathname, filesep, filename];
%% demo call
if not(libisloaded('idc2caligraph')), loadlibrary('idc2caligraph', @idc2caligraph); end
queried_scan_indices = 100:110;
disp('************************************')
CLIB_INIT_STATUS = initializeIDC(idc_file_fullpath, 0.9999, '4p1', true);
disp(['function ''initializeIDC'' 1st invoke status: ', CLIB_INIT_STATUS]);
assert(strcmp(CLIB_INIT_STATUS, 'IDC2CALIGRAPH_OK'))
tic
[scans, points, CLIB_GETSCAN_STATUS] = getScan(42, queried_scan_indices, 'serial');
disp(['function ''getScan'' serial invoke status: ', CLIB_GETSCAN_STATUS]);
assert(strcmp(CLIB_GETSCAN_STATUS, 'IDC2CALIGRAPH_OK'))
toc
disp('***')
CLIB_INIT_STATUS = initializeIDC(idc_file_fullpath, 0.9999, '4p1', true);
disp(['function ''initializeIDC'' 2nd invoke status: ', CLIB_INIT_STATUS]);
assert(strcmp(CLIB_INIT_STATUS, 'IDC2CALIGRAPH_OK'))
tic
[scans, points, CLIB_GETSCAN_STATUS] = getScan(42, queried_scan_indices);
disp(['function ''getScan'' query invoke status: ', CLIB_GETSCAN_STATUS]);
assert(strcmp(CLIB_GETSCAN_STATUS, 'IDC2CALIGRAPH_OK'))
toc
axes(handles.axes1)
scatter3(points{1}(:,1),points{1}(:,2),points{1}(:,3),'.')
axis equal
grid on
box on
disp('***')
[meta_data, CLIB_GETIDCINFO_STATUS] = getIdcInfo();
disp(['function ''getIdcInfo'' invoke status: ', CLIB_GETIDCINFO_STATUS]);
assert(strcmp(CLIB_GETIDCINFO_STATUS, 'IDC2CALIGRAPH_OK'))
disp('************************************')
save('demo_ziqi.mat', 'scans', 'points', 'meta_data')
unloadlibrary idc2caligraph
  • now my question: Why does it work if the dll's are in the same directory. But not if the dll's are not there? I don't want to handover the dll's. Did I do something wrong during compilation?
here is some information about my system, let me know if you need other information.
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.7.0.1190202 (R2019b)
MATLAB License Number: 40774147
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19042)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.7 (R2019b)
GUI Layout Toolbox Version 2.3.4 (R2018b)
MATLAB Compiler Version 7.1 (R2019b)
>>

采纳的回答

Marten Amschler
Marten Amschler 2021-7-16
we found the Bug. If you want to call the shared libraried from a compiled version, you have to build the prototype file. And we left it with the same name as the library.
With a different name, everything works. The functions work in the compiled version, without the dll's in it's directory.

更多回答(0 个)

类别

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

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by