How to generate an executable form a matlab gui that doesn't require Matlab Compiler Runtime (MCR) on the machine - matlab-guide

How to generate an executable from a matlab gui that( The exe file) doesn't require Matlab Compiler Runtime (MCR) on the machine.
When I include Matlab runtime within the package, the size becomes too big.

The closest you can come is to generate C/C++ code using Matlab Coder and build it as a standalone C/C++ executable, but Matlab-Coder has many quirks and doesn't support the full set of Matlab functionality. Expect some rough waters if you head that way.
Using matlab Compiler - I'm afraid it just can't be done.

Related

Compiling COBOL as 32-bit Executable For Windows

I am diving into the world of COBOL and have written a simple program that compiles and runs as intended from my KDE Plasma command line using open-cobol (cobc). I have seen a few sites mention that COBOL is quite portable and does not require multiple compilations, but when I try to run the same output program on Windows 10 (ie 32-bit), the system states that the program is a 16-bit application and thus cannot run.
Are there parameters that I can use with cobc to compile in such a way that my programs will run on Windows 10, or am I fundamentally misunderstanding the portability of this language?
Compilation command: cobc -x -o program program.cob
Your program is likely already a 64bit executable (depending on your actual OS, otherwise its 32bit), but it is definitely no Windows binary (and because Windows doesn't recognize it, it just guesses this is a 16bit executable).
COBOL itself is portable, even between different compilers (if you restrict yourself to "standard" COBOL or use only the extensions that the compilers used share), but you need "some" native parts in any case.
As a well known example take Java or .NET: the "runtime" is a native binary, which executes the java (or msil) byte code.
There are some COBOL compilers generating intermediate code which is actually portable and can be used with the "native runtime" you have to install beforehand.
The easiest option for your case: take a compatible compiler and recompile your COBOL source for this platform on this platform.
I'd suggesting the successor of OpenCOBOL: GnuCOBOL, using the official windows binaries.

gdb, how to step into c runtime? Where is crt_c.c?

When I'm stepping into debugged program, it says that it can't find crt/crt_c.c file. I have sources of gcc 6.3.0 downloaded, but where is crt_c.c in there?
Also how can I find source code for printf and rand in there? I'd like to step through them in debugger.
Ide is codeblocks, if that's important.
Edit: I'm trying to do so because I'm trying to decrease size of my executable. Going straight into freestanding leaves me with a lot of missing functions, so I intend to study and replace them one by one. I'm trying to do that to make my program a little smaller and faster, and to be able to study assembly output a bit easier.
Also, forgot to mention, I'm on windows, msys2. But answer is still helpful.
How can I find source code for printf and rand in there?
They (printf, rand, etc....) are part of your C standard library which (on Linux) is outside of the GCC compiler. But crt0 is provided by GCC (however, is often not compiled with debug information) and some C files there are generated in the build tree during compilation of GCC.
(on Windows, most of the C standard library is proprietary -inside some DLL provided by MicroSoft- and you are probably forbidden to look into the implementation or to reverse-engineer it; AFAIK EU laws might mention some exception related to interoperability¸ but then you need to consult a lawyer and I am not a lawyer)
Look into GNU glibc (or perhaps musl-libc) if you want to study its source code. libc is generally using system calls (listed in syscalls(2)) provided by the Linux kernel.
I'd like to step through them in debugger.
In practice you won't be able to do that easily, because the libc is provided by your distribution and has generally been compiled without debug information in DWARF format.
Some Linux distributions provide a debuggable variant of libc, perhaps as some libc6-dbg package.
(your question lacks motivation and smells like some XY problem)
I intend to study and replace them one by one.
This is very unrealistic (particularly on Windows, whose system call interface is not well documented) and could take you many years (or perhaps more than a lifetime). Do you have that much time?
Read also Operating Systems: Three Easy Pieces and look into OsDev wiki.
I'm trying to do so because I'm trying to decrease size of my executable.
Wrong approach. A debugger needs debug info (e.g. in DWARF) which will increase the size of the executable (but could later be stripped). BTW standard C functions are in some common shared library (or DLL on Windows) which is used by many processes.
I'm on windows, msys2.
Bad choice. Windows is proprietary. Linux is made of free software (more than ten billions lines of source code, if you consider all useful packages inside a typical Linux distribution), whose source code you could study (even if it would take several lifetimes).

How can I compile and run a C program (with OpenMP) in gem5 Full System?

I am an undergraduate student working on my thesis about parallel programming.
I am using OpenMP model. Now i want to use gem5 for measure performance.
That's why i install gem5 Full System successfully by following link:
http://cearial01.kaist.ac.kr/index.php/2016/08/26/gem5-documentation/
Now i want to compile & run a c program with OpenMP (matmul.c) using gem5.
How can i compile & run this program?
I mean inside which folder i stored this program file (matmul.c) for compile?
How i create object file of this program?
How can i change no of processor, cache memory size, no of cpu during running & compilation?
I am new student of this section. That's why my asking list is too big!
Hope anybody don't mind.
Best Regards,
Litu
How can I compile and run this program? I mean inside which folder I stored this program file (matmul.c) for compile? How I create object file of this program?
How to cross compile for an image is not gem5 specific, so I'll be brief.
First you must obtain a cross compiler for the image.
The best way to do that, is to get a cross compiler from the same source as the image to ensure compatibility.
My preferred approach is to use minimal Buildroot images. Buildroot:
builds both the cross compiler and the image for me, and thus ensure compatibility
makes it easy to automate building new software with its package system
can produce very simple images, which are more suitable for gem5 and architecture research
This is my setup on GitHub. It contains a minimal OpenMP hello world which I have successfully run inside of gem5.
Another good option is to use https://crosstool-ng.github.io/
Since you want OpenMP support, you must build the GCC cross compiler compiler with support.
I think this is done in GCC with:
./configure --enable-libgomp
or through the Buildroot option:
BR2_GCC_ENABLE_OPENMP=y
And then when compiling, you must pass the -fopenmp option to gcc.
How can I change the number of processors and the cache memory size?
The best way to answer that question yourself is to use something like:
./build/ARM/gem5.opt configs/example/fs.py -h
and search the options.
You come across:
-n NUM_CPUS, --num-cpus=NUM_CPUS.
For ARM you also need to pass a .dtb with the corresponding core count, e.g.: ./system/arm/dt/armv7_gem5_v1_2cpu.dtb for 2 cores.
caches: you will find the following options easily:
--caches --l1d_size=1024 --l1i_size=1024 --l2cache --l2_size=1024 --l3_size=1024
But keep in mind that:
the Linux kernel does not see the cache sizes correctly as of fbe63074e3a8128bdbe1a5e8f6509c565a3abbd4
How to switch CPU models in gem5 after restoring a checkpoint and then observe the difference?
caches only affect certain CPU types, usually the more detailed such as ARM HPI and x86 DerivO3CPU, but not AtomicSimpleCPU.

What makes DosBox on web.archive.org so slow despite JIT?

I wanted to see if I could play Exile 2 from web.archive.org and I found that I need to install it first, which takes ages. Given that I'm basically emulating x86 machine on an x86 computer, DosBox supports dynarec (dynamic recompilation) and contemporary browsers support JITing the JavaScript code (and Emscripten generates asm.js, which should be rather easy to JIT), what makes it all so slow? In other words, what could be the bottleneck?
Dosbox is compiled using Emterpreter, which makes it slower than the pure asmjs version:
The Emterpreter is an option that compiles asm.js output from Emscripten into a binary bytecode. It also generates an interpreter ("Emscripten interpreter", hence Emterpreter) capable of executing that bytecode. This lets you compile your project, or parts of your project, into bytecode that will be interpreted, as opposed to asm.js that will be executed directly by the JavaScript engine.
The second reason is, that the Dynamic recompilation in the emscripten port of dosbox is not available yet. It would be a lot of work, to make it possible to create asmjs code on the fly.

Converting MATLAB model code to C++ and using in Linux

I have matlab installed in windows based system. I have generated a model for the application.
I want to convert this code to C++ code and use it in a linux based system. I converted this code using auto coder to C code but I am not understanding how to use it in a linux based system.
Please let me know what are the steps to be followed?
Thank You
You have to build a project (or a makefile for linux) around the generated C files. With a decent compiler, you should be able to compile these under Linux as well as under windows.

Resources