本文主要是介绍Protobuf调用Utf8DebugString()发生coredump问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Protobuf调用Utf8DebugString()发生coredump
概述
-> % ./test
GOOGLE_PROTOBUF_VERSION:3012003
terminate called after throwing an instance of 'std::system_error'what(): Unknown error -1
[1] 3303214 abort (core dumped) ./test
CMakeLists.txt
project(test)
include_directories(./${THIRD_PART_PATH}/protobuf/protobuf_3.12.3/include${THIRD_PART_PATH}
)
link_directories(${THIRD_PART_PATH}/protobuf/protobuf_3.12.3/lib
)
add_executable(test test.cpp example.pb.cc planning.pb.cc RawInsParkingSpace.pb.cc)
target_link_libraries(test protobuf)
src
#include <iostream>
#include <fstream>#include "planning.pb.h"void test2() {Planning pts;pts.set_tick(152);pts.set_timestamp(155);std::cout << pts.tick() << std::endl;std::cout << pts.Utf8DebugString() << std::endl;
}int main() { std::cout <<"GOOGLE_PROTOBUF_VERSION:" << GOOGLE_PROTOBUF_VERSION << std::endl;test2(); return 0;
}
原因
编译时需要链接 pthread
target_link_libraries(test protobuf pthread)
这篇关于Protobuf调用Utf8DebugString()发生coredump问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!