Recompile Arduino Target for Simulink for Windows 64 bit - matlab

I want to use Arduino Target for Simulink. It is made only for 32bit versions of Windows, but I read that you can recompile it and use it in 64-bit Windows.
I have tried, but I have not succeeded. I think that the files you need to create are the ones ending on .mexw32. What do you use to recompile these?

From http://www.mathworks.com/matlabcentral/fileexchange/24675-arduino-target:
To compile the C files for win64 (or
another platform), first make sure you
have a supported compiler:
http://www.mathworks.com/support/compilers/R2010b/win64.html
Once you have a compiler installed,
you can run "mex -setup" to point to
the appropriate compiler.
Finally, you can run "mex filename.c"
to compile all the functions in the
blocks directory.

Related

Linking with pe-i386 object file and a pe-x86-64 object file

Because my understanding of this problem is limited, please excuse me if I provide irrelevant details.
Question
I have two versions of MingGW on my computer, and both are 32-bit. The first one is what I call "basic MinGW", and it's the one I installed using mingw-get several years ago. The other one came with MSYS2.
Here are the constraints I am dealing with, details provided in the postscript:
My program depends on library A, which I can only compile from source using the MSYS2 MinGW.
My program depends on B.dll, a file that was provided to me. I do not have the source.
Using objdump, I discovered that B.dll has file format pe-i386
Using objdump, I discovered that programs compiled with the basic MinGW have file format pe-i386
Using objdump, I discovered that programs compiled with the MSYS2 MinGW have file format pe-x86-64
The end result is this:
My program cannot compile with the basic MinGW because library A (which must be compiled with MSYS2 MinGW) is incompatible
My program cannot compile with the MSYS2 MinGW because B.dll is incompatible
What is the difference between these two file formats? If they are both 32-bit, why can't I compile them together? Is it possible to convert B.dll to be compatible with the MSYS2 MinGW?
Details
Library A is libevent. At some point, libevent requires netioapi.h which does not appear to be present in the basic MinGW. However, MSYS2 MinGW is able to compile libevent.
B.dll is provided to me in Modelsim. It is the library you must link against fro compiling Verilog PLI programs.

why does the error regarding gcc is occuring in matlab?

I have download that code from github.
Whenever that code tries to check mexopencv (a file inside lib folder). It shows an error on Matlab 2017a that is:
[error 3] please make sure gcc >= 4.4 g++ >= 4.4 is installed ...
I am having a gcc version of 8.8.0
Following is the description of system
Window 10
Visual Studio 2012
Matlab 2017a
opencv 2.4.10
mexopencv (install from your folder LIB)
You might lack of standard libraries (.dll in Windows but .lib in Linux). The code was developed under Linux (help is also only provided for Linux systems) and once tested under Windows 7.
The method was tested under OS linux lubuntu 14.04, CPU intel i5 and
16GB of RAM. This guide was written under a linux-based distribution
scope, more precisely debian. Unfortunately we lack experience to
address bugs or any problem that could emerge in non-linux OS, we will
provide only linux OS help regarding execution problems, we apologise.
we tested this code on Windows7. We successfully installed opencv
2.4.10 following this tutorial: [http://www.learnopencv.com/install-opencv3-on-windows/]
This suggests that the mex-function is also linux-based. The error should vanish if you compile the source code yourself on your system, e.g. with MinGW (also GCC), see here.
EDITED:
the README.markdown file (under LIB/mexopencv-master.zip) provides a little guide through the installation process of both, openCV and the mexopencv function for unix (including ubuntu 14.04) and Windows systems. The latter states:
Browse to mexopencv root folder, and type the following in the MATLAB
command window:
>> mexopencv.make
By default, mexopencv assumes the OpenCV library is installed in
C:\opencv. If this is not the case, specify the path as an argument:
>> mexopencv.make('opencv_path', 'c:\your\path\to\opencv')
Note that if you build OpenCV from source, this path specification
might not work out of the box. You need to replace dll files in the
OpenCV package with newly built binaries. Or, you need to modify
+mexopencv/make.m to correctly link your MEX-files with the library.
To remove existing mexopencv binaries, use the following command.
>> mexopencv.make('clean', true)
It requires a standard C++ compiler supported by Matlab (see here), any Visual Studio installation should be OK, as an open-source option MinGW is recommended. Just remember to pick the right system (usually 64-bit).

Deploy mex file without dependencies

I am compiling some mex files that contain CUDA code.
With the right compiler installed, and CUDA installed in the machine, the compilation would always succeed and the code then works fine. Sometimes one can also use the same compiled .mexw64 (in the win64 case) in a different PC without the need of compiling it, as long as that PC has CUDA installed. However, if CUDA is not installed, the execution would fail because it can not find the needed libraries.
Is it possible to compile mex files and include any library/dependency on them, so they can, in most cases, just be copypasted into a new PC and execute?

Can I build mex for linux on mac?

Is it possible to use MATLAB on macOS to build a mex file for running on linux (with the .mexa64 extension)? Suppose that I have an appropriate compiler such as GCC. How would I do this? I couldn't find any useful arguments in mex.
I understand building for a different platform would require a full toolchain, but I'm wondering if MATLAB has one already under the hood.

MATLAB Compiler Runtime (MCR) compiler

I packaged the 7.13 MCR compiler with my files (via desploytool).
I have some questions with assuming the client installed the MCR.
1) If the client doesn't have MATLAB, but just the MCR. he will be able to run my application by the MCR?
2) how can the client make the MCR compiler to be the default?
I tried:
mbuild -setup
Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2010a\sys\lcc
[2] Microsoft Visual C++ 2008 SP1 in C:\Program Files\Microsoft Visual Studio 9.0
[0] None
Compiler:
but I didn't see the MCR. his location is something like: C:\Program Files\MATLAB\MATLAB Compiler Runtime\v713 but I don't know what is the exactly path. should I know it?
3) should I have to make a bat file which configures the MCR to be the default compiler?
The MCR is not a compiler.
MCR is an abbreviation for MATLAB Compiler Runtime. When you use deploytool or mcc (available with MATLAB Compiler or the MATLAB Builder products), it converts your MATLAB program into a standalone component (e.g. an executable or library). You then give your end user the component and the MCR, and the component runs against the MCR instead of MATLAB.
The answer to your question i) is yes, your users only need the MCR, not MATLAB. Your users should not need to interact with mbuild at all, (and if they don't have MATLAB anyway, they can't). mbuild is used by you when preparing to create the component, not by your users when running it.
I think you confuse things. MCR is MATLAB Compiler Runtime. It does not provide any compiler, it allows one to run MATLAB programs compiled and deployed with mcc.
So the answer to your first question: yes, your client needs only to install MCR to run the programs you compile for him using mcc.
The answer to the other questions: there is no compiler..