chenshuo / recipes Goto Github PK
View Code? Open in Web Editor NEWSome code snippets for sharing
Home Page: blog.csdn.net/Solstice
License: BSD 3-Clause "New" or "Revised" License
Some code snippets for sharing
Home Page: blog.csdn.net/Solstice
License: BSD 3-Clause "New" or "Revised" License
recipes/thread/test/Waiter_test.cc
Line 230 in 5c04084
另外还有一些boost::bind可以替换成lambda function
g++ -O0 -g -Wall -I ../.. -pthread -o test1 Channel.cc EventLoop.cc Poller.cc ../../logging/Logging.cc ../../logging/LogStream.cc ../../thread/Thread.cc ../../datetime/Timestamp.cc test1.cc -lpthread
../../thread/Thread.cc: In function ‘pid_t muduo::CurrentThread::tid()’:
../../thread/Thread.cc:103:26: error: call of overloaded ‘gettid()’ is ambiguous
103 | t_cachedTid = gettid();
| ^
In file included from /usr/include/unistd.h:1170,
from /usr/include/boost/config/stdlib/libstdcpp3.hpp:78,
from /usr/include/boost/config.hpp:49,
from /usr/include/boost/core/noncopyable.hpp:12,
from /usr/include/boost/noncopyable.hpp:15,
from ../../thread/Atomic.h:11,
from ../../thread/Thread.h:11,
from ../../thread/Thread.cc:8:
/usr/include/x86_64-linux-gnu/bits/unistd_ext.h:34:16: note: candidate: ‘__pid_t gettid()’
34 | extern __pid_t gettid (void) __THROW;
| ^~~~~~
../../thread/Thread.cc:30:7: note: candidate: ‘pid_t {anonymous}::gettid()’
30 | pid_t gettid()
| ^~~~~~
make: *** [../reactor.mk:6: test1] Error 1
运行test8,使用telnet充当客户端,当在telnet中输入quit后,发现会执行Poller::updateChannel()的else分支。
这是为什么呢?
仔细研究了整个套接字的关闭流程:
::poll返回 --将事件放入activeChannel--> 由EventLoop调用handleEvent分发 --readCallback_()--> 进入TcpConnection的handleRead() --n==0执行handleClose()--> TcpServer::removeConnection() --queueInLoop--> TcpServer::connectDestory() --EventLoop::removeChannel() --> Poller::removeChannel()
并没有发现有Poller::updateChannel()被调用
而且发现Poller::updateChannel()的else分支中有
if (channel->isNoneEvent()) {
// ignore this pollfd
pfd.fd = -channel->fd()-1;
}
然后在EventLoop::removeChannel有
assert(pfd.fd == -channel->fd()-1 && pfd.events == channel->events());
的操作,感觉chenshuo大佬你应该是知道这个问题的,我研究了好一会儿。
chenshuo大佬有时间的话,可以稍微讲解一下吗?(问题可能有点简单,不过实在是没想明白。)
你好,买了你的书,不错啊!
但有个地方不太明白,你在2.1.1使用了shared_ptr::unique来断言g_foos是否为FooList的唯一引用,如果不是唯一引用,则重置。如下:
void post(const Foo& f)
{
printf("post\n");
getlock locker(mutex);
if (!g_foos.unique())
{
g_foos.reset(new FooList(*g_foos));
printf("copy the whole list\n");
}
assert(g_foos.unique());
g_foos->push_back(f);
}
但是,我在https://zh.cppreference.com/w/cpp/memory/shared_ptr/unique这个文档中看到一段话:
“此函数于 C++17 中被弃用并于 C++20 中移除,因为 use_count 在多线程环境中只是估计”。
请问如果我参考了你的解决方案,应用在项目中,后续是否有问题?
谢谢!
recipes / tpc / TcpStream.cc中的第50行
int nr = sock_.write(buf, len);
是否应换成
int nr = sock_.write(buf + written, len - written);
"next_permutation" works on a sorted-array, but (L10) int elements[] = { 1, 1, 1, 0, 0, 0, 0 }; this is not a non-decreasing array,so the answer will output only one line : "1:1,2,3".
I think elements should be "{0, 0, 0, 1, 1, 1, 1}" and (L21) should be "if (!selectors[i])", that will work and output results as except.
Line 85 in b9b67c9
just as in Singleton
Hi,
Thank you for sharing your code. I'm learning your code, and try to adopt your code into my program.
I'm writing the client by Qt on 64 bit windows, and server on 64 bit linuxMint, As I used your code in "codec.h", I sent information from client to server,
您好,
我是您 《Linux多线程》 的读者,我遇到一个问题:
我用的是Mac OS 系统,还是个新手,当我编译的时候,有个报错,说<sys/prctl.h> 找不到。 我查了一下,有人说这个文件在Mac OS 下是不支持的。 请问您有什么建议吗,是不是我弄的有问题?
非常感谢!
在recipes/thread/Mutex.h 中, MutexLock 类继承了boost的noncopyable, 是没有copy constructor 的,但是在MutexLockGuard 类的构造函数中却使用了初始化列表对 mutex_进行初始化,这样不是矛盾了吗?
event loop quit() twice here, then wakeup() in EventLoop sometimes fails and prints garbage info on screen.
g++ -g -Wall -O0 -pthread -lprotobuf -lz -lpthread -Wl,-rpath -Wl,/usr/local/lib query.pb.cc codec_test.cc -o codec_test
codec_test.cc: In function ‘void testQuery()’:
codec_test.cc:31:3: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
codec_test.cc:35:3: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
codec_test.cc: In function ‘void testAnswer()’:
codec_test.cc:79:3: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
codec_test.cc:83:3: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/tmp/cckaCacS.o: In function muduo::protobuf_AssignDesc_query_2eproto()': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:37: undefined reference to
google::protobuf::DescriptorPool::generated_pool()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:37: undefined reference to google::protobuf::DescriptorPool::FindFileByName(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:38: undefined reference to
google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const_, int)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:38: undefined reference to google::protobuf::internal::LogMessage::operator<<(char const_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:38: undefined reference to
google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:38: undefined reference togoogle::protobuf::internal::LogMessage::~LogMessage()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:55: undefined reference to
google::protobuf::DescriptorPool::generated_pool()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:55: undefined reference togoogle::protobuf::MessageFactory::generated_factory()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:55: undefined reference to
google::protobuf::internal::GeneratedMessageReflection::GeneratedMessageReflection(google::protobuf::Descriptor const*, google::protobuf::Message const*, int const*, int, int, int, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, int)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:73: undefined reference togoogle::protobuf::DescriptorPool::generated_pool()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:73: undefined reference to
google::protobuf::MessageFactory::generated_factory()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:73: undefined reference togoogle::protobuf::internal::GeneratedMessageReflection::GeneratedMessageReflection(google::protobuf::Descriptor const_, google::protobuf::Message const_, int const_, int, int, int, google::protobuf::DescriptorPool const_, google::protobuf::MessageFactory_, int)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:88: undefined reference to
google::protobuf::DescriptorPool::generated_pool()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:88: undefined reference togoogle::protobuf::MessageFactory::generated_factory()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:88: undefined reference to
google::protobuf::internal::GeneratedMessageReflection::GeneratedMessageReflection(google::protobuf::Descriptor const_, google::protobuf::Message const_, int const_, int, int, int, google::protobuf::DescriptorPool const_, google::protobuf::MessageFactory_, int)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:38: undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /tmp/cckaCacS.o: In function
protobuf_RegisterTypes':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:102: undefined reference to google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(google::protobuf::Descriptor const*, google::protobuf::Message const*)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:104: undefined reference to
google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(google::protobuf::Descriptor const_, google::protobuf::Message const_)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:106: undefined reference to google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(google::protobuf::Descriptor const*, google::protobuf::Message const*)' /tmp/cckaCacS.o: In function
muduo::protobuf_AddDesc_query_2eproto()':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:124: undefined reference to google::protobuf::internal::VerifyVersion(int, int, char const*)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:132: undefined reference to
google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const_, int)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:134: undefined reference to google::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const_, void (_)(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:141: undefined reference to
google::protobuf::internal::OnShutdown(void ()())'
/tmp/cckaCacS.o: In function Query': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:161: undefined reference to
google::protobuf::UnknownFieldSet::UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:161: undefined reference to google::protobuf::Message::~Message()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:169: undefined reference to
google::protobuf::UnknownFieldSet::UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:169: undefined reference to google::protobuf::UnknownFieldSet::~UnknownFieldSet()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:169: undefined reference to
google::protobuf::Message::~Message()'
/tmp/cckaCacS.o: In function muduo::Query::SharedCtor()': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:177: undefined reference to
google::protobuf::internal::kEmptyString'
/tmp/cckaCacS.o: In function ~Query': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:181: undefined reference to
google::protobuf::UnknownFieldSet::~UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:181: undefined reference to google::protobuf::Message::~Message()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:181: undefined reference to
google::protobuf::UnknownFieldSet::~UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:181: undefined reference to google::protobuf::Message::~Message()' /tmp/cckaCacS.o: In function
muduo::Query::SharedDtor()':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:186: undefined reference to google::protobuf::internal::kEmptyString' /tmp/cckaCacS.o: In function
muduo::Query::Clear()':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:217: undefined reference to google::protobuf::internal::kEmptyString' /tmp/cckaCacS.o: In function
muduo::Query::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:253: undefined reference to google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream_, std::basic_string<char, std::char_traits<char>, std::allocator<char> >_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:270: undefined reference to
google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream_, std::basic_string<char, std::char_traits, std::allocator >)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:289: undefined reference to google::protobuf::internal::WireFormat::SkipField(google::protobuf::io::CodedInputStream_, unsigned int, google::protobuf::UnknownFieldSet_)' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedInputStream::ReadTag()':
/usr/local/include/google/protobuf/io/coded_stream.h:818: undefined reference togoogle::protobuf::io::CodedInputStream::ReadTagFallback()' /tmp/cckaCacS.o: In function
muduo::Query::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream) const':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:303: undefined reference to google::protobuf::internal::WireFormatLite::WriteInt64(int, long, google::protobuf::io::CodedOutputStream*)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:312: undefined reference to
google::protobuf::internal::WireFormatLite::WriteString(int, std::basic_string<char, std::char_traits, std::allocator > const&, google::protobuf::io::CodedOutputStream_)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:321: undefined reference to google::protobuf::internal::WireFormatLite::WriteString(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:326: undefined reference to
google::protobuf::internal::WireFormat::SerializeUnknownFields(google::protobuf::UnknownFieldSet const&, google::protobuf::io::CodedOutputStream*)'
/tmp/cckaCacS.o: In functiongoogle::protobuf::io::CodedOutputStream::WriteTagToArray(unsigned int, unsigned char_)': /usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference to
google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char_)'
/tmp/cckaCacS.o: In function google::protobuf::internal::WireFormatLite::WriteInt64NoTagToArray(long, unsigned char*)': /usr/local/include/google/protobuf/wire_format_lite_inl.h:514: undefined reference to
google::protobuf::io::CodedOutputStream::WriteVarint64ToArray(unsigned long, unsigned char_)'
/tmp/cckaCacS.o: In function google::protobuf::io::CodedOutputStream::WriteTagToArray(unsigned int, unsigned char_)': /usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference to
google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char*)'
/usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference togoogle::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char_)' /tmp/cckaCacS.o: In function
muduo::Query::SerializeWithCachedSizesToArray(unsigned char_) const':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:358: undefined reference to google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*)' /tmp/cckaCacS.o: In function
muduo::Query::ByteSize() const':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:392: undefined reference to google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(google::protobuf::UnknownFieldSet const&)' /tmp/cckaCacS.o: In function
muduo::Query::MergeFrom(google::protobuf::Message const&)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:401: undefined reference to google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:401: undefined reference to
google::protobuf::internal::LogMessage::operator<<(char const_)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:401: undefined reference to google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:401: undefined reference to
google::protobuf::internal::LogMessage::~LogMessage()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:406: undefined reference to google::protobuf::internal::ReflectionOps::Merge(google::protobuf::Message const&, google::protobuf::Message_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:401: undefined reference to
google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/cckaCacS.o: In functionmuduo::Query::MergeFrom(muduo::Query const&)': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:413: undefined reference to
google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:413: undefined reference togoogle::protobuf::internal::LogMessage::operator<<(char const_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:413: undefined reference to
google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:413: undefined reference togoogle::protobuf::internal::LogMessage::~LogMessage()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:423: undefined reference to
google::protobuf::UnknownFieldSet::MergeFrom(google::protobuf::UnknownFieldSet const&)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:413: undefined reference togoogle::protobuf::internal::LogMessage::~LogMessage()' /tmp/cckaCacS.o: In function
Answer':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:474: undefined reference togoogle::protobuf::UnknownFieldSet::UnknownFieldSet()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:474: undefined reference to
google::protobuf::Message::~Message()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:482: undefined reference togoogle::protobuf::UnknownFieldSet::UnknownFieldSet()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:482: undefined reference to
google::protobuf::UnknownFieldSet::~UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:482: undefined reference togoogle::protobuf::Message::~Message()' /tmp/cckaCacS.o: In function
muduo::Answer::SharedCtor()':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:490: undefined reference togoogle::protobuf::internal::kEmptyString' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:491: undefined reference to
google::protobuf::internal::kEmptyString'
/tmp/cckaCacS.o: In function~Answer': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:495: undefined reference to
google::protobuf::UnknownFieldSet::~UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:495: undefined reference togoogle::protobuf::Message::~Message()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:495: undefined reference to
google::protobuf::UnknownFieldSet::~UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:495: undefined reference togoogle::protobuf::Message::~Message()' /tmp/cckaCacS.o: In function
muduo::Answer::SharedDtor()':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:500: undefined reference togoogle::protobuf::internal::kEmptyString' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:503: undefined reference to
google::protobuf::internal::kEmptyString'
/tmp/cckaCacS.o: In functionmuduo::Answer::Clear()': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:534: undefined reference to
google::protobuf::internal::kEmptyString'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:539: undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/cckaCacS.o: In function
muduo::Answer::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream_)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:575: undefined reference to google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:592: undefined reference to
google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream_, std::basic_string<char, std::char_traits, std::allocator >)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:609: undefined reference to google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:628: undefined reference to
google::protobuf::internal::WireFormat::SkipField(google::protobuf::io::CodedInputStream, unsigned int, google::protobuf::UnknownFieldSet_)'
/tmp/cckaCacS.o: In function google::protobuf::io::CodedInputStream::ReadTag()': /usr/local/include/google/protobuf/io/coded_stream.h:818: undefined reference to
google::protobuf::io::CodedInputStream::ReadTagFallback()'
/tmp/cckaCacS.o: In function muduo::Answer::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream*) const': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:642: undefined reference to
google::protobuf::internal::WireFormatLite::WriteInt64(int, long, google::protobuf::io::CodedOutputStream_)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:651: undefined reference to google::protobuf::internal::WireFormatLite::WriteString(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:660: undefined reference to
google::protobuf::internal::WireFormatLite::WriteString(int, std::basic_string<char, std::char_traits, std::allocator > const&, google::protobuf::io::CodedOutputStream*)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:669: undefined reference togoogle::protobuf::internal::WireFormatLite::WriteString(int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::io::CodedOutputStream_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:674: undefined reference to
google::protobuf::internal::WireFormat::SerializeUnknownFields(google::protobuf::UnknownFieldSet const&, google::protobuf::io::CodedOutputStream_)'
/tmp/cckaCacS.o: In function google::protobuf::io::CodedOutputStream::WriteTagToArray(unsigned int, unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference to
google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char_)'
/tmp/cckaCacS.o: In function google::protobuf::internal::WireFormatLite::WriteInt64NoTagToArray(long, unsigned char_)': /usr/local/include/google/protobuf/wire_format_lite_inl.h:514: undefined reference to
google::protobuf::io::CodedOutputStream::WriteVarint64ToArray(unsigned long, unsigned char*)'
/tmp/cckaCacS.o: In functiongoogle::protobuf::io::CodedOutputStream::WriteTagToArray(unsigned int, unsigned char_)': /usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference to
google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char_)'
/usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference to google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char*)' /usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference to
google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char_)'
/tmp/cckaCacS.o: In function muduo::Answer::SerializeWithCachedSizesToArray(unsigned char_) const': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:716: undefined reference to
google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*)'
/tmp/cckaCacS.o: In functionmuduo::Answer::ByteSize() const': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:757: undefined reference to
google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(google::protobuf::UnknownFieldSet const&)'
/tmp/cckaCacS.o: In functionmuduo::Answer::MergeFrom(google::protobuf::Message const&)': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:766: undefined reference to
google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:766: undefined reference togoogle::protobuf::internal::LogMessage::operator<<(char const_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:766: undefined reference to
google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:766: undefined reference togoogle::protobuf::internal::LogMessage::~LogMessage()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:771: undefined reference to
google::protobuf::internal::ReflectionOps::Merge(google::protobuf::Message const&, google::protobuf::Message_)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:766: undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /tmp/cckaCacS.o: In function
muduo::Answer::MergeFrom(muduo::Answer const&)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:778: undefined reference to google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:778: undefined reference to
google::protobuf::internal::LogMessage::operator<<(char const_)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:778: undefined reference to google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:778: undefined reference to
google::protobuf::internal::LogMessage::~LogMessage()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:791: undefined reference to google::protobuf::UnknownFieldSet::MergeFrom(google::protobuf::UnknownFieldSet const&)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:778: undefined reference to
google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/cckaCacS.o: In function Empty': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:840: undefined reference to
google::protobuf::UnknownFieldSet::UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:840: undefined reference to google::protobuf::Message::~Message()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:848: undefined reference to
google::protobuf::UnknownFieldSet::UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:848: undefined reference to google::protobuf::UnknownFieldSet::~UnknownFieldSet()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:848: undefined reference to
google::protobuf::Message::~Message()'
/tmp/cckaCacS.o: In function ~Empty': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:859: undefined reference to
google::protobuf::UnknownFieldSet::~UnknownFieldSet()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:859: undefined reference to google::protobuf::Message::~Message()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:859: undefined reference to
google::protobuf::Message::~Message()'
/tmp/cckaCacS.o: In function muduo::Empty::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream_)': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:923: undefined reference to
google::protobuf::internal::WireFormat::SkipField(google::protobuf::io::CodedInputStream*, unsigned int, google::protobuf::UnknownFieldSet*)'
/tmp/cckaCacS.o: In functiongoogle::protobuf::io::CodedInputStream::ReadTag()': /usr/local/include/google/protobuf/io/coded_stream.h:818: undefined reference to
google::protobuf::io::CodedInputStream::ReadTagFallback()'
/tmp/cckaCacS.o: In functionmuduo::Empty::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:937: undefined reference to
google::protobuf::internal::WireFormatLite::WriteInt32(int, int, google::protobuf::io::CodedOutputStream_)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:942: undefined reference to google::protobuf::internal::WireFormat::SerializeUnknownFields(google::protobuf::UnknownFieldSet const&, google::protobuf::io::CodedOutputStream*)' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedOutputStream::WriteTagToArray(unsigned int, unsigned char_)':
/usr/local/include/google/protobuf/io/coded_stream.h:972: undefined reference to google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char_)' /tmp/cckaCacS.o: In function
muduo::Empty::SerializeWithCachedSizesToArray(unsigned char*) const':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:955: undefined reference togoogle::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char_)' /tmp/cckaCacS.o: In function
muduo::Empty::ByteSize() const':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:975: undefined reference togoogle::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(google::protobuf::UnknownFieldSet const&)' /tmp/cckaCacS.o: In function
muduo::Empty::MergeFrom(google::protobuf::Message const&)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:984: undefined reference togoogle::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const_, int)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:984: undefined reference to
google::protobuf::internal::LogMessage::operator<<(char const*)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:984: undefined reference togoogle::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:984: undefined reference to
google::protobuf::internal::LogMessage::~LogMessage()'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:989: undefined reference togoogle::protobuf::internal::ReflectionOps::Merge(google::protobuf::Message const&, google::protobuf::Message_)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:984: undefined reference to
google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/cckaCacS.o: In functionmuduo::Empty::MergeFrom(muduo::Empty const&)': /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:996: undefined reference to
google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const_, int)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:996: undefined reference to google::protobuf::internal::LogMessage::operator<<(char const*)' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:996: undefined reference to
google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:996: undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /home/hua/source/chenshou_recipes/protobuf/query.pb.cc:1002: undefined reference to
google::protobuf::UnknownFieldSet::MergeFrom(google::protobuf::UnknownFieldSet const&)'
/home/hua/source/chenshou_recipes/protobuf/query.pb.cc:996: undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedInputStream::ReadVarint32(unsigned int_)':
/usr/local/include/google/protobuf/io/coded_stream.h:733: undefined reference to google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int_)' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedInputStream::ReadVarint64(unsigned long*)':
/usr/local/include/google/protobuf/io/coded_stream.h:743: undefined reference togoogle::protobuf::io::CodedInputStream::ReadVarint64Fallback(unsigned long_)' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(unsigned int, unsigned char_)':
/usr/local/include/google/protobuf/io/coded_stream.h:904: undefined reference to google::protobuf::io::CodedOutputStream::WriteVarint32FallbackToArray(unsigned int, unsigned char*)' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedOutputStream::WriteVarint32SignExtendedToArray(int, unsigned char_)':
/usr/local/include/google/protobuf/io/coded_stream.h:919: undefined reference to google::protobuf::io::CodedOutputStream::WriteVarint64ToArray(unsigned long, unsigned char_)' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedOutputStream::VarintSize32(unsigned int)':
/usr/local/include/google/protobuf/io/coded_stream.h:980: undefined reference togoogle::protobuf::io::CodedOutputStream::VarintSize32Fallback(unsigned int)' /tmp/cckaCacS.o: In function
google::protobuf::io::CodedOutputStream::WriteStringToArray(std::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:998: undefined reference togoogle::protobuf::io::CodedOutputStream::WriteRawToArray(void const_, int, unsigned char_)' /tmp/cckaCacS.o: In function
MessageLite':
/usr/local/include/google/protobuf/message_lite.h:73: undefined reference tovtable for google::protobuf::MessageLite' /tmp/cckaCacS.o: In function
Message':
/usr/local/include/google/protobuf/message.h:172: undefined reference tovtable for google::protobuf::Message' /tmp/cckaCacS.o: In function
google::protobuf::UnknownFieldSet::Clear()':
/usr/local/include/google/protobuf/unknown_field_set.h:187: undefined reference togoogle::protobuf::UnknownFieldSet::ClearFallback()' /tmp/cckaCacS.o: In function
muduo::Query::set_questioner(std::basic_string<char, std::char_traits, std::allocator > const&)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:411: undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/cckaCacS.o: In function
muduo::Query::mutable_questioner()':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:432: undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/cckaCacS.o: In function
muduo::Answer::set_questioner(std::basic_string<char, std::char_traits, std::allocator > const&)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:539: undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/cckaCacS.o: In function
muduo::Answer::mutable_questioner()':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:560: undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/cckaCacS.o: In function
muduo::Answer::set_answerer(std::basic_string<char, std::char_traits, std::allocator > const&)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:597: undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/cckaCacS.o:/home/hua/source/chenshou_recipes/protobuf/query.pb.h:618: more undefined references to
google::protobuf::internal::kEmptyString' follow
/tmp/cckaCacS.o: In functiongoogle::protobuf::internal::WireFormatLite::Int64Size(long)': /usr/local/include/google/protobuf/wire_format_lite_inl.h:720: undefined reference to
google::protobuf::io::CodedOutputStream::VarintSize64(unsigned long)'
/tmp/cckaCacS.o: In functiongoogle::protobuf::internal::WireFormat::VerifyUTF8String(char const_, int, google::protobuf::internal::WireFormat::Operation)': /usr/local/include/google/protobuf/wire_format.h:295: undefined reference to
google::protobuf::internal::WireFormat::VerifyUTF8StringFallback(char const_, int, google::protobuf::internal::WireFormat::Operation)'
/tmp/cckaCacS.o: In function muduo::Query const* google::protobuf::internal::dynamic_cast_if_available<muduo::Query const*, google::protobuf::Message const*>(google::protobuf::Message const*)': /usr/local/include/google/protobuf/generated_message_reflection.h:394: undefined reference to
typeinfo for google::protobuf::Message'
/tmp/cckaCacS.o: In function google::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Swap(google::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)': /usr/local/include/google/protobuf/repeated_field.h:907: undefined reference to
google::protobuf::internal::RepeatedPtrFieldBase::Swap(google::protobuf::internal::RepeatedPtrFieldBase_)'
/tmp/cckaCacS.o: In function muduo::Answer const_ google::protobuf::internal::dynamic_cast_if_available<muduo::Answer const*, google::protobuf::Message const*>(google::protobuf::Message const_)': /usr/local/include/google/protobuf/generated_message_reflection.h:394: undefined reference to
typeinfo for google::protobuf::Message'
/tmp/cckaCacS.o: In functionmuduo::Empty const_ google::protobuf::internal::dynamic_cast_if_available<muduo::Empty const*, google::protobuf::Message const*>(google::protobuf::Message const_)': /usr/local/include/google/protobuf/generated_message_reflection.h:394: undefined reference to
typeinfo for google::protobuf::Message'
/tmp/cckaCacS.o: In functiongoogle::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::TypeHandler::Type const& google::protobuf::internal::RepeatedPtrFieldBase::Get<google::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::TypeHandler>(int) const': /usr/local/include/google/protobuf/repeated_field.h:659: undefined reference to
google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const_, int)'
/usr/local/include/google/protobuf/repeated_field.h:659: undefined reference to google::protobuf::internal::LogMessage::operator<<(char const*)' /usr/local/include/google/protobuf/repeated_field.h:659: undefined reference to
google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/usr/local/include/google/protobuf/repeated_field.h:659: undefined reference to google::protobuf::internal::LogMessage::~LogMessage()' /usr/local/include/google/protobuf/repeated_field.h:659: undefined reference to
google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/cckaCacS.o: In function google::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::TypeHandler::Type* google::protobuf::internal::RepeatedPtrFieldBase::Add<google::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::TypeHandler>()': /usr/local/include/google/protobuf/repeated_field.h:675: undefined reference to
google::protobuf::internal::RepeatedPtrFieldBase::Reserve(int)'
/usr/local/include/google/protobuf/repeated_field.h:677: undefined reference to google::protobuf::internal::StringTypeHandlerBase::New()' /tmp/cckaCacS.o: In function
void google::protobuf::internal::RepeatedPtrFieldBase::Destroy<google::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits, std::allocator > >::TypeHandler>()':
/usr/local/include/google/protobuf/repeated_field.h:644: undefined reference to google::protobuf::internal::StringTypeHandlerBase::Delete(std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)' /tmp/cckaCacS.o: In function
void google::protobuf::internal::RepeatedPtrFieldBase::MergeFrom<google::protobuf::RepeatedPtrField<std::basic_string<char, std::char_traits, std::allocator > >::TypeHandler>(google::protobuf::internal::RepeatedPtrFieldBase const&)':
/usr/local/include/google/protobuf/repeated_field.h:698: undefined reference to google::protobuf::internal::RepeatedPtrFieldBase::Reserve(int)' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo5EmptyE[vtable for muduo::Empty]+0x20): undefined reference to
google::protobuf::Message::GetTypeName() const'
/tmp/cckaCacS.o:(.rodata._ZTVN5muduo5EmptyE[vtable for muduo::Empty]+0x40): undefined reference to google::protobuf::Message::InitializationErrorString() const' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo5EmptyE[vtable for muduo::Empty]+0x48): undefined reference to
google::protobuf::Message::CheckTypeAndMergeFrom(google::protobuf::MessageLite const&)'
/tmp/cckaCacS.o:(.rodata._ZTVN5muduo5EmptyE[vtable for muduo::Empty]+0x88): undefined reference to google::protobuf::Message::DiscardUnknownFields()' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo5EmptyE[vtable for muduo::Empty]+0x90): undefined reference to
google::protobuf::Message::SpaceUsed() const'
/tmp/cckaCacS.o:(.rodata._ZTVN5muduo6AnswerE[vtable for muduo::Answer]+0x20): undefined reference to google::protobuf::Message::GetTypeName() const' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo6AnswerE[vtable for muduo::Answer]+0x40): undefined reference to
google::protobuf::Message::InitializationErrorString() const'
/tmp/cckaCacS.o:(.rodata._ZTVN5muduo6AnswerE[vtable for muduo::Answer]+0x48): undefined reference to google::protobuf::Message::CheckTypeAndMergeFrom(google::protobuf::MessageLite const&)' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo6AnswerE[vtable for muduo::Answer]+0x88): undefined reference to
google::protobuf::Message::DiscardUnknownFields()'
/tmp/cckaCacS.o:(.rodata._ZTVN5muduo6AnswerE[vtable for muduo::Answer]+0x90): undefined reference to google::protobuf::Message::SpaceUsed() const' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo5QueryE[vtable for muduo::Query]+0x20): undefined reference to
google::protobuf::Message::GetTypeName() const'
/tmp/cckaCacS.o:(.rodata.ZTVN5muduo5QueryE[vtable for muduo::Query]+0x40): undefined reference to google::protobuf::Message::InitializationErrorString() const' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo5QueryE[vtable for muduo::Query]+0x48): undefined reference to
google::protobuf::Message::CheckTypeAndMergeFrom(google::protobuf::MessageLite const&)'
/tmp/cckaCacS.o:(.rodata.ZTVN5muduo5QueryE[vtable for muduo::Query]+0x88): undefined reference to google::protobuf::Message::DiscardUnknownFields()' /tmp/cckaCacS.o:(.rodata._ZTVN5muduo5QueryE[vtable for muduo::Query]+0x90): undefined reference to
google::protobuf::Message::SpaceUsed() const'
/tmp/cckaCacS.o:(.rodata.ZTIN5muduo5EmptyE[typeinfo for muduo::Empty]+0x10): undefined reference to typeinfo for google::protobuf::Message' /tmp/cckaCacS.o:(.rodata._ZTIN5muduo6AnswerE[typeinfo for muduo::Answer]+0x10): undefined reference to
typeinfo for google::protobuf::Message'
/tmp/cckaCacS.o:(.rodata.ZTIN5muduo5QueryE[typeinfo for muduo::Query]+0x10): undefined reference to typeinfo for google::protobuf::Message' /tmp/ccsvWMTv.o: In function
testQuery()':
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:37: undefined reference to typeinfo for google::protobuf::Message' /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:39: undefined reference to
google::protobuf::Message::PrintDebugString() const'
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:40: undefined reference to google::protobuf::Message::DebugString() const' /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:40: undefined reference to
google::protobuf::Message::DebugString() const'
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:44: undefined reference to typeinfo for google::protobuf::Message' /tmp/ccsvWMTv.o: In function
testEmpty()':
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:57: undefined reference to typeinfo for google::protobuf::Message' /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:59: undefined reference to
google::protobuf::Message::PrintDebugString() const'
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:60: undefined reference to google::protobuf::Message::DebugString() const' /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:60: undefined reference to
google::protobuf::Message::DebugString() const'
/tmp/ccsvWMTv.o: In function testAnswer()': /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:85: undefined reference to
typeinfo for google::protobuf::Message'
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:87: undefined reference to google::protobuf::Message::PrintDebugString() const' /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:88: undefined reference to
google::protobuf::Message::DebugString() const'
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:88: undefined reference to google::protobuf::Message::DebugString() const' /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:92: undefined reference to
typeinfo for google::protobuf::Message'
/tmp/ccsvWMTv.o: In function main': /home/hua/source/chenshou_recipes/protobuf/codec_test.cc:98: undefined reference to
google::protobuf::internal::VerifyVersion(int, int, char const)'
/home/hua/source/chenshou_recipes/protobuf/codec_test.cc:109: undefined reference to google::protobuf::ShutdownProtobufLibrary()' /tmp/ccsvWMTv.o: In function
encode(google::protobuf::Message const&)':
/home/hua/source/chenshou_recipes/protobuf/codec.h:47: undefined reference to google::protobuf::MessageLite::AppendToString(std::basic_string<char, std::char_traits<char>, std::allocator<char> >_) const' /home/hua/source/chenshou_recipes/protobuf/codec.h:52: undefined reference to
adler32'
/tmp/ccsvWMTv.o: In functioncreateMessage(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /home/hua/source/chenshou_recipes/protobuf/codec.h:73: undefined reference to
google::protobuf::DescriptorPool::generated_pool()'
/home/hua/source/chenshou_recipes/protobuf/codec.h:73: undefined reference togoogle::protobuf::DescriptorPool::FindMessageTypeByName(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const' /home/hua/source/chenshou_recipes/protobuf/codec.h:77: undefined reference to
google::protobuf::MessageFactory::generated_factory()'
/tmp/ccsvWMTv.o: In functiondecode(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': /home/hua/source/chenshou_recipes/protobuf/codec.h:108: undefined reference to
adler32'
/home/hua/source/chenshou_recipes/protobuf/codec.h:120: undefined reference togoogle::protobuf::MessageLite::ParseFromArray(void const_, int)' /tmp/ccsvWMTv.o: In function
muduo::Query::set_questioner(char const)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:418: undefined reference to google::protobuf::internal::kEmptyString' /tmp/ccsvWMTv.o: In function
muduo::Answer::set_questioner(char const)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:546: undefined reference to google::protobuf::internal::kEmptyString' /tmp/ccsvWMTv.o: In function
muduo::Answer::set_answerer(char const)':
/home/hua/source/chenshou_recipes/protobuf/query.pb.h:604: undefined reference to `google::protobuf::internal::kEmptyString'
collect2: ld returned 1 exit status
make: *** [codec_test] Error 1
and I also tried to link to a custom protobuf installation path (using -L options of g++) and it still won't compile correctly...
请教一下,
https://blog.csdn.net/Solstice/article/details/5864889
这篇提到的吞吐量数据,为啥千兆网卡的吞吐量可以达到几百MB呢?带宽不是只有128MB吗?
运行test8,使用telnet充当客户端,当在telnet中输入quit后,发现会执行Poller::updateChannel()的else分支。
这是为什么呢?
仔细研究了整个套接字的关闭流程:
::poll返回 --将事件放入activeChannel--> 由EventLoop调用handleEvent分发 --readCallback_()--> 进入TcpConnection的handleRead() --n==0执行handleClose()--> TcpServer::removeConnection() --queueInLoop--> TcpServer::connectDestory() --EventLoop::removeChannel() --> Poller::removeChannel()
并没有发现有Poller::updateChannel()被调用
而且发现Poller::updateChannel()的else分支中有 pfd.fd = -channel->fd()-1;
void Poller::updateChannel(Channel* channel)
{
assertInLoopThread();
LOG_TRACE << "fd = " << channel->fd() << " events = " << channel->events();
if (channel->index() < 0) {
...
} else {
// update existing one
assert(channels_.find(channel->fd()) != channels_.end());
assert(channels_[channel->fd()] == channel);
int idx = channel->index();
assert(0 <= idx && idx < static_cast<int>(pollfds_.size()));
struct pollfd& pfd = pollfds_[idx];
assert(pfd.fd == channel->fd() || pfd.fd == -channel->fd()-1);
pfd.events = static_cast<short>(channel->events());
pfd.revents = 0;
// 这里设置了 pfd.fd = -channel->fd()-1;
if (channel->isNoneEvent()) {
// ignore this pollfd
pfd.fd = -channel->fd()-1;
}
}
}
然后在EventLoop::removeChannel有 assert(pfd.fd == -channel->fd()-1 && pfd.events == channel->events());
的操作,
void Poller::removeChannel(Channel* channel)
{
assertInLoopThread();
LOG_TRACE << "fd = " << channel->fd();
assert(channels_.find(channel->fd()) != channels_.end());
assert(channels_[channel->fd()] == channel);
assert(channel->isNoneEvent());
int idx = channel->index();
assert(0 <= idx && idx < static_cast<int>(pollfds_.size()));
const struct pollfd& pfd = pollfds_[idx]; (void)pfd;
// 和这里的 pfd.fd == -channel->fd()-1
assert(pfd.fd == -channel->fd()-1 && pfd.events == channel->events());
size_t n = channels_.erase(channel->fd());
assert(n == 1); (void)n;
if (implicit_cast<size_t>(idx) == pollfds_.size()-1) {
pollfds_.pop_back();
} else {
...
}
}
感觉chenshuo大佬你应该是知道这个问题的,我研究了好一会儿。
chenshuo大佬有时间的话,可以稍微讲解一下吗?(问题可能有点简单,不过实在是没想明白。)
ubuntu 14.04 : kernel 4.4
gcc ver: 7.3.0
boost ver : 1.58
/usr/include/boost/ptr_container/detail/static_move_ptr.hpp:168:57: error: no type named ‘error’ in ‘class boost::ptr_container_detail::static_move_ptr<muduo::detail::FixedBuffer<4000000>, boost::ptr_container_detail::clone_deleter<boost::ptr_container_detail::reversible_ptr_container<boost::ptr_container_detail::sequence_config<muduo::detail::FixedBuffer<4000000>, std::vector<void*, std::allocator<void*> > >, boost::heap_clone_allocator>::null_clone_allocator<false> > >’ typedef typename static_move_ptr<TT, DD>::error type;
To explicitly disable copy ctor and copy assign func of class AsyncLoggingDoubleBuffering can resolve this issue. But why it needs such behavior given the class has already privatly inherited from boost::noncopyable?
Many thanks.
刚刚学到了 s06,channel_->disableAll 为什么在 TcpConnection::handleClose 执行了一次,在TcpConnection::connectDestroyed 又执行了一次?没看到中间有哪几步会影响到 channel_ 的状态啊。
void TimerQueue::handleRead() { ... readTimerfd(timerfd_, now); ... }
陈老师,readTimerfd应该是为了避免level-triggered而调用的吧,为什么我把它注释掉后也不会出现一直触发的问题??
陈老师,你好!
碰到个问题,在使用protobuf时,我看了codec.h里封装的代码,我在测试中碰到如下问题:
比如我有个 AutoReq.proto,它属于package montnets;
调用 const google::protobuf::Descriptor* descriptor =
google::protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName("montnets.AuthReq");
后校验 descriptor 为nullptr, 如果我在调用这个的前面加上 static montnets::AuthReq request; 就能正常。难道一定要在项目中先使用到具体的一个protobuf类之后它才能放入DescriptorPool 池中,这个怎么优化!
谢谢! 附带:我使用的是protobuf 3.4.1
硕哥,eventloop没办法正常退出。如果退出太快的话,EventLoop::quit()执行了,但是EventLoop::loop()读取的quit_还是true
例子:https://github.com/chenshuo/recipes/blob/master/reactor/s03/test6.cc
我的例子:
EventLoopThread loopThread;
EventLoop* loop = loopThread.startLoop();
loop->quit();
printf("exit main().\n");
Counter& Counter::operator=(const Counter& rhs) {
if (this == &rhs)
return *this;
int64_t value;
{
MutexLockGuard lock(rhs.mutex_);
value = rhs.value_;
}
MutexLockGuard lock(mutex_);
value_ = value;
return *this;
}
void swap(Counter& a, Counter& b) {
int64_t value;
{
MutexLockGuard lock(a.mutex_);
value = a.value_;
}
{
MutexLockGuard lock(b.mutex_);
std::swap(value, b.value_);
}
MutexLockGuard lock(a.mutex_);
a.value_ = value;
}
hi, I'm reading your book about the "muduo". And seems found some issue,the version 2 of the thread factory haven't put the newly created stock into the map,the reason is that the pStock will be deconstructed when it leaves "get" function.Here is your code:
I wrote a test and this test will output twice "hello NOT EXIST"
#include <string>
#include <memory>
#include <iostream>
class Stock {
public:
Stock(const std::string &) {}
};
//if pStock defined as a global variable,it will be ok.
class StockFactory// : std::noncopyable
{
public:
std::shared_ptr<Stock> get(const std::string& key)
{
std::shared_ptr<Stock> pStock;
std::weak_ptr<Stock>& wkStock = stocks_[key];
pStock = wkStock.lock();
if (!pStock)
{
std::cout << key << " NOT EXIST" << std::endl;
pStock.reset(new Stock(key));
wkStock = pStock;
} else {
std::cout << key << " EXIST" << std::endl;
}
return pStock;
}
private:
std::map<std::string, std::weak_ptr<Stock> > stocks_;
};
int main() {
StockFactory f;
f.get("hello");
f.get("hello");
}
Wonderful example, just one comment, you hope to check if FUNC is the function type needed at compile time, how about use type traits? like:
// replace if(0) { xxxx } with following statement:
static_assert(std::is_same(FUNC, std::function<void(const State&)>)::value, "FUNC must be type of std::function<void(const State&)>");
static int findEntry(const EntryList& entries, const string& stock);
static MapPtr parseData(const string& message);
陈老师。这两个好像没实现。。。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.