undefined reference to `boost::program_options::options_description::m_default_line_length#39;(对`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
在 CMake 中你可以指定 set(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'的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:对`boost::program_options::options_description::m_default_line_length'的未定义引用


基础教程推荐
- 运算符重载的基本规则和习语是什么? 2022-10-31
- C++,'if' 表达式中的变量声明 2021-01-01
- 设计字符串本地化的最佳方法 2022-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17