未定义引用`boost :: program_options :: options_description :: m_default_line_length' [英] undefined reference to `boost::program_options::options_description::m_default_line_length'

查看:1693
本文介绍了未定义引用`boost :: program_options :: options_description :: m_default_line_length'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译代码,并收到错误

I am trying to compile a code and I get the error


未定义引用 boost :: program_options :: options_description :: m_default_line_length

我在Ubuntu 12.04中使用g ++。虽然我已经做了一些C ++编程,我是Linux开发环境的新手(以前只使用IDE)。

I use g++ in Ubuntu 12.04. Although I have done some C++ programming I am new to the Linux development environment (used only IDEs previously).

所以我做了一个基本的搜索这个麻烦,发现一些链接问题。我不太明白他们,因为我是一个新手。阅读一些解决方案进一步困惑我。我的boost库文件夹在 / usr / include 。一些解决方案说它应该在 / usr / lib 。但我没有任何boost文件夹。

So I did a basic search for this trouble, and found about some linking issues. I didn't quite understand them as I am a newbie. Reading some of those solutions confused me further. My boost library folder is in /usr/include. Some solutions says that it should be in /usr/lib. But I don't have any boost folder there.

我需要改变什么?

推荐答案

如果你从repo安装boost,只需使用 -lboost_program_options 就足够了。

如果你安装了boost库一些其他库,你需要指定由 -L / path / to / lib

If you have installed boost from repo just use -lboost_program_options that will suffice.
If you installed boost libraries in some other library, you need to specify that directoty by -L/path/to/lib

可以指定 set(CMAKE_CXX_FLAGS-lboost_program_options)

但是对于CMake,应该使用

However with CMake you should use

FIND_PACKAGE(Boost COMPONENTS program_options REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(target ${Boost_LIBRARIES})

这篇关于未定义引用`boost :: program_options :: options_description :: m_default_line_length'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆