Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Muduo usage

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. × × ×

The latest code on svn

1) tools to be installed

Yum install cmake

2) install boost

3) enter the home directory

. / build.sh

2 compilation exception

1) CMakeFiles/ttcp_blocking.dir/common.cc.o: In function `parseCommandLine (int, char**, Options*)':

/ root/workspace/muduo-master/examples/ace/ttcp/common.cc:14: undefined reference to

`boost::program_options::options_description::options_description (std::basic_string const&, unsigned int, unsigned int)'

From this error, we can know that it is caused by not specifying a link to the boost library.

2) add a link to boost in the CMakeLists.txt file

Set (CMAKE_CXX_FLAGS "- lboost_program_options")

Continue with the error message:

/ root/workspace/muduo-master/muduo/base/FileUtil.cc: In member function 'int

Muduo::FileUtil::ReadSmallFile::readToString (int, String*, int64_t*, int64_t*, int64_t*)':

/ root/workspace/muduo-master/muduo/base/FileUtil.cc:98: error: 'sizeof' cannot be used for incomplete classes

Type 'boost::STATIC_ASSERTION_FAILURE'

Since the problem has not been solved, try another way of thinking.

3) because the compiled files in the examples directory do not specify the boost library when they are linked, this leads to the first problem

Therefore, in the process of compilation, cancel the compilation of the examples content and choose to generate the version release

BUILD_NO_EXAMPLES=1 BUILD_TYPE=release. / build.sh-j2

For detailed parameter settings, please see build.sh.

3 compilation result

Generate a build folder at the level of the muduo directory

Library files: build/release/lib

Libmuduo_base.a libmuduo_http.a libmuduo_net.a

Libmuduo_base_cpp11.a libmuduo_inspect.a libmuduo_net_cpp11.a

4 simple test

Run bin/inspector_test and access it through the browser http://191.168.230.23:12345, please close linux

Firewall service iptbables stop.

Test results:

Name:inspector_test

State:S (sleeping)

Tgid:15762

Pid:15762

PPid:12064

TracerPid:0

Uid:0000

Gid:0000

5 individual tests

Muduo is a statically linked C++ library. When using the muduo library, you only need to set the header file path and library file path and link the corresponding static library file (- lmuduo_net-

Lmuduo_base) is fine.

Manually compile the first program that lost packets

Cd muduo-master/examples/simple/discard

Gmail + main.cc discard.cc-I / root/workspace/muduo-master/ / root/workspace/build/release/lib/libmuduo_base.a

/ root/workspace/build/release/lib/libmuduo_net.a-lpthread-o muduotest

Attach the Ubuntu compilation error here:

Compilation error, did not find the implementation of pthread_create, install libboost-dev to solve the problem

Use instructions:

Apt-get install gathers + cmake libboost-dev make git

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report