C++ boost::程序选项未定义引用
我使用ubuntu 10.04和libboost1.40C++ boost::程序选项未定义引用,c++,boost,linker-errors,ubuntu-10.04,undefined-reference,C++,Boost,Linker Errors,Ubuntu 10.04,Undefined Reference,我使用ubuntu 10.04和libboost1.40 ls -l /usr/lib | grep boost_pro -rw-r--r-- 1 root root 640800 2010-04-01 05:19 libboost_program_options.a lrwxrwxrwx 1 root root 26 2011-11-03 22:40 libboost_program_options-mt.a -> l
ls -l /usr/lib | grep boost_pro
-rw-r--r-- 1 root root 640800 2010-04-01 05:19 libboost_program_options.a
lrwxrwxrwx 1 root root 26 2011-11-03 22:40 libboost_program_options-mt.a -> libboost_program_options.a
lrwxrwxrwx 1 root root 34 2011-11-03 22:40 libboost_program_options-mt.so -> libboost_program_options.so.1.40.0
lrwxrwxrwx 1 root root 34 2011-11-03 22:40 libboost_program_options.so -> libboost_program_options.so.1.40.0
-rw-r--r-- 1 root root 289336 2010-04-01 05:19 libboost_program_options.so.1.40.0
这是main.cpp(仅用于测试)
这里只有一个couse的原型。
有什么想法吗?显然,有一个双参数构造函数的原型,它接受两个
无符号int
s,两个都有一个默认值。因此,这将成为默认构造函数,在创建a
时使用。它是:
但是,这是在Boost 1.42和您的版本1.40中添加的
因此,我认为您设法用更新的版本覆盖了Ubuntu为您安装的标题,但没有更新/usr/lib
中的库。请尝试卸载并重新安装该软件包
如果您需要比1.40更新的Boost,请升级您的Ubuntu,或者卸载所有与Boost相关的软件包,然后在
/usr/local
中从源代码重新安装。包管理器将远离/usr/local
中的任何内容,因此这将确保此类问题不会再次发生。显然,有一个双参数构造函数的原型,它接受两个无符号int
s,两个都具有默认值。因此,这将成为默认构造函数,在创建a
时使用。它是:
但是,这是在Boost 1.42和您的版本1.40中添加的
因此,我认为您设法用更新的版本覆盖了Ubuntu为您安装的标题,但没有更新/usr/lib
中的库。请尝试卸载并重新安装该软件包
如果您需要比1.40更新的Boost,请升级您的Ubuntu,或者卸载所有与Boost相关的软件包,然后在/usr/local
中从源代码重新安装。包管理器将远离/usr/local
中的任何内容,因此这将确保此类故障不会再次发生
#include <string>
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/program_options/options_description.hpp>
//---------------------------------------------------------------------
int main(int argc,char** argv)
{
boost::gregorian::date now(boost::gregorian::day_clock::local_day());
//is works fine
std::cout<<boost::gregorian::to_iso_string(now)<<std::endl;
boost::program_options::options_description a; //but here i get an error when the constructor have started
return 0;
}
g++ -o main -lboost_date_time -lboost_program_options main.cpp && ./main
/tmp/cc3RJHsG.o: In function `main':
main.cpp:(.text+0x81): undefined reference to `boost::program_options::options_description::options_description(unsigned int, unsigned int)'
collect2: ld returned 1 exit status
find /usr/include/ -name "*description*"
/usr/include/boost/program_options/options_description.hpp
options_description(unsigned = m_default_line_length,
unsigned = m_default_line_length/2);