简体   繁体   中英

Endian conversion using boost

I followed the so called manual of boost for converting (swapping) the endian.

Despite their code is more readable than their manual, could some one please explain how I should fix the following code?

hh.cpp

#include <iostream>
#include <boost/array.hpp>
#include <boost/endian/conversion.hpp>

int main () {

  std::cout << boost::endian::endian_reverse(5);

  return 0;
}

make:

g++ hh.cpp -o hh -Wall -Wconversion -Wfatal-errors -Wextra -std=c++11 -lboost_system -lrt  -lboost_wave -larmadillo -lboost_thread

error:

hh.cpp:3:39: fatal error: boost/endian/conversion.hpp: No such file or directory
 #include <boost/endian/conversion.hpp>
                                       ^
compilation terminated.

Update

Other boost headers are included fine. Only endian has problem.

ls /usr/include/boost/*

http://pastebin.com/nCciracE


Update

$ cat /usr/include/boost/version.hpp

Result:

//  Boost version.hpp configuration header file  ------------------------------//

//  (C) Copyright John maddock 1999. Distributed under the Boost
//  Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/config for documentation

#ifndef BOOST_VERSION_HPP
#define BOOST_VERSION_HPP

//
//  Caution, this is the only boost header that is guarenteed
//  to change with every boost release, including this header
//  will cause a recompile every time a new boost version is
//  released.
//
//  BOOST_VERSION % 100 is the patch level
//  BOOST_VERSION / 100 % 1000 is the minor version
//  BOOST_VERSION / 100000 is the major version

#define BOOST_VERSION 105400

//
//  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
//  but as a *string* in the form "x_y[_z]" where x is the major version
//  number, y is the minor version number, and z is the patch level if not 0.
//  This is used by <config/auto_link.hpp> to select which library version to link to.

#define BOOST_LIB_VERSION "1_54"

#endif

endian library was introduced in boost version 1.58 . You have 1.54, there is no endian library in this release. You should either update boost to 1.58+, either no use endian library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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