Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I compiled boost by this method on Windows:

Go to the directory tools/build/v2/.
Run bootstrap.sh
Run b2 install --prefix=PREFIX where PREFIX is the directory where you want Boost.Build to be installed
Add PREFIX/bin to your PATH environment variable.

And It was working. Now I am trying this on Linux and it does not. I have the following situation:

kron@kron:~/Software/Sources/boost_1_49_0/tools/build/v2$ ./bootstrap.sh 
bash: ./bootstrap.sh: /bin/sh^M: bad interpreter: No such file or directory
kron@kron:~/Software/Sources/boost_1_49_0/tools/build/v2$ sh bootstrap.sh 
: not foundh: 8: 
: not foundh: 10: 
: not foundh: 14: 
bootstrap.sh: 15: Syntax error: Bad for loop variable
kron@kron:~/Software/Sources/boost_1_49_0/tools/build/v2$ ls -l
total 224
-rw-r--r--  1 kron kron   271 Nov  5  2006 boost-build.jam
-rw-r--r--  1 kron kron  7437 Nov  9  2008 boost_build.png
-rw-r--r--  1 kron kron  7169 Jan 14  2009 boost_build.svg
-rw-r--r--  1 kron kron   842 Nov  5  2006 boost.css
-rw-r--r--  1 kron kron  1088 Jun  6  2011 bootstrap.bat
-rw-r--r--  1 kron kron   778 Oct 29  2003 bootstrap.jam
-rwxr-xr-x  1 kron kron  2737 Jun  6  2011 bootstrap.sh
drwx------  2 kron kron  4096 Feb 22 18:28 build
-rw-r--r--  1 kron kron 36462 Jun  6  2011 build-system.jam
share|improve this question
up vote 3 down vote accepted

That ^M is a carriage return. Windows represents line breaks by the two-character sequence carriage return, line feed (CRLF or ^M^J). Linux and other unices use the single character LF. This CR is treated as an ordinary character, so the kernel looks for an interpreter called /bin/sh␍ instead of /bin/sh. When you invoked sh explicitly, it also treated the CR as an ordinary character, part of commands names.

This is a sign that those files were copied from a Windows machine where they were text files. You can't directly copy text files between Windows and Linux machines, you need to convert the line endings. Chances are that you extracted the archive on Windows, then copied the files to Linux. Instead of doing that, extract the archive on Linux.

In the case of Boost, as of version 1.49.0, the archive is distributed in four formats:

  • gzip and bzip2, with unix line endings;
  • zip and 7z, with Windows line endings.

The easiest way of compiling Boost under Linux is to use the bzip2 archive. If you must work with the 7z, you can use commands such as dos2unix or sed -i -e 's/\r$//' on all text files to convert the line endings.

share|improve this answer
I did not copy this. I downloaded from official site. Thx. – itun Apr 6 '12 at 0:38
@itun Then it seems the official archive is broken. What archive did you download exactly? How did you extract it? – Gilles Apr 6 '12 at 0:41
sourceforge.net/projects/boost/files/boost/1.49.0 7z archive – itun Apr 6 '12 at 1:15
dos2unix on the bash script, but this may lead to more problems in other scripts too... – Aaron D. Marasco Apr 6 '12 at 1:25
@itun “Distribution files with extensions .zip and .7z use Windows line endings.” It would be easiest for you to use the .bz2, which uses Unix line endings. – Gilles Apr 7 '12 at 0:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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