Compiling functions that loads an external dll library in 64bits (thunk file problems)
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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).
Are there some example or documentation on this ? I only found http://www.mathworks.nl/help/matlab/ref/loadlibrary.html#btjpunx-1 http://www.mathworks.nl/help/matlab/matlab_external/prototype-files.html
Thanks
0 comentarios
Respuestas (3)
Tejas M U
el 3 de Jul. de 2014
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 comentario
Image Analyst
el 3 de Jul. de 2014
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.
Ofek
el 15 de Jul. de 2016
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 comentario
David Ahrens
el 26 de Feb. de 2021
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
Ver también
Categorías
Más información sobre MATLAB Compiler en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!