freebsd错误:'to_string'不是'std'的成员

时间:2016-03-08 13:51:03

标签: c++ gcc freebsd

我在这个问题上遇到的大多数编译错误都是在使用MinGW的Windows上我不是。

我使用的是FreeBSD 10.2 stable,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)

1 个答案:

答案 0 :(得分:0)

CFLAG_ALL += -D_GLIBCXX_USE_C99
CFLAG_ALL += -D_GLIBCXX_USE_C99_MATH
CFLAG_ALL += -D_GLIBCXX_USE_C99_MATH_TR1

将这三行添加到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 -E
CPP                     = gcc5 -E



CFLAGS_ALL              += -D_GLIBCXX_USE_C99
CFLAGS_ALL              += -D_GLIBCXX_USE_C99_MATH
CFLAGS_ALL              += -D_GLIBCXX_USE_C99_MATH_TR1

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)

使用上面的makefile我只需输入make来构建程序。感谢那些对此有帮助的人。