|
|
Subscribe / Log in / New account

MinGW and why Linux users should care

By Jonathan Corbet
November 19, 2008

The Minimalist GNU for Windows (MinGW) project is a way to get GCC and tools like binutils working to build software for the Windows environment—something that might not sound very interesting to Linux users or developers. But there are a number of advantages to porting and regularly testing free software on Windows, as Red Hat's Richard Jones and Dan Berrange explain in the following interview. Richard and Dan also describe Red Hat's involvement, how developers can participate, as well as how it all helps the free software cause.

LWN: Could you describe the MinGW project? How did it get started?

Richard: For some time I have been making Windows builds of libvirt available and, frankly, it was a real chore. I needed a Windows virtual machine to do it. But Windows is so frustrating to use and maintain: it doesn't come with any of the tools such as shells or version control that we are used to, and because I was only doing builds once a month or so I'd go back to it and find something had gone wrong that would require maintenance or even reinstallation.

During this time, we didn't routinely build libvirt for Windows. New code would inevitably break something. I had to fix things on Windows, then copy the code back to Linux and check that my fixes didn't break the Linux build, then come up with a patch, and all of this was complicated by the fundamental incompatibility of Windows with the rest of the world -- even simply copying code back and forth is irritatingly difficult when one machine is a Windows machine. (There's no ssh or scp or tar, files get executable bits set or have CRLF line endings, etc.)

At the same time we were getting a strong demand for the rest of our virt tools on Windows. Enough was enough. We decided that the only way to deal with this was to remove Windows from the equation. We wanted to build and test libvirt and the virt tools for Windows routinely (daily or more often), from the Fedora host, using the normal development environment. The way to do this is through cross-compilation (the Fedora MinGW project) and testing under emulation (Wine).

Debian & Ubuntu have been shipping the MinGW cross-compiler for quite a while, but it's important to say that the cross-compiler itself is the easy bit. The hard part about this project are the 50+ libraries and development tools that we ship and maintain alongside. Without those, just having the cross-compiler is fairly useless.

Dan: The libvirt project started a few years ago to provide an API for managing Xen virtualization hosts. Initially it was just a locally accessed C library, but over time the project expanded in scope to allow remote RPC access to the management APIs, and over other virtualization technology like QEMU, KVM, OpenVZ, LXC (native Linux containers) & User-Mode Linux. Shortly after we added support for RPC, a number of community members expressed an interest in using the client side from the Windows platform to manage their Unix hosts. Periodically people would contribute patches to make libvirt build on Windows, but soon after they were applied, new unrelated work would break the Windows build again.

It became clear that if the libvirt community was to officially support building a Windows client, then all developers needed to be able to easily test builds for Windows. The obvious stumbling block here is that most of our community developers do not use or even own Windows machines for testing. The MinGW project provides a cross compiler toolchain and stubs for the Win32 APIs to allow building of Windows executables and DLLs from a Linux host. Add in WINE and you can also run your cross-compiled build. MinGW and WINE are completely open source, so we can provide a very good level of support without ever having to purchase a Windows license or leave our primary Linux development environment.

We are not the first people to see the value in MinGW for supporting Windows platforms in open source software. Prior to the the start of the Fedora MinGW effort, Fedora developers would have to build all the cross compilers & libraries themselves. This is not particularly hard, but it is a lot of wasted effort to have everyone duplicating the work. Providing the MinGW compiler toolchain, and important libraries such as libxml, gnutls, libpng, libjpeg, GLib, GTK, etc directly in the Fedora repositories enables developers to focus on their own code, rather than the cross-compilers.

LWN: What is Red Hat's involvement in MinGW?

Richard: Dan and I work for a Red Hat group responsible for fostering the development of new tools and technologies. We have an eye to productisation and I spend quite a lot of time going to customer conferences and asking them what they want to see, but as for whether MinGW will make it into some future supported Red Hat product I cannot say.

Dan: Red Hat initiated development on the libvirt project and supports its ongoing evolution with significant developer resources. Red Hat wants the libvirt project to be the de facto standard for managing virtualization hosts, and the project community members want Windows to be a supported client platform. The work we are doing on the MinGW project in Fedora is thus a response to demand from the libvirt community for better Windows support in our releases. It is just a small part of our day job, alongside major libvirt feature development for Linux systems and in particular KVM & Xen.

LWN: Why does Red Hat care? Are you going into the Windows software business now?

Richard: Red Hat certainly cares about libvirt, and making libvirt available on the widest range of platforms. The alternatives to libvirt are interfaces like XenAPI and VMWare's APIs, which lock customers into proprietary technologies. Any way we can make it easier to provide open APIs and open source software even on closed platforms like Windows is a win for Red Hat, the Linux community, and even for Windows users.

Dan: As Richard says, this effort isn't about any particular Red Hat product. It is a community focused effort to address demand from libvirt users for better Windows client support. People are interested in open source virtualization technology like Xen and KVM, as an alternative to closed source solutions. Open source exists in a heterogeneous world though, and even if someone decides to migrate their servers to virtual machines on a Linux KVM host, they may still need to manage these servers from a Windows desktop. The MinGW project helps us maintain a reliable client build for the Windows platform, and thus lets a broader spectrum of users take advantage of open source virtualization technology. Growing the size of the libvirt community, and encouraging use of virtualization is what is important to Red Hat, and the MinGW project is one small part of that effort.

LWN: Why should free software developers care about MinGW? Does it do anything for them?

Richard: There's been some opposition, along the lines of "why are we helping Windows?". IMHO people who say that are ignoring both history and reality. First the history bit: the GNU project started off as a set of better compilers and command-line tools for the proprietary Unix systems of the day. I remember before Linux was around that you'd get some horrible system like HP-UX or (in my case) OS-9, and the first thing you would do would be to install all the GNU tools. Without real GNU grep, make, awk, bash, those systems were less than useful. Eventually when GNU got a kernel (Linux) we moved over to that system because it came with all the good tools.

Second the reality bit: Windows users are locked into proprietary applications and file formats, everything from Photoshop to QuickBooks to MSN to Illustrator. No Windows user can switch without first switching all their applications, which is going to be a very long transition process. Therefore we need a way to enable the developers of Gimp, GnuCash, Pidgin, Inkscape (to pick four out of hundreds) to easily build and test their software for Windows, so they can ship their software for Windows, respond easily to bug reports, and break that proprietary lock-in. Fedora MinGW does this - in fact we already used our compiler and huge chain of libraries to port Inkscape. Another thing we've found in porting to other platforms, is that it can generally improve the quality of the codebase. Different compilers and runtime environments expose different bugs in an application. The more combinations you can regularly build & test on, the better the overall quality of your code.

Dan: The libvirt project started off with a strong Linux focus due to our immediate needs for a management API for Xen in Fedora and later RHEL-5. Over time the community has contributed patches to improve our portability to non-Linux platforms, in particular Solaris and more recently Windows. While Red Hat's focus is on Linux, enabling portability to other platforms is important because it grows the size of your developer community. Every significant open source project has a huge wishlist of features and nowhere near enough developers and testers to address them all. Cross-platform portability enlarges the pool of potential contributors. They may initially only send minor patches to fix portability bugs for Windows, but over time they can end up working on major new features that benefit every platform.

Another thing we've found in porting to other platforms, is that it can generally improve the quality of the codebase. Different compilers and runtime environments expose different bugs in an application. The more combinations you can regularly build & test on, the better the overall quality of your code.

LWN: Is there anything in particular that developers should keep in mind to make life easier for people building their code for MinGW?

Richard: My pet list would be:

  • Don't write your own build system. Use autoconf/automake/libtool or cmake. That's not to say I'm a great fan of autoconf, but these really do make cross-compilation almost trivial.

    Autoconf-based programs can generally be cross-compiled by doing:

         yum install mingw32-*
         ./configure --host=i686-pc-mingw32
         make
    
  • Don't try to run executables during the build phase. It doesn't work when you're cross-compiling.
  • Do use pkg-config. And if you can't use pkg-config, then make sure your *-config program is a shell script, not a binary.
  • Do use common, portable libraries such as glib, gtk, libvirt or any of our other libraries.
  • Please use Fedora MinGW to routinely cross-compile your own code for Windows.

Dan: I have been pleasantly surprised at just how easy it has been to build many open source libraries with MinGW. Despite almost universal dislike for autotools, the applications which use autotools have been some of the easiest to port, particularly when it comes to building DLLs. The apps with home-brewed build systems have been much more involved. I definitely echo Richard's suggestion to stick to a broadly supported build system like autotools or cmake.

Any project which is serious about enabling support for Windows in their releases should make sure they are running regular automated builds & tests of their codebase. This is actually just good sense for any software engineering project regardless of whether Windows support is desired - it just happens to be particularly useful for configurations that developers rarely test on a day-to-day basis to avoid otherwise unnoticed regressions.

If you are not using a support library like GLib, QT or NSPR (which provides a degree of cross-platform portability) then seriously consider making use of Gnulib. This is a library of code which you can drop into an application, fixing POSIX API portability problems on various platforms. As an example, it replaces Winsock's socket() call so it returns real file descriptors that you can use in both read() and recvfrom(). It can't fix all problems - such as the lack of fork()/exec() on Windows - but if your application / library is written against POSIX, using Gnulib will significantly improve your portability across all Linux, UNIX and Windows platforms.

LWN: What are the biggest challenges that your project faces now? How can the community help?

Richard: Scaling the project is a big challenge. Red Hat dedicates quite limited resources to this project. The only way we can scale it is if the application developers themselves start to use our tools to build and maintain their own programs. I would like to see everyone who has an important Linux app or library start building and shipping for Windows routinely. Bringing open APIs, apps and file formats to Windows users is important: It's important to Windows users because it breaks their lock-in and makes switching to a fully free platform easier down the road. It's important for you, because your potential audience of users will increase by a factor of 10x or 20x.

Dan: Spreading the package maintenance job across a larger number of Fedora members is an important task. There is a limit to how many packages a single person can do a good job at maintaining. To make it manageable we track & pull patches from the native builds to the MinGW cross-compiled builds of common packages. Ultimately we still need more package maintainers to look after the cross-compiled builds.

There are some core pieces of the open source ecosystem which do not work / are not fully portable to a Win32 environment. The most obvious one being DBus, which is used by an ever increasing number of apps for local RPC. There have been a number of efforts to port DBus, but none ever completely finished & merged into the official releases.

LWN: Anything else you'd like to say to LWN readers?

Richard: Get involved.

Dan: Cross platform portability is often beneficial to your project even if you personally only care about its use in Linux. In the libvirt case it is opening up use of libvirt & virtualization to a set of users who have only ever had access to closed source virtualization technology. Portability broadens the pool of potential contributors to your project. Open source developers on the various BSDs, OpenSolaris, and Windows all have the potential to make valuable contributions to your project.

[ We would like to thank Richard and Dan for taking time to answer our questions. ]


to post comments

MinGW and why Linux users should care

Posted Nov 19, 2008 15:13 UTC (Wed) by cde (guest, #46554) [Link] (10 responses)

The main problem about building with MinGW is that you don't get the security benefits you have with VS2005 or VS2008; /GS (stack cookies), /DYNAMICBASE+/NXCOMPAT (address randomization), /NXCOMPAT (prevention against execution) and lastly /safeseh.

See for example VideoLAN, http://milw0rm.com/exploits/7051 which has none of these flags above and is trivially exploitable.

MinGW and why Linux users should care

Posted Nov 19, 2008 15:13 UTC (Wed) by cde (guest, #46554) [Link]

Sorry, I meant /DYNAMICBASE+/FIXED:NO

MinGW and why Linux users should care

Posted Nov 19, 2008 15:37 UTC (Wed) by jreiser (subscriber, #11027) [Link]

How does /GS differ from gcc -fstack-protector , and what about the -fpie option compared to /DYNAMICBASE+/FIXED:no ?

MinGW and why Linux users should care

Posted Nov 19, 2008 15:38 UTC (Wed) by mjthayer (guest, #39183) [Link] (2 responses)

VC++ (at least the command line interface) will run under Wine, if you want to achieve the same thing using that compiler. You will have the same set up issues with libraries and whatnot.

MinGW and why Linux users should care

Posted Nov 19, 2008 17:46 UTC (Wed) by jdahlin (subscriber, #14990) [Link] (1 responses)

Yeah, but the installers of VS/VS express have a long history of not working in wine as the exercise various levels of the window api which is not properly implemented in wine.

MinGW and why Linux users should care

Posted Nov 19, 2008 18:59 UTC (Wed) by mjthayer (guest, #39183) [Link]

It really is doable - I have been cross-building Windows stuff on Linux much of this afternoon. I didn't set up the environment myself though - maybe the stuff was unpacked under Windows and just copied over.

MinGW and why Linux users should care

Posted Nov 19, 2008 17:00 UTC (Wed) by rwmj (subscriber, #5474) [Link]

This is correct to some extent. Currently we build without -fstack-protector because that feature doesn't work in the version of GCC we are using.

Longer term, we want to add / fix all of these features in GCC and the toolchain, stack protection, NX, address space randomization, etc.

Using Visual Studio isn't an option for Fedora because of its non-free status, no matter how good the security features may be.

(I am "Richard" in the article).

MinGW and why Linux users should care

Posted Nov 19, 2008 17:45 UTC (Wed) by tialaramex (subscriber, #21167) [Link] (1 responses)

How much of this just consists of setting some flag fields in the output PE executable?

IIRC at least the NX compatibility and address randomisation are flags. If Microsoft are going to get praise for the improved backwards compatibility, they deserve all the blame for applications that don't get the benefits.

Providing suitable linker flags for MinGW that produce suitably flagged PE executables (perhaps by default) would be nice, but it shouldn't be difficult to do it by hand meanwhile.

MinGW and why Linux users should care

Posted Nov 20, 2008 13:09 UTC (Thu) by PaXTeam (guest, #24616) [Link]

until binutils/ld gets proper support, one can use editbin.exe from VS to set these bits in the PE header (it's a console app, should run fine in wine).

MinGW and why Linux users should care

Posted Nov 19, 2008 22:32 UTC (Wed) by danpb (subscriber, #4831) [Link]

Disclosure: I'm the 'Dan' in the article :-) There are two distinct (but related) use cases for our the MinGW work. First for developers who work on Linux on a day-to-day basis, but want to make sure their code still compiles against Windows. Second, for developers who actually want to ship Windows binaries built with MinGW. For the first case, the lack of the security features in VS is not a problem, since it is basically just being used as a developer testing service. For the second case, clearly there is a downside to not have these features at all, but GCC itself does have potential to include some of them & more could be added if deemed important enough. Fundamentally though, if you want to work with a 100% open source toolchain (I do) and still provide support for Windows you're more or less limited to MinGW or Cygwin as options, MicroSoft VS doesn't come into the equation no matter what it can potentially do. If a Windows user really does want features that VS provides (& has shelled out for its license), then they have the freedom to ignore our MinGW binaries and build from source themselves.

(OT) Visual C++ 2008 Express Edition runs well under WINE

Posted Nov 23, 2008 0:04 UTC (Sun) by qu1j0t3 (guest, #25786) [Link]

For those who need more than MinGW. I'm trying to chase down weird runtime problems on Vista / XP SP3 so have been building with both.

Windows cross-compiler

Posted Nov 19, 2008 17:04 UTC (Wed) by rwmj (subscriber, #5474) [Link] (1 responses)

One thing which might not be clear from Jonathan's introduction:

This project is a Windows cross-compiler that runs on Fedora. You don't need Windows to use it.

Windows cross-compiler

Posted Nov 19, 2008 17:09 UTC (Wed) by jake (editor, #205) [Link]

> One thing which might not be clear from Jonathan's introduction

As much as I'd like to blame Jon :), that was my intro paragraph which does, indeed, not make it very clear. Thanks for pointing it out.

jake

MinGW and why Linux users should care

Posted Nov 19, 2008 20:21 UTC (Wed) by ikm (guest, #493) [Link]

Nowadays in most cases Wine is mature enough to trade cross-compilation for the native compilation in the emulated environment. The drawbacks are slightly higher resource consumption, and of course the x86 architecture dependency. The gain is the easiness of the whole process. This is particularly nice with the Windows version of Qt, where you just install it under Wine and it just works there. And since you would probably run your freshly compiled application under Wine to test if it works or not anyway, why not compile it under Wine as well? Cross-compilation is nice for larger projects, but for the smaller ones Wine is just easier :)

Cygwin

Posted Nov 19, 2008 20:34 UTC (Wed) by fuhchee (guest, #40059) [Link] (15 responses)

For completeness, the article might have mentioned cygwin, which could have been a fine POSIX layer for running libvirt etc. on windows. It was apparently not selected because its GPL license conflicts with the stated desire to aid proprietary software vendors in using libvirt.

Cygwin

Posted Nov 19, 2008 21:03 UTC (Wed) by dlang (guest, #313) [Link] (12 responses)

cygwin doesn't let you create native windows apps, it lets you run *nix apps on windows. many people aren't willing to install an entire cygwin environment just to run one app, and in many cases things running with cygwin are less effician (and definantly less integrated) with the rest of the windows systems.

this is why most apps bother with a windows port in the first place instead of just telling people to use the *nix version under cygwin (many apps have tried this initially, but the preasure doesn't let up)

Cygwin

Posted Nov 19, 2008 21:14 UTC (Wed) by zeekec (subscriber, #2414) [Link] (2 responses)

Cygwin can create native Window executables that don't use the compatibility layer. I believe that it actually uses MinGW.

Cygwin can not do this!

Posted Nov 19, 2008 21:19 UTC (Wed) by khim (subscriber, #9252) [Link] (1 responses)

Cygwin can create native Window executables that don't use the compatibility layer.

Nope. There are no way.

I believe that it actually uses MinGW.

Yes, you can run MinGW under Cygwin as well and so it's possible to create native execulables this way. But... what's the point? You can run MinGW under Linux directly without WINE/Cygwin overhead!

Cygwin can do this!

Posted Nov 20, 2008 18:02 UTC (Thu) by zooko (guest, #2589) [Link]

Yes, it can. The cygwin gcc compiler accepts an option named "-mno-cygwin". If you pass that option, then it produces a normal Win32 executable which does not require cygwin1.dll.

Here is a HOWTO on how to use it, written in 1999:

http://www.delorie.com/howto/cygwin/mno-cygwin-howto.html

Cygwin

Posted Nov 19, 2008 21:25 UTC (Wed) by jengelh (guest, #33263) [Link] (8 responses)

>many people aren't willing to install an entire cygwin environment just to run one app,

All you need is cygwin1.dll and whatever other DLLs programs (including the Windows native ones) normally want to use.

Cygwin

Posted Nov 19, 2008 22:40 UTC (Wed) by rwmj (subscriber, #5474) [Link] (7 responses)

cygwin1.dll is GPL'd, so incompatible with LGPL libraries.

And it does a whole layer of Unix emulation, whereas this is a direct port to the Win32 API.

LGPL is compatible with Cygwin's license (GPL+exceptions)

Posted Nov 20, 2008 2:50 UTC (Thu) by dwheeler (guest, #1216) [Link] (6 responses)

First of all, the LGPL is typically compatible with the GPL, depending on their versions. See my FLOSS License Slide for more information on license compatibility.

BUT Cygwin's license is special: you can use ANY open source software license, without charge, with Cygwin. You can also use Cygwin to run closed source software, but you have to pay extra for that privilege. The Cygwin license, which is the GPL plus some exceptions, is at: http://www.cygwin.com/licensing.html.

The Cygwin license says: "Red Hat permits programs whose sources are distributed under a license that complies with the Open Source Definition [See http://www.opensource.org/docs/osd/ for the precise Open Source Definition and a list of the licenses certified by OSI as conforming to that definition] to be linked with libcygwin.a/cygwin1.dll without libcygwin.a/cygwin1.dll itself causing the resulting program to be covered by the GNU GPL. This means that you can port an Open Source application to Cygwin (TM), and distribute that executable as if it didn't include a copy of libcygwin.a/cygwin1.dll linked into it... Red Hat sells a special Cygwin (TM) License for customers who are unable to provide their application in open source code form."

LGPL is NOT compatible with Cygwin's license (GPL+exceptions)

Posted Nov 20, 2008 8:07 UTC (Thu) by rwmj (subscriber, #5474) [Link] (3 responses)

The people who are using libvirt are mostly developing a mix of in-house and proprietary
applications. They don't want to open source their code, nor do we want to discriminate against
them by making them by a special license. They don't need to buy a special license for libvirt on
Linux, nor to use proprietary APIs such as VMWare API / XenAPI.

LGPL is NOT compatible with Cygwin's license (GPL+exceptions)

Posted Nov 20, 2008 12:21 UTC (Thu) by fuhchee (guest, #40059) [Link] (2 responses)

nor do we want to discriminate against them by making them buy a special license

Since you consider licensing-based incentives to create free software as discrimination, what prevented you from (say) releasing libvirt into the public domain?

LGPL is NOT compatible with Cygwin's license (GPL+exceptions)

Posted Nov 20, 2008 12:35 UTC (Thu) by rwmj (subscriber, #5474) [Link]

LGPL protects the libvirt code while not imposing itself on other code that we didn't write.

As a free software developer yourself, you should know the difference between public domain, LGPL
and GPL.

LGPL is NOT compatible with Cygwin's license (GPL+exceptions)

Posted Nov 20, 2008 12:36 UTC (Thu) by nix (subscriber, #2304) [Link]

This is a *management layer*. It's going to get used by people who have existing virtualization systems and want to manage them. Nobody, but nobody is going to say 'hey! my management layer uses GPL, so I should switch virtualization systems to one that is GPL!'. They'll just not use libvirt.

This is a classic example of a library that is better LGPLed than GPLed.

LGPL is compatible with Cygwin's license (GPL+exceptions)

Posted Nov 21, 2008 17:39 UTC (Fri) by giraffedata (guest, #1954) [Link] (1 responses)

Red Hat permits [open source programs] to be linked with libcygwin.a/cygwin1.dll without libcygwin.a/cygwin1.dll itself causing the resulting program to be covered by the GNU GPL.

This wording shows a typical misunderstanding of copyright, wherein someone thinks a copyright license is something that restricts you in distributing software.

If the resulting program is not covered by GPL, nobody has Red Hat's permission to distribute it at all. (We assume of course that it's a derivative work so that Red Hat has copyright, because otherwise nobody needs Red Hat's permission and the whole point is moot).

I believe what the license means to say is, "... without Red Hat asserting any copyright over the resulting program due to libcygwin.a/cygwin1.dll itself."

LGPL is compatible with Cygwin's license (GPL+exceptions)

Posted Nov 23, 2008 0:16 UTC (Sun) by vonbrand (subscriber, #4458) [Link]

The Red Hat people must have done their assignment before distributing the library under this license... and they are careful with legal stuff.

In any case, it is not the license which restricts distribution, it is copyright law. All the license does is allow you to do stuff the law forbids.

Cygwin

Posted Nov 19, 2008 21:46 UTC (Wed) by zooko (guest, #2589) [Link]

Also a little-understood fact is that the cygwin toolset can be used to build Win32 executables which do *not* require the cygwin1.dll (and therefore are free of GPL requirements, as well as of any performance problems of going through an emulation layer). This is generally accomplished by adding the magic flag "-mno-cygwin" to gcc.

Personally, I've never yet had a need to learn how to install and use the mingw toolset, since the cygwin toolset that I happened to learn first already does everything I need, including producing GPL-free, Win32 executables.

Cygwin

Posted Nov 19, 2008 23:00 UTC (Wed) by danpb (subscriber, #4831) [Link]

Independently of question of Cygwin vs MinGW, the libvirt project chose to use the LGPLv2+ as its license. While there are interesting debates to be had on whether to use GPL vs LGPL for libraries & the FSF has a good article detailing some of the tradeoffs, the libvirt project has decided that the LGPLv2+ best suits our goals.

Having made that decision, we want the same licensing terms to be applicable across all platforms, whether Linux or Windows - we don't wish to penalize Windows users over Linux users. As such the Windows binaries we provide must be LGPLv2+ licensed in line with Linux binaries we ship, and we also wanted to build the binaries from a Linux host machine. While we could have used WINE + Cygwin, we decided that MinGW suited our needs. We've nothing against Cygwin - both MinGW & Cygwin are great open source projects and we're happy to see them both thrive & co-exist. In the same way that we choose to use GTK rather than QT for some apps, does not mean we have anything against QT, it is just a choice to be made. The important thing is that the choice is for a completely open source toolchain & build host OS (Mingw or Cygwin on Linux), over closed source development platform (VisualStudio on Windows).

why Linux users should care

Posted Nov 19, 2008 20:35 UTC (Wed) by fuhchee (guest, #40059) [Link] (7 responses)

Re. the article's title, can someone summarize briefly why linux users should care?

why Linux users should care

Posted Nov 19, 2008 22:40 UTC (Wed) by rwmj (subscriber, #5474) [Link] (6 responses)

You could read the article and it would explain that to you.

why Linux users should care

Posted Nov 19, 2008 22:57 UTC (Wed) by fuhchee (guest, #40059) [Link] (5 responses)

I did read it. The closest thing seems to be this tidbit:

Why should free software developers care about MinGW? Does it do anything for them?

Richard: There's been some opposition, along the lines of "why are we helping Windows?". [...]

But that's a redirection that is not responsive to the question. That really just argues that we need not care about whether this helps windows or not.

Dan: The libvirt project started off with a strong Linux focus due to our immediate needs for a management API for Xen in Fedora and later RHEL-5. Over time the community has contributed patches to improve our portability to non-Linux platforms, [...]

I read this as claiming that the code's portability is improved when, er, it is ported. OK, but again what does that do for linux users?

Or maybe I just missed a material argument somewhere else in the interview. Please help me by pointing it out.

why Linux users should care

Posted Nov 19, 2008 23:10 UTC (Wed) by rwmj (subscriber, #5474) [Link] (2 responses)

Maybe you could read more of the article. For example:

Bringing open APIs, apps and file formats to Windows users is important: It's important to Windows users because it breaks their lock-in and makes switching to a fully free platform easier down the road. It's important for [Linux developers], because your potential audience of users will increase by a factor of 10x or 20x.

Anything which increases the user and developer base, and brings in future Linux users, is good for Linux users and developers now. If you're a Linux developer forced to write software for Windows it's good too because you don't need to leave the Linux environment to use this cross- compiler.

why Linux users should care

Posted Nov 20, 2008 0:03 UTC (Thu) by proski (subscriber, #104) [Link]

I can imagine it would work for specialized (e.g. scientific) applications, where potential users are experts in the problem area and can express their ideas in writing in a concise way.

As for general purpose applications (e.g. DVD burners, file managers etc), Windows users would probably only drain time of the developers without contributing back ideas and fixes. That could slow down or even halt the development, thus inconveniencing the existing users.

why Linux users should care

Posted Nov 20, 2008 14:09 UTC (Thu) by chsnyder (guest, #52714) [Link]

Yes. Portable software (works the same across all platforms) breaks down barriers to entry for potential Linux users. Firfox, VLC, Thunderbird -- these look and feel the same across all platforms, and it's a HUGE deal.

It means that when a Windows user tries Linux, she can appreciate the performance and usability improvements without having to re-learn how to use her applications. It means that when you leave your Windows computer at work, and fire up your Linux laptop at home, you can use the same apps, the same documents, and even the same preferences.

To put it another way, anything that makes it easier to write portable code makes it more likely to be developed first in Linux, and then ported to other OSes. That is extremely good news for Linux users.

why Linux users should care

Posted Nov 19, 2008 23:22 UTC (Wed) by danpb (subscriber, #4831) [Link] (1 responses)

First, the title of the article would probably be better phrased as 'why open source users should care' rather than 'why Linux users should care'. I happen to use Linux for everything I do, but furthering open source software is my primary motivation.

The primary scenario faced is people evaluating whether to deploy a Xen/KVM Linux virtualization host vs a VMWare / Microsoft Hyper-V virtualization host. A common requirement is to be able to manage the virtualization host from a non-Linux client machine, Windows being very common, OS-X to a lesser extent. If a libvirt client were not available for Windows, then VMWare or Hyper-V would be chosen pretty much by default, instead of Linux. So providing Windows client binaries helps Linux adoption, which long terms helps all Linux & open source users. As a developer though I do not wish to use Windows myself, so using a cross-compiler like MinGW allows provision of Windows client binaries to help adoption of Linux virtualization, without requiring actual use of Windows on the part of the developer.

As a second scenario, there are developers who use Windows, but who value open source & wish to contribute to the project. By enabling use of libvirt (& other related apps & libraries) on Windows, it enables a larger pool of developers to become contributors to the project, beyond just Linux based developers. These developers will contribute new features, some of which help all users regardless of their host OS.

Addressing the last point raised, portability helps Linux users by identifying code which relies on undefined behaviour which "just happens" to currently work on Linux. As an example, printf() and the %s format specifier will happily accept NULL with GLibC, printing out '(null)'. This isn't true of other OS' implementation of printf(), so porting to Windows can identify this problem & result in a fix to the main codebase. It then turns out that even on Linux, passing a NULL to printf can cause crashes with certain optimizations the compiler may make - eg converting printf("%s", foo) to puts(foo). So, a porting to Windows identified & helped fix a problem which was lieing dormant during most use on Linux, but could ultimately still affect Linux. This is a little contrived, but the general point is to identify code which relies on undefined behaviour and only works on Linux by luck rather than design.

why Linux users should care

Posted Nov 20, 2008 0:19 UTC (Thu) by fuhchee (guest, #40059) [Link]

This is a little contrived, but the general point is to identify code which relies on undefined behaviour and only works on Linux by luck rather than design.

Cross-compiling per se will do very little to help with that. You'd actually have to test running the code on your targets, at which point you might as well run a native toolchain so as to get even more diversity.

MinGW and why Linux users should care

Posted Nov 19, 2008 20:40 UTC (Wed) by nix (subscriber, #2304) [Link] (4 responses)

Nice article!

(OS-9? You poor sod. Even HP-UX 6 was better than that, IIRC, although
that's not saying much.)

autoconf makes cross-compilation trivial? Sure, but, as you said, this is
only true *if* you don't use AC_TRY_RUN and friends, or otherwise need
accurate runtime tests, and a *lot* of programs fall into one category or
the other. If you do, you're screwed (or you have to do them *really* at
runtime rather than at configure time, which is not always practical).

It's certainly easier to cross-compile an autoconfiscated project than a
non-autoconfiscated project, but not necessarily all that much easier. As
ever, it really depends on whether the project has been written with an
eye to portability...

(Do people really have binary *-config scripts? Who? I mean, even
guile-config is a script. A Guile script, but still.)

I second the mention of gnulib: it's wonderful and maintained by a
cross-section of fine portability wizards, largely as an offshoot of
maintaining other GNU software... but it has no official releases or
(naturally) stable API, the churn rate is quite high, and if you're not
using autoconf, you might as well give up hope of using it without
significant pain. (Also, quite a lot of it is GPLv3ed, but the gnulib
maintainers are often amenable to requests to loosen the license to v2+ or
LGPL.)

MinGW and why Linux users should care

Posted Nov 19, 2008 23:15 UTC (Wed) by rwmj (subscriber, #5474) [Link] (3 responses)

AC_TRY_RUN is definitely one of the autoconf constructs I'd like to discourage people from using.
To be fair though, only 2 out of 50+ of the libraries we ported actually used it.

Did I mention I'm no fan of autoconf ..?

MinGW and why Linux users should care

Posted Nov 20, 2008 0:38 UTC (Thu) by nix (subscriber, #2304) [Link] (2 responses)

But at least it's not quite as CAPITAL LETTER HAPPY as cmake, although
it's still CAPITAL LETTER HAPPY. Reading the cmake documentation or cmake
examples is almost physically painful. You'd think they hadn't realised
that lowercase letters are easier to read.

MinGW and why Linux users should care

Posted Nov 20, 2008 12:21 UTC (Thu) by aleXXX (subscriber, #2742) [Link] (1 responses)

Did you check lately ?
http://www.cmake.org/cmake/help/cmake2.6docs.html#section...

Since CMake 2.4.1 I think lower case commands are supported, and since
2.6.0 using all-lowercase is recommended.

Beside that, I can recommend the same: don't try to run executables
during the configure-step, in general this doesn't work for cross
compiling. If cmake recognizes that a cross-compiled executable should be
executed, it doesn't execute it, prints a warning, and writes a file for
setting the result-variables, with hopefully enough comments so this
becomes doable for the developer. Also the cross compiled executables are
kept so the developer can take them, execute them on the target platform
and enter the results manually in that file. That file can then be fed
into cmake using the -C argument.

Alex

MinGW and why Linux users should care

Posted Nov 20, 2008 12:39 UTC (Thu) by nix (subscriber, #2304) [Link]

cmake supports lowercase! Yay! Now I can learn it without getting a hideous headache ;)

select

Posted Nov 20, 2008 7:31 UTC (Thu) by ncm (guest, #165) [Link] (8 responses)

Am I correct in thinking MinGW doesn't have select()? Or does it, like Win32, have one, but it only works with sockets?

select

Posted Nov 20, 2008 7:54 UTC (Thu) by nix (subscriber, #2304) [Link]

The latter, but thanks to WaitForMultipleObjects() et al one can fake
select(), and recent gnulib does so.

select

Posted Nov 20, 2008 8:04 UTC (Thu) by rwmj (subscriber, #5474) [Link] (5 responses)

"MinGW" neither has nor doesn't have select().

The Fedora MinGW project is a cross-compiler that creates Windows executables. If you want
select-like ability, you could use some Win32 API for that such as - as nix says -
WaitForMultipleObjects.

But you could also (and we'd recommend) use some portability library like glib or NSPR which deals
with the matter in another way and has already been ported to whatever Win32 APIs exist (on
Windows) or whatever Linux/POSIX APIs exist on Linux/Unix.

select

Posted Nov 20, 2008 12:23 UTC (Thu) by aleXXX (subscriber, #2742) [Link] (4 responses)

...or QtCore if the license (GPL or commercial) is ok for you.

Doesn't Boost also have some file/threading classes in the meantime ?
Also signals..

Alex

select

Posted Nov 20, 2008 13:46 UTC (Thu) by rwmj (subscriber, #5474) [Link] (3 responses)

I packaged boost. Boost is a classic example of an upstream package where they've gone off and written their own build system, so they have to maintain all the complexity of building on every system out there, and I had to add to that complexity for cross-compiling. I also did another C++ network environment called POCO, and they also wrote their own build system, completely different from the boost one obviously.

C++ programmers, eh - haven't they suffered enough already?

While we're on the subject of portability libraries, APR (Apache Portable Runtime) is another contender.

Rich.

select

Posted Nov 20, 2008 22:50 UTC (Thu) by nix (subscriber, #2304) [Link] (2 responses)

Cross-compiling and Boost.Jam? You have a stronger soul than I. Just
changing CFLAGS and the preferred installation prefix was hell, and then I
had to figure out why jam coredumped as soon as it started... Autoconf
may be nasty but it's a lot kinder to packagers/builders than bloody jam.
While KDE was searching for a new build system for KDE4 I was in terror
that they'd choose Boost.Jam because it was used for a successful C++
project. Thankfully they are not utterly insane and chose something nicer
(now with added lowercase! ;)))) )

select

Posted Nov 21, 2008 8:50 UTC (Fri) by aleXXX (subscriber, #2742) [Link] (1 responses)

Initial support for building Boost using CMake has been committed to the
Boost repository a few weeks ago.

Alex

select

Posted Nov 22, 2008 12:34 UTC (Sat) by nix (subscriber, #2304) [Link]

That's the best news I've had all week :)

select

Posted Nov 20, 2008 9:52 UTC (Thu) by danpb (subscriber, #4831) [Link]

MinGW at its core is just a cross compiler / toolchain, so it doesn't attempt to make Windows look like POSIX. It provides header files & linker stubs for the Win32 APIs. So you are developing against Win32 APIs, rather than POSIX.

If you want a Windows based runtime environment that strives to completely simulate POSIX APIs, then Cygwin is likely a more suitable choice. If you are happy to work against the Win32 APIs more directly, then GNULib provides wrappers around a number of Win32 APIs to give you a degree of POSIX compatability often good enough for many apps. Finally there are higher level APIs like GLib, QT, NSPR which attempt to provide a platform agnostic APIs.

MinGW rocks!

Posted Nov 20, 2008 12:25 UTC (Thu) by hanwen (subscriber, #4329) [Link] (2 responses)

MinGW rocks! Our user base (see http://lilypond.org) is 60 % windows, and thanks to MinGW and NSIS (http://nsis.sf.net), I can ship weekly release in a neat .exe installer without ever having to touch windows.

MinGW rocks!

Posted Nov 21, 2008 23:44 UTC (Fri) by rwmj (subscriber, #5474) [Link]

Of course we're huge fans of lilypond. Does it build with the Fedora MinGW project? If you'd like help, let me know.

I build all my Free/GPL Photoshop plugins with MinGW!!

Posted Nov 23, 2008 0:06 UTC (Sun) by qu1j0t3 (guest, #25786) [Link]

Indeed it rocks, not having to boot sucky XP! (plugins here)

MinGW and why Linux users should care

Posted Nov 21, 2008 0:24 UTC (Fri) by brouhaha (subscriber, #1698) [Link] (2 responses)

I've been using MingW on Fedora for several years to build Windows versions of several of my programs. It's great when it works, but I've found it difficult to build working versions of the compiler, tools, libraries, etc. for various Fedora releases. Some combinations work well, and some fail to build for non-obvious reasons. Lately I've been doing the cross-development in a virtual machine running Fedora 7, because I wasn't able to get MingW to work properly on Fedora 8 or 9.

The IMCROSS project is an attempt to solve these problems in a distribution-neutral way, and helped a lot, but I'm more excited about seeing MingW become a part of Fedora, with proper RPM packages. Now that the Fedora MingW SIG is making these packages available for Fedora 10, I am even more eager to upgrade to Fedora 10, though I might spend a bit of time finding out whether those SRPMs build and work on Fedora 9. Thanks, guys!

MinGW and why Linux users should care

Posted Nov 21, 2008 19:00 UTC (Fri) by danpb (subscriber, #4831) [Link] (1 responses)

90% of our development has been done on Fedora 9 in fact, the source RPMs we have published should work just fine on F9. We're targetting F10/11 for our initial push but its quite possible we'll build them for F9 too once we get stuff through the package review process. If you want to keep up on details, join the fedora mingw mailing list....

MinGW and why Linux users should care

Posted Nov 21, 2008 23:43 UTC (Fri) by rwmj (subscriber, #5474) [Link]

I'm actually gonna go one better than Dan and say that I built quite a lot of the mingw32-* packages on Fedora 8. The ones we are building now are all done against Fedora 10 and some of them no longer just install on Fedora 8, in particular I know the C++ ones don't because some fundamental C++ library has changed its soname.

The "official" line is we are supporting RHEL 5 (through EPEL) and Fedora ≥ 10. Anything else that works is luck, or you will have to join the project and help support it yourself.

Rich.

MinGW and why Linux users should care

Posted Nov 22, 2008 3:57 UTC (Sat) by k8to (guest, #15413) [Link] (5 responses)

Hmm, this seems to be "MinGW and why Linux developers and free software advocates should care". Maybe I'm splitting hairs, but I see nothing here to care about as a Linux user. Ho hum, some stuff can run on windows, which I don't use.

Sure the theory is that making these tools available to windows users will enable them to transition away from proprietary tools, but I don't buy it. I switched from windows to Linux in 1996 with no pain at all. If what Linux offers was compelling to most people, they would have already transitioned. I don't see any benefit to those who care about free software, because they're already off windows. I don't see any benefit to linux users in making linux desktop apps run on windows. The basic tools already work after a fashion in cygwin, and have for a long time.

I'm certainly not upset with these developers for working on this project, but I don't really see a benefit to me, the Linux user.

MinGW and why Linux users should care

Posted Nov 22, 2008 8:25 UTC (Sat) by bockman (guest, #3650) [Link] (4 responses)

How about this:

1. Porting applications to Windows makes for a larger user base

2. A larger user base makes open source developers happier (as long as windows users
don't whine too much ... but then at least windows users don't flame much )

3. An happier open-source developer makes better open-source software

4. Better open-source software makes linux user happier

MinGW and why Linux users should care

Posted Nov 23, 2008 19:23 UTC (Sun) by k8to (guest, #15413) [Link] (3 responses)

Yes, porting apps to windows means a larger user base, but it often means a worse program. Windows imposes all kinds of stupid expectations that developers bow to. Witness backspace going to the previous page on all versions of Firefox. I have an example at my place of work about how we ended up having to implement our own timezone code because the windows timezone stuff is broken in various ways. Now our code has timezone bugs from time to time that affect all our platforms.

My expectation as a Linux user is that programs that are available on Windows as well will cater primarily to Windows users (the larger potential market), and will become less usable.

MinGW and why Linux users should care

Posted Nov 24, 2008 9:52 UTC (Mon) by rwmj (subscriber, #5474) [Link]

But that's your choice if you are the developer of a program. You could look at it another way and say by keeping up your standards you are bringing better UI concepts / timezone handling / whatever to Windows users.

Anyway there is nothing in the Fedora MinGW work which prevents you from #ifdef'ing pieces of code, or even removing troublesome features from the Windows port entirely.

MinGW and why Linux users should care

Posted Nov 24, 2008 11:33 UTC (Mon) by Cato (guest, #7643) [Link] (1 responses)

Your first example (backspace going to previous pages in Firefox on all platforms) has nothing to do with Windows - you could design Firefox not to do this, and I'm sure a user can change this behaviour, or at least an extension.

The sheer volume of users on Windows can be beneficial for OSS software, by stimulating bug fixes and features, as well as providing people to support the software.

As a co-developer of TWiki (before the recent fork by most of the developers, i.e. http://foswiki.org/ ), I supported it on Windows for a few years, and used it myself on Windows for a time when I didn't have a Linux server available. This helped Linux users, e.g. I18N hacks that I did to work around Windows Perl's (very broken) locale support also worked for Linux platforms with broken locales, Perl 5.005 hosting users where I18N regexes were more basic, etc.

Where Windows is somewhat broken but you still have ported the app, you can also deliver a Linux virtual machine using VMware, which is what the TWiki team did as well - this ends up being a good advert for Linux as well.

Doing cross-platform code always risks introduction of bugs, so wherever possible it's best to use a third party portability library, or a portable language such as Perl, Python, etc.

MinGW and why Linux users should care

Posted Dec 1, 2008 5:35 UTC (Mon) by k8to (guest, #15413) [Link]

But firefox using backspace for previous page is exactly the problem with targetting windows users. You first think: okay, we just want to make the program available to windows users, so you do a straight port. Then you get pushback from your new userbase and you think: okay, we should really make this application more reasonable for windows users by meeting their expectations. Then you think: well most of my users are windows users, and doing things different ways for different platforms is redundant code; I can improve quality by doing things the same way on all platforms. Then you have stupid windows behavior on all platforms.


Copyright © 2008, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds