Is there a way to export an FMU that runs on Mac from a Windows or Linux based software? - fmi

I currently work on simulating a system using a Windows or Linux based software, that can export FMI 2.0 compliant models. Can I run that exported FMU from within a Simulink model running on a Mac?
I tried exporting the FMU from a Linux machine and when I attempted to run the model on Mac, I got an error “Cannot load the library”

You need to export an FMI model containing a MAC compatible binary, as in compiled for MAC. The FMI standard has defined a folder structure so that an FMU can contain binaries for multiple architectures. Most prevalent are probably linux and windows in 32/64 bit but MAC is certainly an option.
Clarify if the tool you export the FMU from supports MAC or at least an FMI export for that architecture.

If your exporting tools supports export of C-Code FMUS (you find it in the sources folder of the FMU, when you unpack the zip file), you can recompile it for mac, e.g. using the command line call or GUI of fmpy. (add platform binary), see e.g.,
https://github.com/CATIA-Systems/FMPy/blob/main/tests/test_c_code.py

Related

How to generate binaries for Linux 64 bit using the source code FMU exported from Dymola. (Cross compilation Windows to Linux)

I have a Simulink model which imports FMU exported from Dymola. I want to run many simulations on this Simulink model by varying some parameters. I want to make use of HPC available in the office. Since HPC runs on the Linux platform, I am not able to use the same FMU on Linux, because of missing binaries for Linux (.so file).
Approach 1:
Since Dymola uses separate FMU build scripts for linux, the best approach would be to install the linux version of Dymola in a VM on your PC and simply export your model there. Your existing license should mostly work as long as your VM can access network locations.
Approach 2:
The FMU compilation in windows is done using a batch file
[Path to Dymola Install]\bin\buildfmu.bat
turn on echo in the batch file and you should see all the steps. Set your compiler to GCC, Export as Source code FMU and recreate all the compilation steps in Linux. This will be tedious and might have windows-specific steps so there is a good chance it won't work out.

Is it possible to compile a Crystal script so it can run on any Linux machine without the user having to download Crystal

There is a Crystal equivalent of OCRA (One-Click Ruby Application Builder) but it's only for Windows and I use Linux.
Crystal unlike Ruby is not interpreted or executed in a virtual machine. Crystal is compiled to native code ahead of execution using the LLVM. Application is started by the operating system not with interpreter.
So yes, onсе compiled app can copy and run for any Linux machine with the same architecture. You may need to install system libs like libssl for use full featured stdlib but it is not critical.
Crystal app is already OCRA (all of included shards will builded into one binary) if you specially have not used dynamic linking.
What to read next:
List of supported platforms
Installation Crystal
Using the Compiler for build app
Crystal reference
And API documentation

How to build Visual C++ apps on Linux that use Windows headers?

I've seen several tutorials on how to compile C++ applications for Windows on a linux system, however, I have failed to find a way to use Windows specific headers (i.e Windows.h) in my C++ program to compile for Windows (.exe/.dll). I was wondering if anyone knew how I can compile Visual C++ programs on Linux that use Windows OS Specific headers/functions (just compile). Thanks!
You can't. Windows system headers, e.g. windows.h reference OS specific APIs that are not known to Linux. Only Microsoft's compiler can create Windows format objects and executables and it doesn't run on Linux.
You can create cross-platform applications consisting of common code that will build and run on Windows and Linux. But the only way to use platform specific APIs in such an application, e.g. GUI, is to #define sections in/out according to the build environment.

Can I compile and run a linux app C++ source on Windows?

I have source code for a linux application. It seems I can compile it on windows with CygWin. My question is, after compilation, can I run it on Windows?
Depends totally on what APIs you use. If you stick to C standard library things, like <stdio.h>, <stdlib.h>, etc. then yes, you can just compile and run on either OS. Or for C++ apps, there is the Standard C++ Library, which any OS / development environment should provide.
If you use any OS-specific APIs, then of course it will not be compatible with another OS. There are libraries however, like APR that try to abstract out the OS-specific bits.
From a casual glance at the code you've linked to, it appears to not use any OS-specific APIs. However:
Note that this code requires the Gnu Scientific Library, http://www.gnu.org/software/gsl/
you'll need to get that library installed as well.
The simple answer is yes; if you can compile a Linux application with Cygwin, then the compiled application will run on windows. Cygwin provides windows implementations of many unix system functions and libraries.
Cygwin/mingw(http://www.mingw.org/) should have most of the tools you need to build the binary. Once the build succeeds, you can run the binary (only) on windows.

Can i use windows libraries in linux and vice versa?

As per my knowledge, windows uses .lib and .dll extension for libraries and linux uses .a and .so. I am working on a project in ubuntu for manipulation with jpeg image files. so i want to know if these libraries can be used interchangeably in linux and windows? for example if have created example.so library in ubuntu and now i want to use it in some compiler in windows...
If you're planning on running under Wine, then yes.
Otherwise the chances are small. Windows DLLs will most probably use Windows APIs not available on Linux. Even if they're not the DLLs are built for use with compilers running on Windows.
Why not use imagemagick? http://www.imagemagick.org/script/index.php

Resources