GenomeTools Windows Port
I'm currently porting GenomeTools to Windows (MinGW). Some notes can be found here: https://github.com/genometools/genometools/wiki/GenomeTools-Windows-Port I'm pushing in this branch: https://github.com/gordon/genometools/tree/windows It's not ready for a pull request, though. Comments welcome.
Nice! I will have a look at it tomorrow.
Cool. But don't bother with mmap(), I already know how to do it and will code it tomorrow as well.
mmap() is ported now and it is possible to compile libgenometools with
scripts/build_windows.sh lib/libgenometools.a
and compiling the gt binary with
scripts/build_windows.sh bin/gt
also works. The libarary contains all subdirectories, but there are multiple places where I just outcommented the UNIX specific code. For example, process forking for Windows is missing completely.
I think we should pull this into the master soon so that others can contribute to the port. Any opinions on this?
Thanks for the initial work!
I am just using fileutils, and I am extending it by a function that concatenates dir, basename and suffix. I was thinking about different dir separators in *NIX Windows. Do we have to worry about that?
Yes, please use the defines from core/compat.h.
thanks, found it, and aborted the plan for concatenation. Variable number of parameters is too problematic, and using GtStr anyone can concatenate strings easily.
@stefan-kurtz asked on #863 about the missing parts for the Windows port of GenomeTools, let's continue the discussion here. A few more notes for whomever wants to continue working on a native port for Windows (that is, one which can be compiled with MinGW directly and doesn't depend on a POSIX compatibility layer provided by Cygwin):
- Travis does only checks that the code compiles for Windows (by cross-compiling it with mingw-gcc), it doesn't check that it actually works.
- In the past I pushed it to the point that everything GenomeThreader depends on works, that's why there is a native binary of GenomeThreader for Windows.
- The Travis test makes sure that the GenomeTools code still compiles on Windows.
Things that have to be considered when porting to Windows
- Windows has different path separators. Use the defines in https://github.com/genometools/genometools/blob/master/src/core/compat.h for that.
- Windows hat different line endings (
\r\ninstead of\n). Code that doesn't take that into account will fail. - The native C compiler on Windows (Visual Studio) only supports C89 and not C99. Since we are only targetting MinGW at this point it doesn't matter, but it is good to keep that in mind to not make the problem worse. For example, in C89 there is no
stdbool.hheader. - POSIX functions are not available on Windows, they have to be wrapped into a compatibility layer and their functionality implemented with the Windows API. That's usually possible, but a bit cumbersome.
How to do a full port to Windows
- Grep for all occurences of
_WIN32in the source which is not in compat.[ch]. Create a wrapper function for the corresponding POSIX function and look for an equivalent Windows API function. Implement the wrapper for Windows as well (withifdef _WIN32in compat.c).
How to test the code
-
On Linux compile with mingw32-gcc (as done in https://github.com/genometools/genometools/blob/master/.travis.yml). You can probably test most of the code by using Wine. That is, compile the 32-bit version with MinGW and then call the binary with
wine gt. -
Compile natively on Windows with MinGW.
Even if the code is developed and tested on Linux (with Wine) it has to be tested on Windows natively!
For that one has to figure out how to get the test suite running on Windows, maybe one can install Ruby with pacman as well.
How to setup your MinGW environment on Windows
- Download the MSYS2 installer from http://www.msys2.org/ (usually you want the
x86_64installer no matter what you want to compile, unless you are still running a 32bit version of Windows). - Run the installer and install MSYS2 into
C:\msys64(orC:\msys32for the 32bit version) and launch the MSYS2 shell (C:\msys64\msys2). - In the MSYS2 shell enter:
pacman -Sy pacman(to update the package DB and pacman) - Close the MSYS2 shell and launch it again (
C:\msys64\msys2). In the MSYS2 shell enter:pacman -Syu(to update the package DB and install the core system packages). - Close the MSYS2 shell and launch it again (
C:\msys64\msys2). Update the rest withpacman -Su - Close the MSYS2 shell and launch it again (
C:\msys64\msys2). Install MinGW 64bit:pacman -S mingw-w64-x86_64-gcc(to compile for 64bit). Install MinGW 32bit:pacman -S mingw-w64-i686-gcc(to compile for 32bit). - Install make:
pacman -S make. - Optionally install any libraries/tools you may need.
You can search the repository by
pacman -Ss name_of_packageand install a package bypacman -S name_of_package. - To compile the GenomeTools for Windows (MinGW) 64bit lauch
C:\msys64\mingw64and for 32bit launchC:\msys64\mingw32
If you start working on that, please start sending small pull requests immediately and do not wait until the whole thing is finished. That way we can give early feedback. PRs are fine as long as they still compile and do not break anything for Linux and Mac.