Why do I get Library was not found Error while using external library in parpool?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 23 Apr 2018
Modificato: Edric Ellis
il 24 Apr 2018
Hi,
I would like to call external library functions in parallel.
I am using the code below.
clear all
if ~libisloaded('shrlibsample')
addpath(fullfile(matlabroot,'extern','examples','shrlib'))
loadlibrary('shrlibsample')
end
struct.p1 = 4; struct.p2 = 7.3; struct.p3 = -290;
parpool('AttachedFiles',{'shrlibsample.mexw64','shrlibsample.h','shrlibsample.c', 'shrhelp.h'});
parfor i=1:4
[res,st] = calllib('shrlibsample','addStructByRef',struct);
end
unloadlibrary shrlibsample
But, when running this code, I am getting error- ERROR: Library was not found
How to fix this?
Risposta accettata
MathWorks Support Team
il 23 Apr 2018
Modificato: Edric Ellis
il 24 Apr 2018
This error means that the library you are trying to call is not available in parallel workers.
Although, you have added required files to the parallel pool using 'AttachedFiles', the reason why this error is thrown is that those libraries are not loaded in parallel workers.
In order to have libraries available in those workers, please load libraries in each worker.
clear all;
addpath(fullfile(matlabroot,'extern','examples','shrlib'))
struct.p1 = 4; struct.p2 = 7.3; struct.p3 = -290;
parpool('AttachedFiles',{'shrlibsample.mexw64','shrlibsample.h','shrlibsample.c', 'shrhelp.h'});
parfor i=1:4
if ~libisloaded('shrlibsample')
loadlibrary('shrlibsample')
end
[res,st] = calllib('shrlibsample','addStructByRef',struct);
end
unloadlibrary shrlibsample
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Call C from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!