Bug #1449

Compiling under MinGW/MSYS

Added by Terkhen about 10 years ago. Updated about 10 years ago.

Status:ReopenedStart date:2010-09-07
Priority:NormalDue date:
Assignee:-% Done:


Target version:-


Currently FIRS will not compile under MinGW/MSYS. I have identified the following issues:

  • Windows versions of Mercurial use windows path style by default. This will result in an empty list of source files. This can be solved either by adding slash=true to [ui] options at .hgrc/mercurial.ini, using "hg --config "ui.slash=1"..." or by modifying the following line at scripts/Makefile.def (this modificacion does not seem to affect compilation under Linux):

-REPO_FILES_CMD := $(HG) st -A | grep -v "^I" | grep -v "^?" | grep -v "^R" | grep -v "^\!" | cut -d\ -f2
+REPO_FILES_CMD := $(HG) st -A | grep -v "^I" | grep -v "^?" | grep -v "^R" | grep -v "^\!" | cut -d\ -f2 | sed -e "s/\\\/\\//g"

  • $(CC) and $(NFORENUM) are not set correctly. CC will use "cc" as value instead of gcc, and NFORenum will use nforenum instead of renum. I solved this by using export to set the correct values before compiling FIRS, but of course it is not a good solution.
  • MSYS current version of unix2dos (0.1.3) does not have a -q option. Removing -q from UNIX2DOS_FLAGS allows make bundle to complete.
  • make install will fail when used under windows 7 (probably under vista too) because the correct INSTALL_DIR in these versions is C:\Users\USER_NAME\Documents\OpenTTD\data.

hg_backslash.diff Magnifier - Fixes the backslash issue with mercurial. (1001 Bytes) Terkhen, 2010-09-08 14:56

windows_install_folder.diff Magnifier - Use the correct install folder in vista/7. (636 Bytes) Terkhen, 2010-09-08 16:14

unix2dos_fix.diff Magnifier - Don't use -q option with unix2dos if the option is not present. (1.15 KB) Terkhen, 2010-09-08 21:34

check_default_cc.diff Magnifier - Checks if the default value for $(CC) is usable. (532 Bytes) Terkhen, 2010-09-08 23:25

windows_install_folder_UPDATE.diff Magnifier - Use the correct install folder in all versions of windows. (648 Bytes) Terkhen, 2010-09-11 13:35

swisstowns.nfo - mingw (44.3 KB) Ammler, 2010-09-18 12:36

swisstowns.nfo - linux (44.3 KB) Ammler, 2010-09-18 12:36

use_dos2unix.diff Magnifier (1.88 KB) fanioz, 2010-09-24 18:40

Associated revisions

Revision 176:3e14a6951cec
Added by planetmaker about 10 years ago

Change #1449: Use a working dir separator also under cygwin and msys (Terkhen)

Revision 177:9a2b6b18a3b8
Added by planetmaker about 10 years ago

Change #1449: Some unix2dos don't know how to be quiet. Let them babble but not complain (Terkhen)

Revision 193:8605b33400eb
Added by planetmaker about 10 years ago

Fix #1449: Define gcc for buggy MinGW


#1 Updated by planetmaker about 10 years ago

<Terkhen> strange thing is, CC seems to be empty before calling make, but make test returns "cc"
<Terkhen> so... something is modifying cc after calling make but before checking CC

MinGW seems to define an empty CC variable or it gets emptied on the way. Possibly check explicitly for it being empty and then override it with the default, if empty.

#2 Updated by Ammler about 10 years ago

I have installed
- tortoisehg
- python
- perl from strawberry
- luna mingw
- and the libs from tt-forum
- boost (simple copy from boost to /include)

nforenum and grfcodec built (grfdiff didn't build)

then I was able to build firs r1355
(make CC=gcc

nml project:

+ nmlc swisstowns.nml
Traceback (most recent call last):
  File "C:/mingw/local/bin/nmlc", line 4, in <module>
    from nml import main
ImportError: No module named nml

#3 Updated by Terkhen about 10 years ago

I'm attaching a diff to fix the first issue, using the second option. I agree that it is better than forcing the user to edit the hgrc, and looks cleaner than using sed.

$(NFORENUM) is set correctly: the name of the win32 binary of nforenum was wrong.

Talking about $(CC) in IRC it was concluded that $(CC) should be set by msys to a working value, but it isn't. If not set, make uses the default implicit value, which is 'cc' (see http://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html). I think that, if set, $CC should be tested to check if it really exists (probably using which, as done with UNIX2DOS).

#4 Updated by Terkhen about 10 years ago

The attached diff file checks the version of Windows to decide which INSTALL_DIR to use. If version is different than 5 (Windows 2000 and XP), it will assume Vista/7 folders. It has only been tested under Windows 7.

#5 Updated by Terkhen about 10 years ago

Yet another diff file, this time to fix the -q problem with unix2dos. It "should" work, but it needs testing with a system that actually has unix2dos with a -q option to make sure.

#6 Updated by Terkhen about 10 years ago

This diff fixes the problem with $(CC). If $(CC) has been set by make to the default implicit value ('cc'), it will check if 'cc' exists using which. Otherwise CC will be set to gcc, which is a better value to use by default. This check can't use $(CC) directly since make won't allow a variable to reference itself when being defined.

#7 Updated by Terkhen about 10 years ago

Update of windows_install_folder.diff. It uses the shared folders instead of the personal folders of the user (which IIRC was preferred). It has been tested under both Windows XP and Windows 7.

#8 Updated by Ammler about 10 years ago

using shared location would be similar to use /usr/local in unix, which isn't the case, the "default" location is meant to be for developing testing, so the preferred should be $HOME...

for consistency we should either change unix to /usr/local too, or keep windows also at home.

#9 Updated by planetmaker about 10 years ago

  • Status changed from New to Feedback

Does OpenGFX have now everything it needs to compile on windows reasonably? Or did I miss something?

#10 Updated by Terkhen about 10 years ago

From the original list of issues (besides NML ones), only the problem with undefined CC is missing. There is a minor issue with output during install ([INSTALL] docs to C:UsersPublicDocumentsOpenTTDdataopengfx). Also, make install failed once because it could not erase existing files (I'm guessing problems with permissions) but I can't reproduce this problem.

#11 Updated by planetmaker about 10 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 0 to 100

Applied in changeset 8605b33400eb.

#12 Updated by Ammler about 10 years ago

I have different md5sums with linux or mingw, attached the nfos, please find the difference :-)

#13 Updated by planetmaker about 10 years ago

The town names do differ... How does that relate to the build system?

If that's from the very same repo version, please attach a verbose build log and possibly the whole project (bundle_src) or give the repo revision; the Swiss town name grf I know doesn't use the makefile.

#14 Updated by fanioz about 10 years ago

Illegal character '#' at "input", line 1 [msys - windows problem]
could be fixed with 'dos2unix' the .NML file before processed by nmlc (after [g]cc)

attached the (I want to try to make a) diff file.

Also available in: Atom PDF