14

I am trying to compile code, the makefile created using qmake. When I run mingw32-make I get the following error:

cd bzip2-1.0.5\ && c:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe c:\Documents an
d Settings\user\My Documents\Visual Studio 2010\Projects\meshlab\meshlab\meshla
b\src\external\bzip2-1.0.5\bzip2-1.0.5.pro -o Makefile
Cannot find file: c:\Documents.
Cannot find file: and.
Cannot find file: Settings\user\My.
Cannot find file: Documents\Visual.
Cannot find file: Studio.
Cannot find file: 2010\Projects\meshlab\meshlab\meshlab\src\external\bzip2-1.0.5
\bzip2-1.0.5.pro.
mingw32-make: *** [bzip2-1.0.5\Makefile] Error 2

By the error it appears that mingw32-make doesn't understand paths that have spaces in them. Is that true? Is there a way around it?

3
  • 1
    Did you try putting quotes around the entire path+filename with the spaces in it? – jonsca May 14 '11 at 3:19
  • @jonsca - the makefile was generated automatically by qmake. I would expect qmake to create valid makefiles, else what's it's use on windows at all? – olamundo May 14 '11 at 3:38
  • 1
    Yes, but the Documents and Settings bit has confounded other software for a while. They finally got it right in Vista and W7 when they changed it to \Users\name\Documents. Since your meshlab project is probably not tied to that path in any way, try moving it to c:\projects\ or something. – jonsca May 14 '11 at 3:43
8

From the MinGW "Getting Started" guide:

MinGW may have problems with paths containing spaces, and if not, usually other programs used with MinGW will experience problems with such paths. Thus, we strongly recommend that you do not install MinGW in any location with spaces in the path name reference; i.e. you should avoid installing into any subdirectory of "Program Files" or "My Documents", or the like.

I suspect the same problems found in running executable files will also manifest itself with other files as well. You could try wrapping the whole thing (file specification) inside double quotes and this may work but Windows is sometimes not as logical as UNIX-based shells in this area.


Spaces in file names are evil anyway :-)

2
  • 48
    Spaces aren't evil. Environments that can't handle them are evil. – Aleksandr Dubinsky Sep 13 '13 at 8:38
  • 1
    Totally agree ... Spaces aren't evil. Environments that can't handle them are evil! Back to 8.3 file/dir names or what? ^^ ..... – hfrmobile Mar 8 '16 at 10:05
9

The common way to do it in Linux/UNIX is to escape each space with a backslash, like: /c/Documents\ and\ Settings/User However, this doesn't always work in MinGW.

So, use the short (8.3) name. You get the short name with the Windows (not MinGW) command for %I in (<PATH>) do @echo %~sI where <PATH> can be . (show current directory, like pwd), * (list files in current directory), a particular file path, etc.

Btw, to copy from the awful cmd.exe window, click the icon in the upper-left corner of the title bar, go to Properties, Options, and enable QuickEdit Mode. Then you can select text with your mouse. The Enter key (or menu>Edit>Copy) copies the text to the clipboard. The insert key (or menu>Edit>Paste) pastes it.

0
8

Not sure if this helpful or not (in fear of being downvoted), but I created a semantic link in order to avoid paths with spaces. Not sure if it will solve the problem since in my scenario it displayed a different error after I used the semantic link relating to pthreads which I still haven't been able to fix.

Creating semantic link using the command prompt:

mklink /j "C:\newshortcut" "C:\Program Files\Directory with spaces"

Then on the command you want to run, you use C:\newshortcut

1
1

Sorry for necroing this, but I had a similar problem and I was able to fix it using cygpath.

For my case I was trying to make an environment variable to visual studio:

export DEVENV="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
echo $DEVENV
$DEVENV $1 /build "Release|win64"

Which would result in:

/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
-bash: /c/Program: No such file or directory

The solution was to use cygpath -w to convert the path with spaces into an 8.3 filename:

export DEVENV=$(cygpath -w -s "/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com")
echo $DEVENV
$DEVENV $1 /build "Release|win64"

Which results in:

C:\PROGRA~2\MICROS~1\2019\COMMUN~1\Common7\IDE\devenv.com

and no error. Hopefully this helps future travellers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.