Shortcut for addition of DYLIB_API before functions and variables #11
-
Hi there, I came across dylib a couple of days ago and I thought it could be great tool. The way I am currently creating a DLL/.so files is through compiling .m (matlab) files through MATLAB Coder which converts Matlab to MEX(Matlab Executable) or C++ files. There can potentially be lots of varaibles/ functions genereated by Coder during compilation and it would be really hard to put a DYLIB_API infront of them manually since they are intially in MATLAB. Is there any alterantive to this? Perhaps something of inheritence nature? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 26 replies
-
Hello, https://www.mathworks.com/help/compiler_sdk/gs/create-a-c-application-with-matlab-code.html In Matlab, if you build your code as a C dynamic library, the usage of With that, you should no longer need to add manually |
Beta Was this translation helpful? Give feedback.
Hello,
The goal of
DYLIB_API
is to mark a function or a variable asextern "C"
and putdllexport
on windows.https://www.mathworks.com/help/compiler_sdk/gs/create-a-c-application-with-matlab-code.html
In Matlab, if you build your code as a C dynamic library, the usage of
extern "C"
is now uselessOn the link above, I saw that you have the option "exported function", this option will add
dllexport
before your exported functionWith that, you should no longer need to add manually
DYLIB_API
.After building into a C dynamic library, you can check if your symbols are here and correctly named using
nm
:https://en.wikipedia.org/wiki/Nm_(Unix)