编译sogou的workflow时遇到的问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
g++ -std=c++11 -Wall tutorial/tutorial-01-wget.cc -I _include/ -o twget
报错:
/data/tmp/tutorial-01-wget-f47913.o: In function `wget_callback(WFNetworkTask<protocol::HttpRequest, protocol::HttpResponse>*)':
tutorial/tutorial-01-wget.cc:(.text+0x29c): undefined reference to `protocol::HttpHeaderCursor::next(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
tutorial/tutorial-01-wget.cc:(.text+0x428): undefined reference to `protocol::HttpHeaderCursor::next(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
/data/tmp/tutorial-01-wget-f47913.o: In function `main':
tutorial/tutorial-01-wget.cc:(.text+0x79e): undefined reference to `WFTaskFactory::create_http_task(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, std::function<void (WFNetworkTask<protocol::HttpRequest, protocol::HttpResponse>*)>)'
/data/tmp/tutorial-01-wget-f47913.o: In function `protocol::RedisValue::~RedisValue()':
tutorial/tutorial-01-wget.cc:(.text._ZN8protocol10RedisValueD2Ev[_ZN8protocol10RedisValueD2Ev]+0x14): undefined reference to `protocol::RedisValue::free_data()'
/data/tmp/tutorial-01-wget-f47913.o: In function `EncodeStream::~EncodeStream()':
tutorial/tutorial-01-wget.cc:(.text._ZN12EncodeStreamD2Ev[_ZN12EncodeStreamD2Ev]+0xd): undefined reference to `EncodeStream::clear_buffer()'
/data/tmp/tutorial-01-wget-f47913.o: In function `protocol::RedisMessage::~RedisMessage()':
tutorial/tutorial-01-wget.cc:(.text._ZN8protocol12RedisMessageD2Ev[_ZN8protocol12RedisMessageD2Ev]+0x27): undefined reference to `redis_parser_deinit'
/data/tmp/tutorial-01-wget-f47913.o: In function `protocol::HttpMessage::get_parsed_body(void const**, unsigned long*) const':
tutorial/tutorial-01-wget.cc:(.text._ZNK8protocol11HttpMessage15get_parsed_bodyEPPKvPm[_ZNK8protocol11HttpMessage15get_parsed_bodyEPPKvPm]+0x25): undefined reference to `http_parser_get_body'
/data/tmp/tutorial-01-wget-f47913.o: In function `protocol::HttpMessage::add_header_pair(char const*, char const*)':
tutorial/tutorial-01-wget.cc:(.text._ZN8protocol11HttpMessage15add_header_pairEPKcS2_[_ZN8protocol11HttpMessage15add_header_pairEPKcS2_]+0x5d): undefined reference to `http_parser_add_header'
/data/tmp/tutorial-01-wget-f47913.o: In function `WFCounterTask::done()':
tutorial/tutorial-01-wget.cc:(.text._ZN13WFCounterTask4doneEv[_ZN13WFCounterTask4doneEv]+0x74): undefined reference to `SeriesWork::pop()'
/data/tmp/tutorial-01-wget-f47913.o: In function `WFCounterTask::count()':
tutorial/tutorial-01-wget.cc:(.text._ZN13WFCounterTask5countEv[_ZN13WFCounterTask5countEv]+0x3b): undefined reference to `SubTask::subtask_done()'
/data/tmp/tutorial-01-wget-f47913.o: In function `WFGenericTask::dispatch()':
tutorial/tutorial-01-wget.cc:(.text._ZN13WFGenericTask8dispatchEv[_ZN13WFGenericTask8dispatchEv]+0x18): undefined reference to `SubTask::subtask_done()'
/data/tmp/tutorial-01-wget-f47913.o: In function `WFGenericTask::done()':
tutorial/tutorial-01-wget.cc:(.text._ZN13WFGenericTask4doneEv[_ZN13WFGenericTask4doneEv]+0x43): undefined reference to `SeriesWork::pop()'
/data/tmp/tutorial-01-wget-f47913.o: In function `Workflow::start_series_work(SubTask*, std::function<void (SeriesWork const*)>)':
tutorial/tutorial-01-wget.cc:(.text._ZN8Workflow17start_series_workEP7SubTaskSt8functionIFvPK10SeriesWorkEE[_ZN8Workflow17start_series_workEP7SubTaskSt8functionIFvPK10SeriesWorkEE]+0x47): undefined reference to `SeriesWork::SeriesWork(SubTask*, std::function<void (SeriesWork const*)>&&)'
/data/tmp/tutorial-01-wget-f47913.o: In function `WFFuture<void>::wait() const':
tutorial/tutorial-01-wget.cc:(.text._ZNK8WFFutureIvE4waitEv[_ZNK8WFFutureIvE4waitEv]+0x49): undefined reference to `WFGlobal::get_scheduler()'
tutorial/tutorial-01-wget.cc:(.text._ZNK8WFFutureIvE4waitEv[_ZNK8WFFutureIvE4waitEv]+0x6c): undefined reference to `WFGlobal::sync_operation_begin()'
tutorial/tutorial-01-wget.cc:(.text._ZNK8WFFutureIvE4waitEv[_ZNK8WFFutureIvE4waitEv]+0x87): undefined reference to `WFGlobal::sync_operation_end()'
/data/tmp/tutorial-01-wget-f47913.o: In function `CommScheduler::is_handler_thread()':
tutorial/tutorial-01-wget.cc:(.text._ZN13CommScheduler17is_handler_threadEv[_ZN13CommScheduler17is_handler_threadEv]+0x15): undefined reference to `Communicator::is_handler_thread()'
/data/tmp/tutorial-01-wget-f47913.o:(.rodata._ZTVN8protocol12RedisMessageE[_ZTVN8protocol12RedisMessageE]+0x10): undefined reference to `protocol::RedisMessage::encode(iovec*, int)'
/data/tmp/tutorial-01-wget-f47913.o:(.rodata._ZTVN8protocol12RedisMessageE[_ZTVN8protocol12RedisMessageE]+0x28): undefined reference to `protocol::RedisMessage::append(void const*, unsigned long*)'
/data/tmp/tutorial-01-wget-f47913.o:(.rodata._ZTVN8protocol12RedisMessageE[_ZTVN8protocol12RedisMessageE]+0x48): undefined reference to `non-virtual thunk to protocol::RedisMessage::append(void const*, unsigned long*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

各种undefined

解决:

1
g++  -std=c++11 -Wall tutorial/tutorial-01-wget.cc  -I _include/ -L _lib -lworkflow -lssl -lcrypto -lpthread  -o twget

加上后面的选项就可以了