c++ - unresolved symbols while linking boost program options -


a user of project reported error me. cannot reproduce on computer or lab's server, ask here.

the project uses cmake generate build environment. uses findboost utility (provided cmake) find boost resources.

on beginning, user said while linking final programs, compiler provided "/usr/lib64/lib64/libboost_xxx.so", instead of correct "/usr/lib64/libboost_xxx.so". failed find why cmake generated such weird library location, , asked him manually set variable boost_libraries, , print them:

boost libraries are: /usr/lib64/libboost_thread-mt.so;/usr/lib64/libboost_program_options-mt.so;/usr/lib64/libboost_filesystem-mt.so 

things seem correct. compilation successful. when goes linking, program cries many undefined symbols:

cmakefiles/ht-filter.dir/ht-filter.cpp.o: in function `parse_options(int, char**)': /public/home/yli/downloads/htqc-0.15.0-source/ht-filter.cpp:43: undefined reference `boost::program_options::options_description::options_description(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int)' ...... /usr/local/include/boost/program_options/errors.hpp:372: undefined reference `boost::program_options::validation_error::get_template(boost::program_options::validation_error::kind_t)' 

this 2 typical of so-many errors: 1 locates source code, other locates boost's header. in corresponding line of source code, created options_description object

// renamed boost::program_options opt opt::options_description opt_main("options:"); 

the os of user centos 6.2, , boost version 1.50.0 similiar 1 in computer. version of cmake of user 2.8.11 same mine.

while using cmake's find_package boost, can give few hints cmake may find correct library, such as:

set(boost_use_static_libs off) set(boost_use_multithreaded on) set(boost_use_static_runtime off)  set(boost_root "/usr")  find_package(boost 1.50.0)  message(status "boost_include_dirs: ${boost_include_dirs}") message(status "boost_library_dirs: ${boost_library_dirs}") 

also if linking dynamic libs make sure let boost headers know (i think shouldn't mess order in here):

link_directories(${boost_library_dirs})  include_directories(${boost_include_dirs})  add_definitions( -dboost_all_dyn_link ) 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -