Using OpenAeroStruct with Fortran on Windows - python-2.7

I need to run several analyses with OpenAeroStruct on Python 2.7.15 on a Windows 8.1 platform. These are quite computationally expensive so I'm aware that using Fortran could improve performances but on OpenAeroStruct main github page (https://github.com/mdolab/OpenAeroStruct) it is stated that "there is no documented Windows support for the Fortran code". However, I found this question here: Failure to import pyOptSparseDriver that seems to be similar to my issue. If so, how do I install the pyoptsparse library ? I tried to copy the github in my python folder but still the driver seems not to be working.

The usage of pyOptSparse and the usage of Fortran for OpenAeroStruct are independent of each other. Compiling and using the Fortran version of the code will give you the biggest performance gain.
However, as you've found, successfully compiling this Fortran code on Windows is not straightforward. I'd suggest one of three options:
Obtain a system with Ubuntu Linux or Mac OS to use the Fortran version of the code.
Attempt to use Cygwin and a Fortran compiler to set up an environment within Windows where you could successfully install and run OpenAeroStruct's Fortran code.
You could set up an Ubuntu virtual environment within your Windows system, though this would take time and effort to set up and would be less computationally efficient than running it natively.

Related

How do I cross-compile a program that compiles in Linux for Linux, in Linux for Windows?

I am trying to compile a program that I did not write. It compiles for Ubuntu 16.04 in Ubuntu 16.04 just fine using the following commands.
qmake
make
Is there a simple way to cross compile it for Windows 32bit or 64bit via the manipulation of those commands without any changes in the programming? It is meant to be able to be compiled for windows as well. I have tried countless variations on how to do this with various libraries, all don't work, seemingly due to missing steps in the instructions (or so I'm guessing).
Edit: The program uses C++.
Edit: I am also trying to employ MXE.
Every program requires a runtime environment. Some languages are known to be compiled on most OS by offering a custom runtime for them. Depends on which programming language you are using. Example, Java programs just need a specific JRE for Linux or Windows to run. C#/.NET programs need Mono/Rosylyn variants (may not be fully supported for Linux).
You need to mention the language of your program to figure out the corresponding toolset for a given OS.

Development in Cygwin C++

For a few years I was writing programs in Visual Studio for Windows and with GCC (Code Blocks) for Linux. Most of my libs compiled seamlessly as they worked both in Windows and Linux. However at the moment I am a bit confused, as I have to create an app using Cygwin. I don't really understand if I am still in UNIX/Linux environment, just running app on Windows by some "emulation", or I am rather on Windows just having access to some Linux/Unix functionality. From what I understood from the FAQ's and documentation it looks like I just should behave like in Linux environment.
All explanations I found in internet usually are very general and don't explain the detailed differences from programmers viewpoint.
Short question: Can I just write programs like I did for Linux without any major changes when using Cygwin?
Maybe.
A lot of code written for Linux will compile in Cygwin with very few problems, which can mainly be fixed by messing with preprocessor definitions.
However, any code written for linux which:
Uses a Linux driver
Directly accesses the kernel
Relies on any code which does either of these two things (and doesn't have a Windows counterpart)
will quite definitely not work, regardless of how much you modify the code.
Much as it tries to, Cygwin cannot fully emulate (yes it is an emulator, of sorts) everything a POSIX system can normally do. Cygwin is not windows, just a conversion layer from its own machine language.
For more information, read cygwin's wikia
Can I just write programs like I did for Linux without any major
changes when using Cygwin?
The platforms are not identical, so you can not realistically expect to write the program in Linux, and then POOF expect it to build and work under Cygwin. But if you don't use things not available under Windows, then you won't need major changes. And you can write non-trivial programs, which will build and work on both, perhaps needing a few #ifdefs in places.
From your question I take it you want to work on Linux, but write programs for running under Cygwin. In that case you must also build and test it in the Cygwin environment all the time, so:
Use version control, commit often. I recommend a DVCS like git or mercurial which have separate commit and push, it will allow you to do commits more freely.
Whenever you commit/push, do checkout/pull and build on the Cygwin host. You can do this manually or automatically (by simple custom script polling the version control, or by Jenkins or something).
When ever your code stops building or working under Cygwin, fix it before continuing with new code.
If Cygwin is not absolute requirement, then I would look into using Qt SDK. It can be used for non-Qt projects too, the MinGW toolchain on Windows is very similar to gcc on Linux. And if you're willing to use Qt, then it has all sorts of platform-independent features for things you might want to do, such as discover locations of standard directories for saving files, use threads, print things, have GUI...

Compiling 32-bit python on a 64 bit machine

While I know this has been asked here before, it has been several years since the last time I can find, and there was no successful solution to this question, so here we go.
I have a copy of x64-bit SPSS for *nix that requires on a 32-bit python2.7.3 installation for extended functionality. Unfortunately for me, I run an ubuntu x64 machine, and I've been unable to compile 32bit python on it. I've been able follow both sets of instructions also tested at this link https://askubuntu.com/questions/29253/how-can-i-install-a-32bit-python-on-64-bit-ubuntu but have not had any success with it following the flags. Both resulted in the correct location/unicode settings, but compiled x64 versions. I've checked for missing packages, but none of the recommended packages seem to be missing.
Any help with compiling python (or even an alternative method) would be greatly appreciated. As it is, the only solution I can think of is to create a chroot jail.
Have you considered running 64-bit SPSS and using 64-bit Python?

Will a C++ Linux app built on version X.XX of the kernel run on an earlier version?

This question may seem blindingly obvious and I realise I am putting myself up for a large number of downvotes but I am very new to Linux dev and have only been working on it for a while.
I have been writing an application on ubuntu 12.04 (kernel 3.2.0) in C++ then copying this via scp to an ubuntu 8.04 (kernel 2.6.30) installation on another device. I have been noticing some very strange behaviour that I simply cannot explain. I have naively assumed that I can run this executable on a previous version, but it is beginning to dawn on me that this in fact may not be the case. In future must I ensure that the Linux version I build my application on is identical to that which it will be running on in the field?? Or must I actually build the application from source code directly on the device it will be running on??? I am very new to Linux dev but not new to C++ so I realise that this question may seem facile, but this is the kind of issue that I have simply not seen in books/tutorials etc.
Most of the time, it's not the kernel that stops you, it's glibc.
glibc is backwards compatible, meaning programs compiled and linked to an older version will work exactly the same with a newer version at runtime. The other way around is not that compatible.
Best is of course to build on the distro you want to run it. If you can't do that, build on the one with the oldest glibc install.
It's also very hard to build and link to an older glibc than the system glibc, installing/building glibc tends to mess up your system more than it's worth. Set up a VM with an old Linux, and use that instead.

Building a library across platforms without running all of the platforms

I have a small piece of code that works as a plugin for a larger graphics application. The development platform is Qt with c++ code. I've managed to build a .so, .dylib and .dll for linux, MacOS and Windows respectively, but to do so I had to have a machine running each operating system (in my case, running linux [ubuntu] gcc natively, and windows MinGW and MacOS XCode gcc in virtual machines).
Is there a way to build for all 3 platforms from one? I beat my head against this problem a while back, and research to date suggests that it's not easily (or feasibly) done. The code only needs to link against a single header that defines the plugin
API and is built from a fairly basic Makefile (currently with small variations per platform).
You should have a look at crosscompiling.
You basically build a compiler that (on your current plattform) will output binaries for your desired platforms.
Try this link about doing it on linux, for windows, with QT
Better late than never, I just came across IMCROSS
It looks quite promising!
For Linux it is fairly easy to setup or even download a virtual machine using VMWare for instance. Getting OSX to run on VMWare is somewhat tricky but possible.
Running VMWare and sharing a directory on a local drive you can even compile for the different platforms using the same exact files.
There is somewhere a cross-compiler for OSX but I wouldn't trust it to be of great quality.