Error while using loadlibrary with executable

4 Ansichten (letzte 30 Tage)
GK15
GK15 am 19 Dez. 2017
Bearbeitet: Walter Roberson am 19 Dez. 2017
I am getting following error which running an executable containing 'loadlibrary command'
Error using loadlibrary (line 447)
There was an error loading the library "C:\Software\MATLAB TDMS Executable\MATLAB TDM Example\samples\64-bit\ReadFileNI\for_testing\nilibddc.dll"
The specified module could not be found.
Error in ReadFile (line 31)
Caused by:
Error using loaddefinedlibrary
The specified module could not be found.
MATLAB:loadlibrary:LoadFailed
Error writing to output stream.
I created a prototype file for the .dll using the instructions given out on MATLAB community forums , but I still get the error. What am I doing wrong? Below is the code for which I am developing an executable:
clc;
%Recreate needed property constants defined in nilibddc_m.h
DDC_FILE_NAME = 'name';
DDC_FILE_DESCRIPTION = 'description';
DDC_FILE_TITLE = 'title';
DDC_FILE_AUTHOR = 'author';
DDC_FILE_DATETIME = 'datetime';
DDC_CHANNELGROUP_NAME = 'name';
DDC_CHANNELGROUP_DESCRIPTION = 'description';
DDC_CHANNEL_NAME = 'name';
%Check if the paths to 'nilibddc.dll' and 'nilibddc_m.h' have been
%selected. If not, prompt the user to browse to each of the files.
if exist('NI_TDM_DLL_Path','var')==0
[dllfile,dllfolder]=uigetfile('*dll','Select nilibddc.dll');
libname=strtok(dllfile,'.');
NI_TDM_DLL_Path=fullfile(dllfolder,dllfile);
end
if exist('NI_TDM_H_Path','var')==0
[hfile,hfolder]=uigetfile('*h','Select nilibddc_m.h');
NI_TDM_H_Path=fullfile(hfolder,hfile);
end
%Prompt the user to browse to the path of the TDM or TDMS file to read
[filepath,filefolder]=uigetfile({'*.tdm';'*.tdms'},'Select a TDM or TDMS file');
Data_Path=fullfile(filefolder,filepath);
%Load nilibddc.dll (Always call 'unloadlibrary(libname)' after finished using the library)
%loadlibrary(NI_TDM_DLL_Path,NI_TDM_H_Path);
loadlibrary(NI_TDM_DLL_Path,@PrototypeName);
%Open the file (Always call 'DDC_CloseFile' when you are finished using a file)
fileIn = 0;
[err,dummyVar,dummyVar,file]=calllib(libname,'DDC_OpenFileEx',Data_Path,'',1,fileIn);
%Read and display file name property
filenamelenIn = 0;
%Get the length of the 'DDC_FILE_NAME' string property
[err,dummyVar,filenamelen]=calllib(libname,'DDC_GetFileStringPropertyLength',file,DDC_FILE_NAME,filenamelenIn);
if err==0 %Only proceed if the property is found
%Initialize a string to the length of the property value
pfilename=libpointer('stringPtr',blanks(filenamelen));
[err,dummyVar,filename]=calllib(libname,'DDC_GetFileProperty',file,DDC_FILE_NAME,pfilename,filenamelen+1);
setdatatype(filename,'int8Ptr',1,filenamelen);
disp(['File Name: ' char(filename.Value)]);
end
%Unload nilibddc.dll
unloadlibrary(libname);

Antworten (0)

Kategorien

Mehr zu C Shared Library Integration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by