下载地址:http://sourceforge.net/projects/asio/files/asio/1.12.2%20%28Stable%29/
本人下载的版本:asio-1.12.2
1,本人环境:
1dengzhongqiangdeMacBook-Pro:asio-1.12.2 dengzhongqiang$ clang -v 2Apple LLVM version 10.0.0 (clang-1000.10.44.4) 3Target: x86_64-apple-darwin18.5.0 4Thread model: posix 5InstalledDir: /Library/Developer/CommandLineTools/usr/bin
2. cd到下载的库目录
1dengzhongqiangdeMacBook-Pro:asio-1.12.2 dengzhongqiang$ ./configure 2checking whether to enable maintainer-specific portions of Makefiles... no 3checking for a BSD-compatible install... /usr/bin/install -c 4checking whether build environment is sane... yes 5checking for a thread-safe mkdir -p... ./install-sh -c -d 6checking for gawk... no 7checking for mawk... no 8checking for nawk... no 9checking for awk... awk 10checking whether make sets $(MAKE)... yes 11checking whether make supports nested variables... yes 12checking whether UID '501' is supported by ustar format... yes 13checking whether GID '20' is supported by ustar format... yes 14checking how to create a ustar tar archive... gnutar 15checking build system type... x86_64-apple-darwin18.5.0 16checking host system type... x86_64-apple-darwin18.5.0 17checking whether make supports the include directive... yes (GNU style) 18checking for gcc... gcc 19checking whether the C compiler works... yes 20checking for C compiler default output file name... a.out 21checking for suffix of executables... 22checking whether we are cross compiling... no 23checking for suffix of object files... o 24checking whether we are using the GNU C compiler... yes 25checking whether gcc accepts -g... yes 26checking for gcc option to accept ISO C89... none needed 27checking whether gcc understands -c and -o together... yes 28checking dependency style of gcc... gcc3 29checking for g++... g++ 30checking whether we are using the GNU C++ compiler... yes 31checking whether g++ accepts -g... yes 32checking dependency style of g++... gcc3 33checking for ranlib... ranlib 34checking how to run the C++ preprocessor... g++ -E 35checking for grep that handles long lines and -e... /usr/bin/grep 36checking for egrep... /usr/bin/grep -E 37checking for ANSI C header files... yes 38checking for sys/types.h... yes 39checking for sys/stat.h... yes 40checking for stdlib.h... yes 41checking for string.h... yes 42checking for memory.h... yes 43checking for strings.h... yes 44checking for inttypes.h... yes 45checking for stdint.h... yes 46checking for unistd.h... yes 47checking boost/noncopyable.hpp usability... yes 48checking boost/noncopyable.hpp presence... yes 49checking for boost/noncopyable.hpp... yes 50checking openssl/ssl.h usability... no 51checking openssl/ssl.h presence... no 52checking for openssl/ssl.h... no 53checking whether C++11 is enabled... no 54checking whether C++14 is enabled... no 55checking that generated files are newer than configure... done 56configure: creating ./config.status 57config.status: creating Makefile 58config.status: creating include/Makefile 59config.status: creating src/Makefile 60config.status: creating src/tests/Makefile 61config.status: creating src/examples/cpp03/Makefile 62config.status: creating src/examples/cpp11/Makefile 63config.status: creating src/examples/cpp14/Makefile 64config.status: creating src/examples/cpp17/Makefile 65config.status: executing depfiles commands
3.执行make
1dengzhongqiangdeMacBook-Pro:asio-1.12.2 dengzhongqiang$ make 2Making all in include 3make[1]: Nothing to be done for `all'. 4Making all in src 5Making all in examples/cpp03 6g++ -I./../../../include -g -O2 -ftemplate-depth-256 -o icmp/ping icmp/ping.o 7Undefined symbols for architecture x86_64: 8 "boost::chrono::steady_clock::now()", referenced from: 9 pinger::start_send() in ping.o 10 asio::detail::timer_queue<asio::detail::chrono_time_traits<boost::chrono::steady_clock, asio::wait_traits<boost::chrono::steady_clock> > >::wait_duration_msec(long) const in ping.o 11 asio::detail::timer_queue<asio::detail::chrono_time_traits<boost::chrono::steady_clock, asio::wait_traits<boost::chrono::steady_clock> > >::wait_duration_usec(long) const in ping.o 12 asio::detail::timer_queue<asio::detail::chrono_time_traits<boost::chrono::steady_clock, asio::wait_traits<boost::chrono::steady_clock> > >::get_ready_timers(asio::detail::op_queue<asio::detail::scheduler_operation>&) in ping.o 13 pinger::handle_receive(unsigned long) in ping.o 14ld: symbol(s) not found for architecture x86_64 15clang: error: linker command failed with exit code 1 (use -v to see invocation) 16make[2]: *** [icmp/ping] Error 1 17make[1]: *** [all-recursive] Error 1 18make: *** [all-recursive] Error 1
这里执行报错了。因为这个报错: boost::chrono::steady_clock::now()
分析:由于本人没有安装 boost,所以就没有这个api了。
解决办法:
1.安装boost库
brew install boost
然后执行
./configure --with-boost='/usr/local/include'
4.安装asio
make install