2017-11-21 6 views
-2

라즈베리 Pi2에서 컴파일 된 작은 응용 프로그램을 작성했습니다. 프로그램은 부스트에서 프로그램 옵션을 사용했습니다. 파이가 죽었으므로 새로운 파이 3에서이 앱을 실행하고 싶습니다. 컴파일/링킹은 문제없이 작동합니다. 응용 프로그램을 시작하면 세그먼트 화 오류가 발생합니다. 코드의부스트 프로그램 옵션에서 C++을 사용하면 세그먼트 화 오류가 발생합니다

일부 부품 :

v_AppName = boost::filesystem::basename(argv[0]); 
po::options_description desc("Opties"); 
ProgramOptions(desc); 
po::variables_map vm; 
try 
{ 
    po::store(po::parse_command_line(argc, argv, desc), vm); 
    .... 

프로그램 옵션 기능 (문제를 일으키는 부분) :

void Client::ProgramOptions(boost::program_options::options_description & l_Desc) 
{ 
    l_Desc.add_options() 
    ("help,h", "Show help") 
    ("view,v", "View something") 
    ("TEST", po::value<int>(), "TEST"); 
} 

포 :: 값()에서 가진 마지막 줄이 원인 추락. 이 줄을 제거하면 프로그램이 실행됩니다.

스택 트레이스 :

#0 0x76f17f24 in 
    boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool) const() from /usr/lib/arm-linux-gnueabihf/libboost_program_options.so.1.55.0 
No symbol table info available. 
#1 0x76f13220 in boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)() 
    from /usr/lib/arm-linux-gnueabihf/libboost_program_options.so.1.55.0 
No symbol table info available. 
#2 0x0003cae0 in warmte::Client::Client (this=0x7efff618, argc=1, argv=0x7efff794) at src/client.cpp:38 
    timeout = {<boost::date_time::base_time<boost::posix_time::ptime, boost::date_time::counted_time_system<boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config> > >> = {<boost::operators_impl::less_than_comparable<boost::posix_time::ptime, boost::operators_impl::equality_comparable<boost::posix_time::ptime, boost::posix_time::ptime, boost::operators_impl::operators_detail::empty_base<boost::posix_time::ptime>, boost::operators_impl::operators_detail::false_t>, boost::operators_impl::operators_detail::empty_base<boost::posix_time::ptime>, boost::operators_impl::operators_detail::true_t>> = {<boost::operators_impl::less_than_comparable1<boost::posix_time::ptime, boost::operators_impl::equality_comparable<boost::posix_time::ptime, boost::posix_time::ptime, boost::operators_impl::operators_detail::empty_base<boost::posix_time::ptime>, boost::operators_impl::operators_detail::false_t> >> = {<boost::operators_impl::equality_comparable<boost::posix_time::ptime, boost::posix_time::ptime, boost::operators_impl::operators_detail::empty_base<boost::posix_time::ptime>, boost::operators_impl::operators_detail::false_t>> = {<boost::operators_impl::equality_comparable1<boost::posix_time::ptime, boost::operators_impl::operators_detail::empty_base<boost::posix_time::ptime> >> = {<boost::operators_impl::operators_detail::empty_base<boost::posix_time::ptime>> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, <No data fields>}, time_ = {time_count_ = { 
      value_ = 8569444509916594175}}}, <No data fields>} 
    desc = {static m_default_line_length = 80, m_caption = "Opties", m_line_length = 80, m_min_description_length = 40, 
     m_options = std::vector of length 3, capacity 4 = {{px = 0x6d168, pn = {pi_ = 0x6d980}}, {px = 0x6d188, pn = {pi_ = 0x6f588}}, {px = 0x6f628, 
      pn = {pi_ = 0x6f690}}}, belong_to_group = std::vector<bool> of length 3, capacity 32 = {0, 0, 0}, 
     groups = std::vector of length 0, capacity 0} 
    vm = <incomplete type> 
#3 0x0003c92c in main (argc=1, argv=0x7efff794) at src/client.cpp:17 
    client = {_vptr.Client = 0x57418 <vtable for warmte::Client+8>, vp_Shm = 0x0, vp_Region = 0x0, v_AppName = "warmteclient", l_Index = 0, 
     l_Result = 1} 
+1

Pi3 용으로 컴파일 된 라이브러리 대신 기존 라이브러리에 연결했을 수 있습니다. – chris

+0

via sudo apt-get install libboost1.50-all 또는 'sudo apt-get install libboost1.55-all'을 설치하십시오. –

+0

부스트 1.64.0과 1.65.1을 사용해 보았습니다. 둘 다 C++ 11 플래그를 사용하여 빌드했습니다 (응용 프로그램에서 C++을 사용하기 때문에). ,. 둘 다 작동하지 않았다. 그러나 올바른 라이브러리에 연결되어 있는지 확실하지 않습니다. 어떻게 확인할 수 있습니까? –

답변

0

좋아, 내가 잘못된 라이브러리와 링크 .... 라스베리에 설치된 부스트 라이브러리에 끝날 것이다는/usr/

그래서 내가 추가 lib 디렉토리/지역 -L/usr/local/lib/을 링커에 연결하고 LD_LIBRARY_PATH/usr/local/lib/으로 변경합니다. 이 경로가 기본적으로 추가되지 않는 이유는 여전히 확실하지 않습니다.