MATLAB Answers

Mex compile for Diolan C API

14 views (last 30 days)
Takao Sekiguchi
Takao Sekiguchi on 3 Sep 2020 at 13:15
Commented: Takao Sekiguchi on 9 Sep 2020 at 18:22
Does anybody try to compile mex executable using Diolan C API?
I've tried to include dln_generic.h and dln_gpio.h to wrapper cpp file for mex compile, and every related header files and .lib are stored in the directory which compile command shall be execured, however it complains the linking "undefined reference to function_name". Here is my environemnt. I tried with -R2017b and -R2018a but result were same.
matlab version: R2020a
compiler: MinGW64 Compiler (C++)
command: "mex name_of_the_wrapper.cpp dln.lib user32.lib ws2_32.lib -g -v"
header file declarations:
#pragma once
#pragma comment(lib, "libmx.lib")
#pragma comment(lib, "libmat.lib")
#pragma comment(lib, "libmex.lib")
#pragma comment(lib, "dln.lib")
#include "dln_generic.h"
#include "dln_gpio.h"
#include "mex.h"
struct mxArray_tag {};
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);

  1 Comment

Takao Sekiguchi
Takao Sekiguchi on 9 Sep 2020 at 18:22
I switched to use DLL by LoadLibrary and could solve the linking error but now I got below error to execute mex file...
dynamic link library (DLL) initialization routine failed
Does anyone knows similar experience or solutions?

Sign in to comment.

Answers (0)


Community Treasure Hunt

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

Start Hunting!