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

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

问题描述

我试图编译code和我得到的错误

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

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

我用G ++在Ubuntu 12.04。虽然我已经做了一些C ++编程我是新来的Linux开发环境(仅用于集成开发环境previously)。

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目录。但是,我没有任何提振文件夹中有。

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.

我需要做什么改变?

推荐答案

如果您已经安装了回购提振只使用 -lboost_program_options 这就够了。

如果您在其他一些库安装Boost库,您需要通过指定directoty -L /路径/要/ 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

在CMake的你可以指定设置(CMAKE_CXX_FLAGS-lboost_program_options)

In CMake you may specify 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天全站免登陆