0

I am trying to compile a code example I downloaded for a web server (https://github.com/eidheim/Simple-Web-Server) with gcc-4.9 and I get an error I can't resolve:

src$ make
Makefile:45: http_examples.d: No such file or directory
/usr/bin/gcc-4.9 -MM http_examples.cpp -MT "http_examples.o http_examples.d" -MF http_examples.d
In file included from /usr/include/c++/4.9/regex:35:0,
                 from server_http.hpp:6,
                 from http_examples.cpp:1:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and    library support for the ISO C++ 2011 standard. This support is currently experimental, and must be   enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \

^

I have tried both compiler options and neither corrects the problem. Here are the relevant bits from the make file:

PROJECT = ToolBoxServer
# Compiler
CC = /usr/bin/gcc-4.9

# Run Options       
COMMANDLINE_OPTIONS = /dev/ttyS0

# Compiler options during compilation
COMPILE_OPTIONS = -std=c++11 -pedantic -Wall -Wno-long-long -ggdb3 -gstabs -O0 -pthreads

#Header include directories
HEADERS =  -I/usr/local/include -I./ -I/usr/local/include/boost
#Libraries for linking
LIBS = -lm -lmysqlcppconn
# Dependency options
DEPENDENCY_OPTIONS = -MM

# Compile every cpp file to an object
%.o: %.cpp
        $(CC) -c $(COMPILE_OPTIONS) -o $@ $< $(HEADERS)

I was using gcc-4.8. I read that gcc 4.9 has (better) support for regex and installed it but I get the same error.

Has anyone encountered this? To the best of my knowledge, gcc-4.9 is the most c++11-like compiler available. Can anyone suggest a way to fix this?

Thanks

Mike

manlio
  • 18,345
  • 14
  • 76
  • 126
user3096277
  • 107
  • 8

1 Answers1

2

You didn't include all the relevant bits from your makefile. Notably you didn't include the rule from your makefile that looks something like this:

%.d: %.cpp
     $(CC) -MM $< -MT "$(@:.d=.o) $@" -MF $@

You get the error because this rule doesn't use the same compilation options that you use when you invoke GCC normally. If you add $(COMPILE_OPTIONS) to this rule as well, you shouldn't get the error anymore.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112