c++ - Makefile C++11 error -


i'm learning makefiles. tried writing own 1 after little reading. problem is, errors connected c++11 standard, though put compiler flag needed makefile. here error:

/usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error:  #error file requires compiler , library support upcoming  iso c++ standard, c++0x. support experimental, ,  must enabled -std=c++0x or -std=gnu++0x compiler options. 

and here makefile:

cc = g++ ld = g++  name = app obj_dir = obj  src_dir = src   cxx_flags = -std=c++0x  src = $(shell find $(src_dir) -type f -regex ".*\.cpp") obj = $(subst $(src_dir), $(obj_dir), $(addsuffix .o, $(basename $(src))))  all: $(name)  $(name): $(obj)     $(ld)  $< -o $@ $(cxx_flags)  $(obj_dir)/%.o: $(src_dir)/%.cpp     $(cc)  $< -o $@ $(cxx_flags)  clean:     rm $(name) $(obj_dir) -rf  

notice i've put cxx_flags after checking out other questions on stack overflow, no avail. still same error. it's make ignoring flag. there solution this?

and yes, can compile -std=c++0x flag without make, compiler not problem obviously.

does directory obj exist?

a better way write be:

obj = $(patsubst $(src_dir)/%.cpp,$(obj_dir)/%.o,$(src)) 

you can add $(info obj = $(obj)) etc. after these lines print them out. results of these operations don't match pattern rules, make using default pattern rules.

i discourage kind of thing (using find) though. always, type out source files want compile. doesn't take more few seconds add new file, , ensures don't start throwing random junk program when least expect it.

your compile command wrong: you've forgotten -c flag important. recommend people use same command default rules (run make -p -f/dev/null see default rules).:

$(obj_dir)/%.o: $(src_dir)/%.cpp         $(compile.cc) $(output_option) $< 

this require use standard flags variables (i.e., cxx not cc , cxxflags not cxx_flags) that's idea anyway.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -