Makefile C++11 - 编译为静态库

问题描述 投票:0回答:1

我正在尝试将源文件编译为静态库,但是,它似乎不起作用。这是代码:

#-----------------------------------------------------------------------------
#   Usage of make file
#-----------------------------------------------------------------------------
# Clean operation:
#   make -f MakeClient clean
#
# Make operation:
#   make -f MakeClient
#
#


#OBJ = $(SRC:.cpp=.o)
OBJ_DIR = ./obj

OUT_DIR= ../lib
OUT_FILE_NAME = libclient.a

# include directories
INCLUDES=-I. -I../common -I../../depends -I../../depends/zlib

# C++ compiler flags (-g -O2 -Wall)
CXXFLAGS := -Wall -Wextra -pedantic-errors -std+c++0x

  # compiler
  CCC = g++ 


  # Enumerating of every *.cpp as *.o and using that as dependency
  $(OUT_FILE_NAME): $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(wildcard *.cpp))
    $(CCC)  -o $(OUT_DIR)/$@ $^ -static $(LIB_DIR) $(LIBS) -std=c++11

#Compiling every *.cpp to *.o
$(OBJ_DIR)/%.o: %.cpp dircreation
$(CCC) -c $(INCLUDES) $(CCFLAGS) -o $@ $<

dircreation:
@mkdir -p $(OUT_DIR)
@mkdir -p $(OBJ_DIR)

.PHONY : clean
clean:
rm -f $(OBJ_DIR)/*.o $(OUT_DIR)/$(OUT_FILE_NAME) Makefile.bak

问题似乎是认识到我正在使用 C++11,因为实际代码无法编译。

有什么想法吗?

c++ gcc makefile
1个回答
1
投票

CCFLAGS
替换为
CXXFLAGS
,反之亦然。

旗帜的拼写是

-std=c++0x
(谢谢,@Pixelchemist)。

© www.soinside.com 2019 - 2024. All rights reserved.