libinzhangyuan/asio_kcp

client_lib 编译出错

liuchengguang opened this issue · 6 comments

g++ -Wall -g3 -c kcp_client.cpp -o kcp_client.o
kcp_client.cpp: In member function ‘void asio_kcp::kcp_client::do_send_connect_packet(uint64_t)’:
kcp_client.cpp:149:108: error: ‘strerror’ was not declared in this scope
std::cerr << "do_asio_kcp_connect send error return with errno: " << errno << " " << strerror(errno) << std::endl;

头文件<string.h> 在.cpp里已经包含,有谁遇见过吗?

I guess the problem is the version of gcc.

Which version on your computer?
Please try using gcc 4.8 or newest gcc.
And please tell the result.

gcc version is 5.2, i'm sure
[root@192 client_lib]# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/gcc/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --enable-languages=c,c++ --disable-multilib
Thread model: posix
gcc version 5.2.0 (GCC)

[root@192 client_lib]# rpm -qi glibc
Name : glibc
Version : 2.17
Release : 106.el7_2.4
Architecture: x86_64
Install Date: Fri 25 Mar 2016 02:14:10 PM CST
Group : System Environment/Libraries
Size : 13975241
License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Signature : RSA/SHA256, Wed 17 Feb 2016 06:10:21 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : glibc-2.17-106.el7_2.4.src.rpm
Build Date : Wed 17 Feb 2016 01:18:26 AM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem http://bugs.centos.org
Vendor : CentOS
URL : http://www.gnu.org/software/glibc/
Summary : The GNU libc libraries
Description :
The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and
memory, as well as to make upgrading easier, common system code is
kept in one place and shared between programs. This particular package
contains the most important sets of shared libraries: the standard C
library and the standard math library. Without these two libraries, a
Linux system will not function.
Name : glibc
Version : 2.17
Release : 106.el7_2.4
Architecture: i686
Install Date: Wed 27 Apr 2016 02:45:23 PM CST
Group : System Environment/Libraries
Size : 15029153
License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Signature : RSA/SHA256, Wed 17 Feb 2016 06:10:13 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : glibc-2.17-106.el7_2.4.src.rpm
Build Date : Wed 17 Feb 2016 12:39:48 AM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem http://bugs.centos.org
Vendor : CentOS
URL : http://www.gnu.org/software/glibc/
Summary : The GNU libc libraries
Description :

I can't help you. I have no idea.
Please write down the method if you solved it.
And this will help me and others.

Thx anyway! i'll try my best

i changed “strings.h ” to “ cstring” in files "kcp_client.cpp" , "kcp_client_util.cpp"; and added the head file “stdio.h” to file util/ikcp.c. thus, all clear!