You can use the MinGW-w64 compiler to build MEX files, a MATLAB interface to a C++ library, and standalone MATLAB engine and MAT-file applications. For more information, see "MATLAB Support for MinGW-w64 C/C++ Compiler".
If you only have the MinGW compiler installed on your system, the mex command automatically chooses MinGW. Go to the next step. However, if you have multiple C or C++ compilers, use mex -setup to choose MinGW.
download mingw-w64 compiler matlab
Download
https://lpoms.com/2xw6sO
Now, to inform the path of the compiler to Matlab, you can write in Matlab command-window, or directly in your m-file the following command.
Replace the given default installation path of the compiler, if you changed it.
I am trying to compile a mex file with MinGW compiler, the mex library is in extern\lib\win64\mingw64\libmex.lib
the header file mex.h is in extern\include\mex.h
Maybe the Matlab_EXTERN_BINARIES_DIR is not currently correctly set?
For using Matlab you need to have a working 64-bit compiler first.
If CMAKE_SIZEOF_VOID_P is still 4, then you had set up MinGW64 to cross-compiler for 32-bit Windows. Or you simply forgot to remove your cache file after switching compilers.
GCC (GNU Compiler Collection) is a free and open source compiler for C and C++ (and other languages like Objective-C, Fortran, D).
MinGW-w64 is a free and open source C library for targetting Windows 32-bit and 64-bit platforms.
The combination of these results in a free C/C++ compiler for Windows.
Even though GCC and MinGW-w64 can be used on other platforms (e.g. Linux) to generate Windows executables, the WinLibs project only focusses on building versions that run natively on Windows.
GCC already runs on many different platforms (including GNU/Linux and Apple macOS) and had been around for a long time (since 1987).
C - and derived languages like C++ and Objective-C - are the preferred programming languages for a lot of software, including many open source projects, and even for operating systems themselves.
Having a GCC compiler on Windows allows making Windows versions of many software projects that already exist for other operating systems (e.g. GNU/Linux).
This allows application developers to build native binaries of their software for multiple operating systems including Windows.
But also, when starting software projects from scratch, it opens up the possibility to use many existing (open source) libraries and better future portability to other platforms (if the developer(s) avoid calling native Windows functions).
Problem: In some cases (e.g. when building GCC 10.2.0) there are printf format compiler errors when building against MinGW-w64 8.0.0. See MinGW-w64 ticket #853.
Solution: No general soluton yet. To fix building GCC 10.2.0 replace #include with # undef HAVE_INTTYPES_H in libgomp/target.c and libgomp/oacc-parallel.c.
Problem: When using GCC 10 there are multiple definition of `' linker errors that weren't there when using earlier versions of GCC.
Solution: Add compiler flag -fcommon. See this link for more information.
Gnumex is currently thoroughly outdated. However, Matlab has been offering support for the MinGW C compiler since version R2015b, and it is possible to call Fortran from C. There is some discussion and an example in a new post on the Gnumex discussion page. 2015-July-2With new changes to Matlab (and possibly also MinGW-w64) gnumex is yet again out of date it seems.However, I came across a solution on stackoverflow (scroll to 1st answer, with heading mingw_mexopts.bat) that allowed me to mex with MinGW-w64. The solution bypasses gnumex by providing an options file that seems to work. I have just posted my version of the file to the gnumex mailing list. Kristjan.2014-March-22The website was overhauled and documentation updated. More is needed but it is an improvement.2013-Sept-06Added support for 64 bit MATLAB
I contacted the MathWorks support, and they told me that most likely the problem is due to the complexity of my model, and that if I cannot reduce its dimensions (and this is my scenario), then the only thing that can possibly be done is looking for a "more efficient compiler" (quote).
You said that in fact I could try with different compilers, but I searched on the web and I could not find explicit information about whether GCC and/or Clang are supported with VeriStand. But I am not expert in compiling, do you have any advice regarding this?
This "Segmentation fault " could caused by many reasons, but which could be obvius is that the compiler has to struggle which such a big file. Maybe you are running out of ram, which could be easily check if you look into your task manager during compilation.
I finally managedd to build a .so file from the Simulink model (basically, the problem of the compilation was the presence of some huge look-up tables; I reduced their dimensions and then the compiler was able to manage the task).
Is it possible that the compilation is actually not able to "translate" correctly some of the Simulink blocks, thus resulting in a computational error of the deployed model, while the compiler does not recognize that something has gone wrong?
Since the original mingGW installer from underneath is not always working this is the best possibility to install the latest version of MingGW-64.Download the latest MSYS2 Installer and follow the steps in the wizard. After installing MSYS2, open the "MSYS2 MINGW64" terminal and download the Mingw-w64 toolchain with help of the package manager:pacman -S --needed base-devel mingw-w64-x86_64-toolchain
MinGW-w64 comprises development tools for compiling and debugging. Download the Mingw-w64 Installer from here and follow the steps in the wizard. It is essential that the installation path does not contain any spaces.Therefore, you cannot install MinGW-w64 in Program Files.We recommend to create a folder mingw-w64 on your system drive (e.g., C:\mingw).Install a current version and specify win32 as thread when requested.Additionally, choose the architecture x86_64.
Open the command prompt of Windows either via the Program Menu or type cmd in the Start Search of Windows. Enter:g++ --versionIf version information of the compiler is displayed, it was successful and you can continue with the next section.
Now that you successfully installed a compiler, you can continue with the next step of the installation tutorial.All information in the installation tutorial is based on a setup with MinGW-w64.For users with previous experience in building a 4diac FORTE, the details are listed:When generating files for compiling in CMake, the tool "Unix Makefiles" has to be selected.Also the architecture option needs to be set in CMake: The correct FORTE_ARCHITECTURE is Win32When compiling, open the Windows command line and go to the folder, where CMake built the binaries. Execute the command make to compile.Where to go from here?If you want to build a 4diac FORTE, here is a quick link back:
These .tar.gz files unpack (with a variety of Windows software, e.g. 7-zip) into a folder with a bin subdirectory that contains libnlopt.dll. To link with this in your compiler, you will typically also want the import library for the DLL, which can be found in the lib subdirectory and is called libnlopt.dll.a (this can be used similarly to the .lib files you may be used to). See, in particular, these instructions for nlopt.
If you want to compile NLopt on Windows with MinGW, be sure to install the MinGW version of cmake (e.g. with pacman -S mingw-w64-x86_64-cmake) and then build via cmake -G"MSYS Makefiles" . && make in order to ensure that cmake produces the correct type of makefile.
I've been given a project to run on MATLAB R2011a. As there are several .c files in there - I need to set up GCC as the MEX compiler for that project. However, I cannot seem to find any explanation as to how to set it up. I've tried a script program called gnumex - but it failed (probably set up for an older version of MATLAB).
If needed, set up the C compiler in a similar manner with a new XML config file specifying the C language, the C compiler frontend (e.g. "x86_64-w64-mingw32-gcc.exe" which won't automatically link the C++ standard library), adjust the link libraries as needed, compiler flags (e.g. change -std=c++11 to -std=c99), etc.
The file below is for x64 version of Matlab and Mingw. I'm using the TDM Mingw64 distribution, which I installed in p:\mingw64-tdm. I have Matlab installed in p:\matlab\R2012a -- edit those accordingly.
f5d0e4f075