load mex library error on Linux

6 次查看(过去 30 天)
Jose Gutierrez de la Concha
回答: Nihal 2024-8-16,10:09
Hi,
I getting this error while trying to load a mex library on Ubuntu 20.04
>> loadlibrary('ice', @iceproto)
Error using message/getString
In 'MATLAB:loadlibrary:ErrorRunningFromCommandLine', parameter {0} must be a real scalar.
Error in loadlibrary
I have build a mex, proto and thunk files
ice.mexa64 iceproto.m icethunk.so
Cheers,
Jose

回答(1 个)

Nihal
Nihal 2024-8-16,10:09
Hi Jose,
The error you're encountering suggests that there might be an issue with how the loadlibrary function is being called or with the files involved. Here are some steps to help troubleshoot and resolve the issue:
  1. Check File Paths: Ensure that the files ice.mexa64, iceproto.m, and icethunk.so are in the current working directory or provide the full path to these files when calling loadlibrary.
  2. Verify Function Signatures: Make sure that the iceproto.m file correctly defines the function signatures expected by the ice library. This file should contain the necessary prototype information for MATLAB to interface with the library.
  3. Correct Usage of loadlibrary: The loadlibrary function typically requires the name of the shared library and the prototype file. Ensure your command is structured correctly
  4. Check MATLAB Version Compatibility: Ensure that the MATLAB version you are using is compatible with the compiled MEX file. Sometimes, MEX files need to be compiled with specific MATLAB versions to ensure compatibility.
  5. Library Dependencies: Check if the ice library has any dependencies that are not met. You can use tools like ldd on the ice.mexa64 file to check for missing dependencies
  6. Recompile the MEX File: If the above steps don't resolve the issue, consider recompiling the MEX file. Make sure to use the correct compiler settings and MATLAB's mex function
  7. Check for Errors in Prototype File: Double-check the iceproto.m file for any syntax errors or incorrect function declarations that might prevent loadlibrary from executing properly.

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by