Help with reading the functions inside a library

Is there a reason why the code below cannot find the dll that IS in the directory as shown (there is also the h file with the same name)
[file,path] = uigetfile('C:\Users\Public\PI\PI_Programming_Files_PI_GCS2_DLL\*.dll');
libname=fullfile(path,file)
%Remove the extension
[path,name,ext] = fileparts(libname)
%Rebuild without Ext
libname=fullfile(path,name)
hname=fullfile(path,name) %Dont need this if same name
loadlibrary('libname')
libfunctionsview libname
Error using loadlibrary
Could not find file libname.h.
Error in loadlibrary
(here are the library and header files)

 採用された回答

Rik
Rik 2021 年 1 月 16 日

0 投票

You first store a filename in a variable, but then you use the Name of the variable to call loadlibrary.
loadlibrary(libname);%this should work better

6 件のコメント

Jason
Jason 2021 年 1 月 16 日
Now Im gettng
libname =
'C:\Users\Public\PI\PI_Programming_Files_PI_GCS2_DLL\PI_GCS2_DLL'
Error using loadlibrary
Could not find file PI_GCS2_DLL.h.
Error in loadlibrary
Rik
Rik 2021 年 1 月 17 日
The function requires a header file as well. I am not familiar enough with this to know what it should contain, but at least you are now passing the actual file name to the loadlibrary function.
Jason
Jason 2021 年 1 月 17 日
thanks Rik, the header file is the same name so according to the documentation its not needed.
Strangely, it only seems to works when I do use the hfile name as well as use an alias
hname=libname;
loadlibrary(libname,hname,'alias','lib')
Rik
Rik 2021 年 1 月 17 日
From your screenshot it looks like your header file doesn't actually have an extension, while the error indicates Matlab expects a .h file. But glad you solved it.
Jason
Jason 2021 年 1 月 17 日
Forgive me, but what does 'thunk it' mean

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFloating-Point to Fixed-Point Conversion についてさらに検索

質問済み:

2021 年 1 月 16 日

コメント済み:

2021 年 1 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by