简体   繁体   English

在Ubuntu中编译C ++ boost dynamic_bitset代码

[英]Compiling C++ boost dynamic_bitset code in Ubuntu

I have used boost's dynamic_bitset in my code. 我在代码中使用了boost的dynamic_bitset。 I wanted to know if I should include any boost library for the code. 我想知道是否应该为该代码包括任何Boost库。 I read that we just have to include the boost path in the include directives and boost should work fine ( this link ). 我读到我们只需要在include伪指令中包含boost路径,并且boost应该可以正常工作( 此链接 )。

But when I try to compile my code, I get the following error. 但是,当我尝试编译代码时,出现以下错误。

boost/dynamic_bitset/dynamic_bitset.hpp: No such file or directory boost / dynamic_bitset / dynamic_bitset.hpp:无此类文件或目录

Here is a simple boost code that makes use of dynamic_bit. 这是一个利用dynamic_bit的简单提升代码。

    #include <iostream>
    #include <boost/dynamic_bitset.hpp>
//  Also tried giving the entire boost path
//  #include "/home/user_name/BOOST_CPP/boost_1_50_0/boost_1_50_0/boost/dynamic_bitset.hpp"
    using namespace std;
    int main(int argc, char* argv[])
    {
        cout<<"Welcome to Boost"<<endl;
        boost::dynamic_bitset<> x(10);
        return 0;
    }

[edit] I compiled using g++ boost_hello.cpp Am I missing something? [edit]我使用g++ boost_hello.cpp编译我是否缺少某些内容? Where I can I find what libraries I should include for compiling boost code.? 在哪里可以找到应包含哪些库来编译Boost代码?

PS: I followed Jedf's blog for installing boost libraries at it was successful. PS:我跟随Jedf的博客成功安装了boost库。

Most likely your include directive is not correct. 您的include指令很可能不正确。 Your error seems to indicate that the #include <boost/dynamic_bitset.hpp> is working, however, that header does #include "boost/dynamic_bitset/dynamic_bitset.hpp" and that is the header your error is complaining about. 您的错误似乎表明#include <boost/dynamic_bitset.hpp>正在运行,但是,标头确实包含#include "boost/dynamic_bitset/dynamic_bitset.hpp" ,这就是您的错误所抱怨的标头。

I'm assuming you're using g++, most likely you need something like g++ -I /home/user_name/BOOST_CPP/boost_1_50_0/boost_1_50_0/ in your compilation command line. 我假设您使用的是g ++,最有可能需要在编译命令行中使用g++ -I /home/user_name/BOOST_CPP/boost_1_50_0/boost_1_50_0/

If you'll show the command you're using to compile we can probably tell for sure. 如果您将显示用于编译的命令,我们可能可以肯定地说出来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM