【发布时间】:2016-03-08 13:51:03
【问题描述】:
我在这个问题上看到的大多数编译错误都发生在使用 MinGW 的 Windows 上,我不是。
我正在使用 FreeBSD 10.2 稳定版、gcc 5、c++14。
下面是被踢出的错误代码。
src/map/message.cpp:445:23: error: 'to_string' is not a member of 'std'
server.append(std::to_string(chatPort));
这是该行的实际代码及其后面的一些代码。
string_t server = "tcp://";
server.append(chatIp);
server.append(":");
server.append(std::to_string(chatPort));
这是头文件
#include "../common/socket.h"
#include "../common/sql.h"
#include "../common/mmo.h"
#include <zmq.hpp>
#include "../common/cbasetypes.h"
class CBasicPacket;
struct chat_message_t
{
zmq::message_t* type;
zmq::message_t* data;
zmq::message_t* packet;
};
namespace message
{
void init(const char* chatIp, uint16 chatPort);
void send(MSGSERVTYPE type, void* data, size_t datalen, CBasicPacket* packet);
void close();
};
任何想法或帮助将不胜感激!
提前致谢。
编辑如下*
这是我的 Makefile.am 现在
## Set automake options
AUTOMAKE_OPTIONS=foreign
## Gather sourcelist
include sources.am
## Set up all of our dependency flags
SRC_ALL = $(SRC_DARKSTAR)
CFLAGS_ALL = $(DARKSTAR_CFLAGS)
CPPFLAGS_ALL = $(DARKSTAR_CPPFLAGS)
CXXFLAGS_ALL = $(DARKSTAR_CXXFLAGS)
LIBS_ALL = $(DARKSTAR_LIBS)
LDFLAGS_ALL = $(DARKSTAR_LDFLAGS)
CXX = g++5 -std=c++14
CC = gcc5
CPP = gcc5 -E
CFLAGS_ALL += -std=gnu++14
CFLAGS_ALL += -std=c++14
CFLAGS_ALL += $(LUA_CFLAGS)
CFLAGS_ALL += $(MYSQL_CFLAGS)
LIBS_ALL += $(LUA_LIBS)
LIBS_ALL += $(MYSQL_LDFLAGS)
LIBS_ALL += -lzmq
## Add Architecture-specific stuff
if DARKSTAR_ARCH_LINUX
LIBS_ALL += -ldl
endif
if DARKSTAR_ARCH_SOLARIS
LIBS_ALL += -lsocket -lnsl -ldl
endif
if DARKSTAR_ARCH_FREEBSD
CPPFLAGS_ALL += -D__FREEBSD__
endif
if DARKSTAR_ARCH_NETBSD
CPPFLAGS_ALL += -D__NETBSD__
endif
if DARKSTAR_ARCH_WIN32
CPPFLAGS_ALL += -DFD_SETSIZE=4096 -DCYGWIN
endif
## Targets
bin_PROGRAMS = dsgame dsconnect dssearch
dsgame_SOURCES = $(SRC_ALL) $(SRC_MAP)
dsgame_CXXFLAGS = $(CFLAGS_ALL) $(CXXFLAGS_ALL)
dsgame_CPPFLAGS = $(CPPFLAGS_ALL) -DdsUDPSERV
dsgame_CFLAGS = $(CFLAGS_ALL)
dsgame_LDFLAGS = $(LDFLAGS_ALL)
dsgame_LDADD = $(LIBS_ALL)
dsconnect_SOURCES = $(SRC_ALL) $(SRC_LOGIN)
dsconnect_CXXFLAGS = $(CFLAGS_ALL) $(CXXFLAGS_ALL)
dsconnect_CPPFLAGS = $(CPPFLAGS_ALL) -DdsTCPSERV
dsconnect_CFLAGS = $(CFLAGS_ALL)
dsconnect_LDFLAGS = $(LDFLAGS_ALL)
dsconnect_LDADD = $(LIBS_ALL)
dssearch_SOURCES = $(SRC_SEARCH_COMMON) $(SRC_SEARCH)
dssearch_CXXFLAGS = $(CFLAGS_ALL) $(CXXFLAGS_ALL)
dssearch_CPPFLAGS = $(CPPFLAGS_ALL)
dssearch_CFLAGS = $(CFLAGS_ALL)
dssearch_LDFLAGS = $(LDFLAGS_ALL)
dssearch_LDADD = $(LIBS_ALL)
【问题讨论】:
-
<string>被收录了吗? -
假设
#include <string>没有修复它,请给出编译器命令(包括标志)。 -
制作 CC=gcc5 CXX=g++5 CPP="gcc5 -E"