消息关闭
    暂无新消息!

1.Linux 下两个makefile编译同一个源文件,两个makefile编译同一个源文件,第一个makefile可以通过,第二个makefile就会报错error: ‘to_string’ is not a member of ‘std’

2.makefile文件
(1)源码

if(handle_status == 0) {
    send_str = "{\"status\":\"ok\", \"errorcode\":" + std::to_string(handle_status) + "}";
} else {
    send_str = "{\"status\":\"error\", \"errorcode\":" + std::to_string(handle_status) + "}";
}

(2)第一个makefile

OBJS = broadcast.o nvme_gpu_handle.o udp_server.o
CC = g++
CFLAGS = -Wall -g -std=c++11

psme_client : $(OBJS)
    $(CC) $(OBJS) -o psme_client

udp_server.o : udp_server.cpp  udp_server.hpp
    $(CC) $(CFLAGS) -c udp_server.cpp -o udp_server.o

broadcast.o : broadcast.cpp broadcast.hpp
    $(CC) $(CFLAGS) -c broadcast.cpp -o broadcast.o

nvme_gpu_handle.o : nvme_gpu_handle.cpp nvme_gpu_handle.hpp
    $(CC) $(CFLAGS) -c nvme_gpu_handle.cpp -o nvme_gpu_handle.o

clean :
    rm -rf *.o
    rm -rf psme_client

(3)第二个makefile

CC := g++
CFLAGS := -std=c++11 -g -Wall -O3 
Target := psme_client
Source := $(wildcard ./*.cpp)
ndir := $(notdir $(Source))
Objs := $(patsubst %.cpp,%.o,$(Source))

.PHONY: all clean

$(Target) : $(Objs)
    $(CC) $(CFLAGS) -o $(Target) $(Objs)
    @ echo "make $(Target) down!"    

all:
    $(Target)     
    
clean:
    rm -rf $(Objs)
    @ echo "clean down"

3.错误
error: ‘to_string’ is not a member of ‘std’
4.截图

5.找过的解决方法
https://stackoverflow.com/que...
还有其他的,都没有解决,求大神相助!


0个回答

暂无回答!