Is there any POSIX compatibility layer for Windows x64? - windows

I'm trying to compile Redis for Windows x64 with no luck.
I tried different things
Cygwin works perfectly but GCC produces only 32 bit executables
Compling with Mingw-w64 will not work without a lot of code changes (My understanding is that MinGw does not provide POSIX compatibility for Windows)
Microsoft Services for Unix has an outdated GCC version and requires the Unix subsystem to be installed as a dependency
Any idea?

Ruling out MSU, there is no POSIX compatibility layer for Win64. Your best bet is probably on working with mingw-w64 and provide yourself fallback Win32/Win64 code for the POSIX calls you need. That's painful, of course.

Related

mingw ld cannot find -lpthread?

I'm trying to cross-compile a C/C++ program for Windows on Linux.
I've gotten to the point where everything compiles properly, except that x86_64-w64-mingw32/bin/ld is called with the option -lpthread, which doesn't work.
I'm not sure why it's called with that option, because I'm 100% certain that there are no references in the code to threads except through CreateThread, which is part of the Windows API. There's no good reason for mingw to try to link in pthreads if I'm not using them, right?
(Fedora 32 but 64-bit, if it helps.)
There is no way to teach the GCC compiler driver to drop "-lpthread" if the compiler was configured to include pthread support.
I guess you are trying to do a static build (?) and the libpthread.a is not installed by your toolchain.
See a related bug report # https://bugzilla.redhat.com/show_bug.cgi?id=2070571

Linaro ARM bare metal cross compiler on Windows and libwinpthread-1.dll

The Windows binary distribution of the Linaro gnu AARCH64 ARM cross compiler (based on mingw) has a dependency on a library libwinpthread-1.dll. When I run .\aarch64-elf-gcc.exe --version I get a pop-up that says
The program can't start because libwinpthread-1.dll is missing from your computer. Try reinstalling the program to fix this problem.
For the life of me I can't seem to find anything about this library, where to find it, build it, etc. Based on the name it seems obvious that it is some pthread library for windows, but maybe not. The cross compiler is a 32-bit Windows binary for a 64 bit ARM target. The host is 64-bit Windows 10.
Any idea where I can find a 32-bit version of libwinpthread-1.dll?
The latest version of the tool chain at
https://releases.linaro.org/components/toolchain/binaries/6.1-2016.08/aarch64-elf/
seems to not have this problem of a missing dll
It can be found in
gcc-linaro-6.1.1-2016.08-i686-mingw32_aarch64-elf\libexec\gcc\aarch64-elf\6.1.1\libwinpthread-1.dll
Ed

Compile Ada program for Linux using Windows

If I want to compile a program that is written in Ada, I have to use GNAT, of course.
As my Computer has Windows as its sole operating system, I cannot use GNAT, normally. Right? Thus I got Cygwin which enables me to use GNAT on Windows.
But the result is an executable that runs under Windows - not Linux. So how can I compile the Ada code for Linux although I only have Windows? (Please don't think about the reasons ...)
Is this possible with Cygwin? Do I have to install a virtual machine with Linux? Or is there another (easier) solution to this issue?
I have to use GNAT, of course.
Not true; there are other Ada compilers. (GNAT is the only one I know of that's free.)
Running GNAT under Cygwin gives you Cygwin executables, which are Windows executables that depend on cygwin1.dll. They will not work on Linux. See the "What ... isn't it?" section on the Cygwin home page.
There is a GNAT for Windows. The GNAT Pro version has a list of supported platforms here; it includes Linux and Windows, but it doesn't show a Windows-to-Linux cross compiler.
Since GNAT is free software (GNAT Pro isn't is a little more complicated; I won't get into that) there could well be a Windows-to-Linux GNAT cross-compiler -- or, if you're really ambitious, you could build one yourself (or hire someone to do it for you).
But installing GNAT on a Linux system is the easiest approach. It doesn't have to be a virtual machine. If you have the hardware, you can install some Linux system by itself, or you can set up a dual-boot system on your Windows box. Ubuntu has a Windows installer, Wubi, that installs an Ubuntu image as a Windows file; it doesn't let you run Windows and Ubuntu concurrently, but it lets you dual-boot without having to repartition.
There are other options; these are just the ones I'm familiar with.
Is this possible with Cygwin?
It's probably possible.
Do I have to install a virtual machine with Linux? Or is there another (easier) solution to this issue?
Installing a Linux on a virtual machine is likely to be the simplest solution to your problem.
Since GNAT is free software (GNAT Pro isn't; I won't get into that) there could well be a Windows-to-Linux GNAT cross-compiler -- or, if you're really ambitious, you could build one yourself (or hire someone to do it for you).
Actually GNAT Pro is Free Software, free as in freedom, not as in beer.
And I think that it would be simplest to install Linux in virtual machine and compile with it.
AdaCore has a gnat compiler for the Windows operating system freely available at: http://libre.adacore.com/libre/download/ and choose "Free Software..." and click "Build Your Download Package" and go from there. As Keith Thompson suggests, you can setup a dual-boot solution if you actually need a Linux compatible executable. Remember any program compiled on Windows results in a Windows-only executable unless you have a compiler that allows for cross-compilation.
It became possible for them who use Windows 10 64 bit with new "Linux Subsystem" feature. You may install gnat on it and use it to compile ELF binaries, as well as windows binaries.

Is it possible to use the SANE backend on windows platforms?

I have to develop a scanning application for the Canon 9000F, but I'm having troubles with WIA and TWAIN. I've read on the SANE project's home page that this specific scanner works pretty well with their technology, so I would be interested if it is possible to use the SANE backend on Windows platforms.
I found some information on this website: http://www.zago.net/sane/windows/sane_on_windows.html
SANE on Windows:
The port has been integrated in the CVS tree on september 23rd, 2003.
It will be available in SANE release 1.0.13.
Windows is also listed as platform on the SANE's wikipedia page:
Operating system: Microsoft Windows, Linux, UNIX, OS/2
In spite of this very interesting thread: sane runs in windows without cygwin I think that your only really viable option for using SANE on Windows is to use Cygwin or MinGW with MSYS. From the README.windows file:
SANE on Windows
Prerequisites
To be able to compile sane-backends, you need to have either Cygwin or
Mingw compilers and a suitable POSIX compatible environment.
You can get the Cygwin POSIX compatible environment for Windows
Windows and the Cygwin gcc compiler at http://www.cygwin.com
You can get the MSYS POSIX compatible environment for Windows and the
MinGW gcc compiler at http://www.mingw.org/wiki/MSYS
The scanner must be detected by Windows and not be disabled. Check
with the hardware manager.
Once you have either of those, you can untar and build SANE from the source code (check the readme for the required libraries) and it may or may not work with your Canon 9000F Scanner.
As you say, the chances are good that it will work as it is listed as supported under the pixma backend.
The difficult part was handled by TWAIN which is no longer an option as Windows moves forward. The SANE backends need to be built under Cygwin. Won't build with Mingw - no POSIX functionality.

Compile Linux application for Windows (C)

can I compile a linux application, with Linux-only available libraries, for Windows ?
I know the author of nginx web server uses some Wine tools to get his Linux-based project working on win32, natively, but how does he do that ?
Is MinGW support to create Windows binaries linked with Linux-specific libraries/headers ?
PS: I do not want to use cygwin due to big lost about performance...
Using something like mingw32 environment, you would have to find or build yourself all libraries on which the project you want to build depends (and all libraries on which those libraries depend).
You might end up having to implement some functionality which is missing on that platform. One of the reasons cygwin is slow is the hoops it has to jump through to simulate unix-y things that are missing on windows.
As long as the project uses the standard libraries on Linux and do not depend on anything specific to the Linux platform, the Mingw port of GCC can compile it on Windows.
If you are familiar with Linux tools and you don't Cygwin, you might want to take a look at MSYS:
MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. It is intended to supplement MinGW and the deficiencies of the cmd shell.

Resources