Adminstrative Note

Although this page remains valid, the MinGW team have decided to no longer promote mingwPORT distributions. Therefore the information below is for your own use only. The latest way to share build information for packages is with mgwport .

Using mingwPORTs

The mingwPORTs provide an automated and repeatable method of creating and building libraries and applications from source. By using a build script such as the mingwPORT files, developers can easily share the steps it takes to create an executable or library on their particular operating system with a specific compiler. The mingwPORT script files are designed for the standard GNU style build tools and a standard shell such as the bash shell. They automate the usual ./configure, make, make install process. The mingwPORT scripts can be customized for non-standard builds such as those that require patches in order to work.

You can check the MINGW archives at Sourceforge to determine if a mingwPORT is available for a particular library or executable you want to build and install. These scripts are typically provided in a tarball (.tar.gz or .tar.bz2) file and have mingwPORT somewhere in their file name. Since these are shell scripts, you'll need MSYS on your system in order to run them. To use a mingwPORT, download and decompress the file. Within MSYS, change directory (cd) to the mingwPORT directory that was created when you decompressed the tarball. Type ./mingwPORT.sh. The shell script will ask a series of questions that helps it determine where files are and where the build and install should take place. Once the questions are answered, the scripts will automatically perform the steps a developer usually takes to create an executable or library.

Build scripts are used by a variety of Open Source projects to help automate the process of building and sharing executables and libraries. Although mingwPORT shell scripts could be designed for use on other systems with gnu style compilers such as Cygwin or Linux, many Linux distributions typically have their own format for providing build scripts. Many build script formats (including mingwPORTs) offer functionality to automatically download the source code to be built. The source code tarballs may be kept at the same web site that the build scripts are available from. However, for various reasons such as space, keeping up with latest versions, etc., build scripts typically point to the original web site where source code for a project is available and maintained. In order to download the original source, most build scripts use the Open Source program wget. This is how the mingwPORT scripts download a tarball to be built. In order for this to work, you must have a working copy of wget on your system. Also, the URL for the source code must be up-to-date. Locations of files on the web can change often and occasionally older source code may no longer be accessible on the web any more. You'll want to make sure the URL you're downloading from is still accurate especially if the build script fails to run to completion. The mingwPORT scripts give you the opportunity to change where you're downloading the source from if you know the location has changed.

How to Sneaker Net

If you don't have Internet access on the system where your MINGW and MSYS tool chains are installed, you can use sneaker net with a mingwPORT. Just download the mingwPORT tarball and the source code it refers to. The mingwPORT.ini file usually gives the web site where you can find and download the source code from. Move these files to the system you want to build on. Decompress the mingwPORT tarball. Run the mingwPORT.sh script as usual. When asked if you want to "Download file", answer no (type N). You'll be asked for the location of the archive file. You can then tell the shell script the directory where you downloaded, copied or are storing the source code tarball.

You'll Want wget

Since wget is needed by the mingwPORT scripts to automatically download from the Internet, you'll need to download a binary copy of wget that's compatible with Windows to use this feature. There is a mingwPORT tarball to build wget at the MINGW site at Sourceforge. If you use it, I'd recommend you use the sneaker net method of downloading the source yourself and telling the script where this source file is located.

Make Sure MSYS is up-to-date

It's recommended that you use the latest version of MSYS when working with mingwPORTs. Please note that versions of MSYS 1.0.10 and prior expect any files installed in the /usr/bin and /bin directories to use POSIX style command line conventions. For files in other directories, MSYS converts file names with slashes (POSIX style file names) to the Windows style file name convention using backslashes. However, this is not done for files in /usr/bin and /bin directories with earlier versions of MSYS. That means all executable files you install that aren't built specifically for MSYS will not work properly if placed in those directories. This includes programs like wget. It's much easier to update your system to the latest version of MSYS and not have to worry about where your executables get installed in order for them to work properly. You need a release version of MSYS after 1.0.10 if you want to avoid this issue.

Creating mingwPORTs

Some of the developers of MINGW have designed an automated method, called portmaker, for creating mingwPORT scripts based on templates. Portmaker should help make it possible for anyone to create mingwPORTs if they are not currently available for a needed library or application. If you do create a mingwPORT, please share it with other developers. The more we share build scripts with each other, the more likely you'll be able to find a script for a particular library or application you want to build when you need it. Sharing build scripts can really save developers time and effort when building Open Source applications and libraries.

How to Get portmaker

You can download the latest version of portmaker from cvs at Sourceforge using a program like WinCVS from sites like Portable Apps, or by using the CVS client provided in the MSYS Supplementary Tools package set; anonymous checkout of the appropriate files is achieved by executing the commands

export CVSROOT
cvs login

At this point, you will be prompted to enter a password. There is none; simply press <ENTER> to continue, then

cvs -z3 co portmaker

You can also view the files directory or download from http://mingw.cvs.sourceforge.net/mingw/portmaker/.

Once you've downloaded the portmaker files, within MSYS, run the usual ./configure, make, make install on them. To work with portmaker once it is installed, again within MSYS, type portmaker. It will ask a series of questions about the executable or library you want to build. This helps create the mingwPORT.ini file which has default answers to the questions a user is later asked when using the mingwPORT scripts. The portmaker script will copy over template files and create a mingwPORT.ini file with the defaults you've given it. These files will be placed in a mingwPORT subdirectory. If you have any patches required, place the diff output for all the files that need changing in a file called mingwPORT.patch also in that subdirectory. The files in the mingwPORT subdirectory should peform just like any mingwPORT you download from the MINGW web site would. To share them, you can tar and compress them so that they can be distributed in tarball format.

Some Variable Value Tips

When working with mingwPORTs, the archive (such as the ARCHIVEFILE, ARCHIVEPATH) typically refers to the executable or library source file you're trying to build. Your mingwPORT files are usually placed in a mingwPORT subdirectory underneath the SRCDIR directory. The PREFIX can be used to indicate where to install files to. If you install files to /usr/bin, /usr/doc, and so on, your PREFIX would be /usr. Since the MINGW compiler has some expectations about paths and where libraries and include files are installed, you'll want to make sure you use a PREFIX that will facilitate installation to a location where these files can be easily found.

Sharing mingwPORTs

I'd like to encourage all developers working with mingwPORTs or other forms of build scripts to share these files. The more we share, the more likely we'll be able to find a build script for a particular library or executable when we need one. It's also more likely you'll be able to find help creating your own build scripts for programs or libraries if others are familiar with this process.

There's a forum at the MinGW site on Sourceforge for discussing issues with mingwPORTs at
http://sourceforge.net/forum/forum.php?forum_id=440309; however, the lead developers now consider this to be deprecated -- please use the MinGW Users mailing list as the preferred forum, for discussion of issues with mingwPORTs.

You'll find a mingwPORT submission page at http://sourceforge.net/tracker/?group_id=2435&atid=752210.

If anyone runs across other information on this topic or other forums for discussion of build scripts for the MINGW compiler suite, please post about it or share the links to the information below. Also, if anyone has created and is sharing build scripts for Open Source projects that will work with MINGW, please post the links to them as well.

Re: mingwPORT

keith's picture

Thanks for writing this up, Laura. Just a few minor points to note:

  1. There is a pre-built wget.exe included within the current wget-1.9.1-mingwPORT tarball; we recommend copying it to /mingw/bin -- certainly not to /bin or /usr/bin, if using an MSYS version prior to MSYS-1.0.11.
  2. We now consider the mingwPORT discussion forum on SourceForge to be deprecated. If you insist on using it, please don't be surprised if you don't get a timely response; rather use the mailing list instead. I've updated your text to reflect this.
  3. I plan to make the mingwPORT question and answer dialogue considerably less terse -- more akin to the style currently used in the cross-compiler build scripts.

Re: mingwPORT

Keith, if you have the cvs command to retrieve the portmaker source code, that would probably also be a good think to add to the wiki entry. There are some command lines examples for this at the old wiki site, but I wasn't sure if they were still up-to-date and working.

Re: mingwPORT

keith's picture

Sure. It's done. It was already documented on the Official CVS Repository page, but I guess there's no harm in repeating it here.

This wiki is not a forum for discussion of usage issues. Please use the mingw-users@lists.osdn.me list instead. We do not allow creation of comments by anonymous or untrusted users, on any page.
Site Status

Site maintenance performed successfully, site online Dec 13th 12:00 AM Eastern.