필터 지우기
필터 지우기

Compiling functions that loads an external dll library in 64bits (thunk file problems)

조회 수: 16 (최근 30일)
Hi, The application that I'm trying to compile is calling the loadlibrary function. I had a series of errors and found in the documentation that I should use a prototype function, then a thunk file. I saw some generated , *thunk_pcwin64.dll exp, lib and obj files and tried to load the dll, but it is still not working ()
I did not find any documentation on how to proceed : should I only call the generated dll ? (this does not work with the uncompiled version).
Thanks

답변 (3개)

Tejas M U
Tejas M U 2014년 7월 3일
What is the error message? Which language is your application written in? C++ libraries need thunk files. Are you creating a library from MATLAB? If so, have you added the prototype file in the ‘additional files’ section while creating the load library? When you are using the load library in your application program, are you linking the DLL to the application?
Also, here are some limitations of loadlibrary:
1. You must have a supported C compiler and Perl must be available.
2. Do not call loadlibrary if the library is already in memory. To test this condition, call libisloaded.
3. loadlibrary does not support libraries generated by the MATLAB Compiler™ product.
4. The MATLAB Shared Library interface does not support library functions with function pointer inputs.
  댓글 수: 1
Mathieu
Mathieu 2014년 7월 4일
편집: Mathieu 2014년 7월 4일
Hi, my application is running when compiled in 32bits and also running when not compiled.
In 64 bits the error which I can't solve is a call to thunkoadfile.
how do I get a thunk file ? As mentioned above, matlab generates a thunk*.dll at the same time as the prototype function but I don't know what I am supposed to do with it.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2014년 7월 3일
Do you have a prototype file? And are you adding the file as an mcc argument:
mcc -m yourApp.m -d 'D:\MATLAB\OutputFolder' -a cbw_prototype_file.m -a cbw64_thunk_pcwin64.dll -a 'C:\Program Files (x86)\Measurement Computing\DAQ\cbw64.dll'
It's been a while since I've figured it out so I don't remember all the details about why things are done, but you can look over my file. I had to create this and run it to make some files in order to run a DLL from Measurement Computing Corporation that talks to one of their digital I/O devices.
  댓글 수: 1
Mathieu
Mathieu 2014년 7월 4일
Thanks.
I have a prototype file (.m) as well as a dll both generated by the loadlibrary function of matlab.
I'm not putting the file as an mcc argument: I'll try that. I was trying to deploy with the deploy tool. I also did mcc calls but without passing the dll as an argument.
Oddly enough there is no documentation on that on the mcc page.

댓글을 달려면 로그인하십시오.


Ofek
Ofek 2016년 7월 15일
I know this question is old - but in hope of helping others googling their way here, let me try to fill in some details.
The question is a bit vague and if it had the exact error messages we might have been able to help more - but it does closely resemble some issues we had trying to deploy components calling loadlibrary.
The loadlibrary documentation does leave much to be desired, and some hacking had to be used to understand this apparatus better. The full (-ish) details are laid out here, but the bottom lines are:
1) The proto file contains info about calling the thunk DLL.
2) The thunk DLL is about adjusting calling conventions.
3) When the Matlab component consuming the native DLL is deployed (using matlab compiler), the loadlibrary call is made from wherever the CTF archive was extracted to – and it occasionally fails to find the thunk dll. Our solution was to intervene in the proto.m file, and have it take the thunk path from the registry.
  댓글 수: 1
David Ahrens
David Ahrens 2021년 2월 26일
I know this is old.
How do you get the thunk path from the registry?
using matlab 2017a,
I get the loadlibrary call responding with a warning 'Warning: The function '<funcName>' was not found in the library' for every method and in the order of the proto file.
All works fine on the machine with matlab installed. When trying to execute on the machine with MCR installed I get the problems.
Redistributing using the ctf file bundled in my installer.
Have tried to hard code the directory that the MCR runs from directly into the proto file

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Package MATLAB Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by