Error when calling C code and libraries from MATLAB

Hi,
I am trying to call external .c files, which outputs real time data from an INS system, to Matlab and get these real-time values into a simple matlab GUI I have built. I am not an expert in C but I have a good understanding about matlab.
I dont know if this is the right approach for what I want to do, so if there is a simpler way I am open for suggestions.
I am following the steps provided by https://se.mathworks.com/help/matlab/call-c-library-functions.html , but when I am trying to load just the first header file into matlab it does not find the file and I get an error.
This is the first lines of the C code that I want to load
#include <sbgEComLib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Below is the code I use
loadlibrary('sbgECom','sbgEComLib.h')
where sbgECom is refered to my sbgECom.lib file, and the error I get is
Error using loadlibrary
There was an error loading the library "sbgECom"
The specified module could not be found.
Error in ellipsecall (line 11)
loadlibrary('sbgECom','sbgECom.h')
Caused by:
Error using loaddefinedlibrary
The specified module could not be found.
I am in the directory of the files, so the .lib and .h files are in the current directory. What am I doing wrong?

1 个评论

I think the loadlibrary function only works with dynamic libraries (.dll for windows). For static libraries, you would have to either compile the library into a dynamic library and export the functions you would like to use, or use the mexFunction interface to write a mex function to call the function you need.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB Compiler 的更多信息

产品

版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by