title: Getting the error "cc1plus: error: unrecognized command line option "-std=c++11"" when I run code on Qt creator
body: <p>I have taken the code from the following source on Github and am trying to run it from Qt on RHEL Red Hat 4.4.7-17:</p>
  
  <p><a href="https://github.com/neveraway/oclJPEGDecoder" rel="nofollow noreferrer">https://github.com/neveraway/oclJPEGDecoder</a></p>
  
  <p>I extracted the project folder and ran <code>qmake -project</code>in it. I opened the files in Qt creator and further modified my .pro file to link OpenCL sources and add the CXX and CFLAGS.</p>
  
  <p>My .pro file looks like this:</p>
  
  <pre><code>######################################################################
  # Automatically generated by qmake (1.07a) Tue Mar 28 14:51:49 2017
  ######################################################################
  
  TEMPLATE = app
  DEPENDPATH += src \
                /usr/local/cuda-7.0/lib64/
  
  INCLUDEPATH += . src \
                  /usr/local/cuda-7.0/lib64/\
                 /usr/local/cuda-7.0/include/
  # Input
  HEADERS += src/bitstream.h \
             src/bmp.h \
             src/decoder.h \
             src/huffman.h \
             src/idct.h \
             src/jpeg.h \
             src/macro.h \
             src/stdafx.h \
             src/targetver.h \
             src/zigzag.h
  
  SOURCES += src/bitstream.cpp \
             src/cpuIDCT8x8.cpp \
             src/decoder.cpp \
             src/huffman.cpp \
             src/main.cpp \
             src/oclDCT8x8.cpp \
             src/parser.cpp \
             src/stdafx.cpp \
      src/main.cpp
  
  LIBS += -L/usr/local/cuda-7.0/lib64/ -lOpenCL
  
  QMAKE_CXXFLAGS += -std=c++11
  
  QMAKE_CFLAGS += -std=c99
  
  DISTFILES += \
      src/idct8x8.cl \
      oclJPEGDecoder.sln \
      oclJPEGDecoder.vcxproj \
      oclJPEGDecoder.vcxproj.filters \
      README.md \
      test/JPEG_example_JPG_RIP_050.jpg
  </code></pre>
  
  <p>When I clicked on <code>Run qmake</code> and then <code>Build All</code>, this is what I saw under "Compile Output":</p>
  
  <pre><code>18:08:23: Configuration unchanged, skipping qmake step.
  18:08:23: Starting: "/usr/bin/make" 
  Makefile:634: warning: overriding commands for target `main.o'
  Makefile:603: warning: ignoring old commands for target `main.o'
  g++ -c -pipe -std=c++11 -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../oclJPEGDecoder-master -I. -I../oclJPEGDecoder-master -I../oclJPEGDecoder-master/src -I/usr/local/cuda-7.0/lib64 -I/usr/local/cuda-7.0/include -I/opt/Qt5.6.2/5.6/gcc_64/include -I/opt/Qt5.6.2/5.6/gcc_64/include/QtGui -I/opt/Qt5.6.2/5.6/gcc_64/include/QtCore -I. -I/opt/Qt5.6.2/5.6/gcc_64/mkspecs/linux-g++ -o bitstream.o ../oclJPEGDecoder-master/src/bitstream.cpp
  cc1plus: error: unrecognized command line option "-std=c++11"
  make: *** [bitstream.o] Error 1
  18:08:23: The process "/usr/bin/make" exited with code 2.
  Error while building/deploying project oclJPEGDecoder-master (kit: Desktop Qt 5.6.2 GCC 64bit)
  When executing step "Make"
  18:08:23: Elapsed time: 00:00.
  </code></pre>
  
  <p>My <code>Makefile</code> has the following contents:</p>
  
  <pre><code>#############################################################################
  # Makefile for building: oclJPEGDecoder-master
  # Generated by qmake (3.0) (Qt 5.6.2)
  # Project:  ../oclJPEGDecoder-master/oclJPEGDecoder-master.pro
  # Template: app
  # Command: /opt/Qt5.6.2/5.6/gcc_64/bin/qmake -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug -o Makefile ../oclJPEGDecoder-master/oclJPEGDecoder-master.pro
  #############################################################################
  
  MAKEFILE      = Makefile
  
  ####### Compiler, tools and options
  
  CC            = gcc
  CXX           = g++
  DEFINES       = -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB
  CFLAGS        = -pipe -g -Wall -W -D_REENTRANT -fPIC $(DEFINES)
  CXXFLAGS      = -pipe -std=c++11 -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC $(DEFINES)
  INCPATH       = -I../oclJPEGDecoder-master -I. -I../oclJPEGDecoder-master -I../oclJPEGDecoder-master/src -I/usr/local/cuda-7.0/lib64 -I/usr/local/cuda-7.0/include -I/opt/Qt5.6.2/5.6/gcc_64/include -I/opt/Qt5.6.2/5.6/gcc_64/include/QtGui -I/opt/Qt5.6.2/5.6/gcc_64/include/QtCore -I. -I/opt/Qt5.6.2/5.6/gcc_64/mkspecs/linux-g++
  QMAKE         = /opt/Qt5.6.2/5.6/gcc_64/bin/qmake
  DEL_FILE      = rm -f
  CHK_DIR_EXISTS= test -d
  MKDIR         = mkdir -p
  COPY          = cp -f
  COPY_FILE     = cp -f
  COPY_DIR      = cp -f -R
  INSTALL_FILE  = install -m 644 -p
  INSTALL_PROGRAM = install -m 755 -p
  INSTALL_DIR   = cp -f -R
  DEL_FILE      = rm -f
  SYMLINK       = ln -f -s
  DEL_DIR       = rmdir
  MOVE          = mv -f
  TAR           = tar -cf
  COMPRESS      = gzip -9f
  DISTNAME      = oclJPEGDecoder-master1.0.0
  DISTDIR = /root/Downloads/build-oclJPEGDecoder-master-Desktop_Qt_5_6_2_GCC_64bit-Debug/.tmp/oclJPEGDecoder-master1.0.0
  LINK          = g++
  LFLAGS        = -Wl,-rpath,/opt/Qt5.6.2/5.6/gcc_64/lib
  LIBS          = $(SUBLIBS) -L/usr/local/cuda-7.0/lib64/ -lOpenCL -L/opt/Qt5.6.2/5.6/gcc_64/lib -lQt5Gui -L/usr/lib64 -lQt5Core -lGL -lpthread 
  AR            = ar cqs
  RANLIB        = 
  SED           = sed
  STRIP         = strip
  </code></pre>
  
  <p>My <code>.o</code> files look like this:</p>
  
  <pre><code>####### Compile
  
  bitstream.o: ../oclJPEGDecoder-master/src/bitstream.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/bitstream.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o bitstream.o ../oclJPEGDecoder-master/src/bitstream.cpp
  
  cpuIDCT8x8.o: ../oclJPEGDecoder-master/src/cpuIDCT8x8.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/idct.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o cpuIDCT8x8.o ../oclJPEGDecoder-master/src/cpuIDCT8x8.cpp
  
  decoder.o: ../oclJPEGDecoder-master/src/decoder.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/jpeg.h \
          ../oclJPEGDecoder-master/src/bmp.h \
          ../oclJPEGDecoder-master/src/bitstream.h \
          ../oclJPEGDecoder-master/src/huffman.h \
          ../oclJPEGDecoder-master/src/zigzag.h \
          ../oclJPEGDecoder-master/src/idct.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o decoder.o ../oclJPEGDecoder-master/src/decoder.cpp
  
  huffman.o: ../oclJPEGDecoder-master/src/huffman.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/huffman.h \
          ../oclJPEGDecoder-master/src/bitstream.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o huffman.o ../oclJPEGDecoder-master/src/huffman.cpp
  
  main.o: ../oclJPEGDecoder-master/src/main.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/bitstream.h \
          ../oclJPEGDecoder-master/src/huffman.h \
          ../oclJPEGDecoder-master/src/idct.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o ../oclJPEGDecoder-master/src/main.cpp
  
  oclDCT8x8.o: ../oclJPEGDecoder-master/src/oclDCT8x8.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          /usr/local/cuda-7.0/include/CL/opencl.h \
          /usr/local/cuda-7.0/include/CL/cl.h \
          /usr/local/cuda-7.0/include/CL/cl_platform.h \
          /usr/local/cuda-7.0/include/CL/cl_gl.h \
          /usr/local/cuda-7.0/include/CL/cl_gl_ext.h \
          /usr/local/cuda-7.0/include/CL/cl_ext.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/idct.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o oclDCT8x8.o ../oclJPEGDecoder-master/src/oclDCT8x8.cpp
  
  parser.o: ../oclJPEGDecoder-master/src/parser.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/jpeg.h \
          ../oclJPEGDecoder-master/src/decoder.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o parser.o ../oclJPEGDecoder-master/src/parser.cpp
  
  stdafx.o: ../oclJPEGDecoder-master/src/stdafx.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o stdafx.o ../oclJPEGDecoder-master/src/stdafx.cpp
  
  main.o: ../oclJPEGDecoder-master/src/main.cpp ../oclJPEGDecoder-master/src/stdafx.h \
          ../oclJPEGDecoder-master/src/targetver.h \
          ../oclJPEGDecoder-master/src/macro.h \
          ../oclJPEGDecoder-master/src/bitstream.h \
          ../oclJPEGDecoder-master/src/huffman.h \
          ../oclJPEGDecoder-master/src/idct.h
      $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o ../oclJPEGDecoder-master/src/main.cpp
  
  ####### Install
  
  install:  FORCE
  
  uninstall:  FORCE
  
  FORCE:
  </code></pre>
  
  <p><strong>2nd ATTEMPT WITH <code>-std=c++0x</code>:</strong></p>
  
  <p>I changed the CXX_FLAGS command to <code>QMAKE_CXXFLAGS += -std=c++0x</code> and kept everything else unchanged in my <code>.pro</code> file. 
  When I clicked on <code>Build All</code> after making the change, this is the output I got under "Compile Output":</p>
  
  <pre><code>18:38:06: Running steps for project oclJPEGDecoder-master...
  18:38:06: Configuration unchanged, skipping qmake step.
  18:38:06: Starting: "/usr/bin/make" 
  Makefile:634: warning: overriding commands for target `main.o'
  Makefile:603: warning: ignoring old commands for target `main.o'
  g++ -c -pipe -std=c++0x -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I../oclJPEGDecoder-master -I. -I../oclJPEGDecoder-master -I../oclJPEGDecoder-master/src -I/usr/local/cuda-7.0/lib64 -I/usr/local/cuda-7.0/include -I/opt/Qt5.6.2/5.6/gcc_64/include -I/opt/Qt5.6.2/5.6/gcc_64/include/QtGui -I/opt/Qt5.6.2/5.6/gcc_64/include/QtCore -I. -I/opt/Qt5.6.2/5.6/gcc_64/mkspecs/linux-g++ -o bitstream.o ../oclJPEGDecoder-master/src/bitstream.cpp
  In file included from ../oclJPEGDecoder-master/src/bitstream.cpp:4:
  ../oclJPEGDecoder-master/src/bitstream.h:368: error: 'nullptr' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h:368: error: ISO C++ forbids initialization of member 'mBitReservoir'
  ../oclJPEGDecoder-master/src/bitstream.h:368: error: making 'mBitReservoir' static
  ../oclJPEGDecoder-master/src/bitstream.h:368: error: invalid in-class initialization of static data member of non-integral type 'uint8_t*'
  ../oclJPEGDecoder-master/src/bitstream.h:369: error: ISO C++ forbids initialization of member 'mCapacity'
  ../oclJPEGDecoder-master/src/bitstream.h:369: error: making 'mCapacity' static
  ../oclJPEGDecoder-master/src/bitstream.h:369: error: ISO C++ forbids in-class initialization of non-const static member 'mCapacity'
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'void BitStream::free()':
  ../oclJPEGDecoder-master/src/bitstream.h:96: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h:96: error: 'nullptr' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h:98: error: type '&lt;type error&gt;' argument given to 'delete', expected pointer
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'void BitStream::trim()':
  ../oclJPEGDecoder-master/src/bitstream.h:110: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'bool BitStream::reserve(size_t)':
  ../oclJPEGDecoder-master/src/bitstream.h:137: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'bool BitStream::frontBit() const':
  ../oclJPEGDecoder-master/src/bitstream.h:209: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'uint8_t BitStream::frontFullByte() const':
  ../oclJPEGDecoder-master/src/bitstream.h:214: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'uint32_t BitStream::front9b(uint8_t) const':
  ../oclJPEGDecoder-master/src/bitstream.h:219: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'uint32_t BitStream::front17b(uint8_t) const':
  ../oclJPEGDecoder-master/src/bitstream.h:227: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'uint32_t BitStream::front25b(uint8_t) const':
  ../oclJPEGDecoder-master/src/bitstream.h:235: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'void BitStream::writeBit(bool)':
  ../oclJPEGDecoder-master/src/bitstream.h:246: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h:248: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'const uint8_t* BitStream::frontData() const':
  ../oclJPEGDecoder-master/src/bitstream.h:307: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'uint32_t BitStream::cachedFrontBits(int)':
  ../oclJPEGDecoder-master/src/bitstream.h:340: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.h: In member function 'void BitStream::moveDataTo(uint8_t*)':
  ../oclJPEGDecoder-master/src/bitstream.h:398: error: 'mBitReservoir' was not declared in this scope
  ../oclJPEGDecoder-master/src/bitstream.cpp: In member function 'size_t BitStream::append(const uint8_t*, size_t)':
  ../oclJPEGDecoder-master/src/bitstream.cpp:22: error: 'mBitReservoir' was not declared in this scope
  make: *** [bitstream.o] Error 1
  18:38:06: The process "/usr/bin/make" exited with code 2.
  Error while building/deploying project oclJPEGDecoder-master (kit: Desktop Qt 5.6.2 GCC 64bit)
  When executing step "Make"
  18:38:06: Elapsed time: 00:00.
  </code></pre>
  
  <p>I got errors in <code>bitstream.c</code> due to incompatibility with the compiler.</p>
  
  <p><strong>How can I get around this issue? Do I absolutely need to install a new version of g++ to get this code to work? Do I need to include anything in my <code>Makefile</code>?</strong></p>
  
  <p>Please guide me in this matter.</p>
  
  <p>EDIT:</p>
  
  <p>My output for <code>g++ --version</code>:</p>
  
  <pre><code>g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
  Copyright (C) 2010 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  </code></pre>
  
  <p>I typed <code>yum install rpmdevtools rpm-build</code> and it gave me the following response:</p>
  
  <pre><code>Loaded plugins: product-id, refresh-packagekit, search-disabled-repos, security,
                : subscription-manager
  Setting up Install Process
  Package rpmdevtools-7.5-2.el6.noarch already installed and latest version
  Package rpm-build-4.8.0-55.el6.x86_64 already installed and latest version
  Nothing to do
  </code></pre>
  
  <p>I wanted to obtain more information about gcc on my system so I typed this command:</p>
  
  <pre><code>yum list available |grep gcc
  </code></pre>
  
  <p>It gave me this response:</p>
  
  <pre><code>compat-gcc-34.x86_64              3.4.6-19.el6           rhel-6-workstation-rpms
  compat-gcc-34-c++.x86_64          3.4.6-19.el6           rhel-6-workstation-rpms
  compat-gcc-34-g77.x86_64          3.4.6-19.el6           rhel-6-workstation-rpms
  gcc-gnat.x86_64                   4.4.7-18.el6           rhel-6-workstation-rpms
  gcc-java.x86_64                   4.4.7-18.el6           rhel-6-workstation-rpms
  gcc-objc.x86_64                   4.4.7-18.el6           rhel-6-workstation-rpms
  gcc-objc++.x86_64                 4.4.7-18.el6           rhel-6-workstation-rpms
  </code></pre>