I have written an application in the IDE CLion. I am trying to create a Makefile on a Linux machine. I used a template Makefile to create my own Makefile, however, there are issues. Note that there are 3 classes called quote, trade and signal.
CXX = g++
# mandatory build flags
CXXFLAGS = -O2 -Werror -std=c++11
# mandatory link flags
AM_LDFLAGS = -Wl,-as-neeeded
output: main.o quote.o trade.o signal.o
${CXX} ${AM_LDFLAGS} ${LDFLAGS} $(filter %.o,$^) -o $@
%: %.cpp
${CXX} ${AM_CXXFLAGS} ${CXXFLAGS} $< -c -o $@
quote.o: quote.cpp quote.h
trade.o: trade.cpp trade.h
signal.o: signal.cpp signal.h
When I run the Makefile, I get the errors:
error: #error This file required the -std=c++11 or -std=gnu++11 compiler options.
Then, many errors appear which require C++11 support. For example, there are issues with std::string, std::chrono. How do I fix this? I am requesting that someone fix the code. Since I just started learning MakeFile today, I most likely won't understand your technical suggestion. Please help. Very appreciative!
EDIT: After following the suggestions below, I fixed the above error. I am now getting the following errors:
g++ -02 -Werror -std=c++11 -c -o main.o main.cpp
g++ -02 -Werror -std=c++11 -c -o quote.o quote.cpp
g++ -02 -Werror -std=c++11 -c -o trade.o trade.cpp
g++ -Wl, -as-needed main.o quote.o trade.o signal.o -o output
/usr/bin/ld: unrecognixed -a option 's-needed'
collect2: error: ld returned 1 exit status
-std=c++11to the CXXFLAGS...CXXFLAGS = -O2 -Werror -std=c++11instead of the existing line you have there.makenot just the error message.