ubuntu16 boost.04可以用boost1.54吗

How to Install boost on Ubuntu? - Stack Overflow
Join Stack Overflow to learn, share knowledge, and build your career.
or sign in with
I'm on Ubuntu, and I want to install Boost.
I tried with
sudo apt-get install boost
But there was no such package. What is the best way to install boost on Ubuntu?
73.8k33295246
1,81521021
You can use apt-get command (requires sudo)
sudo apt-get install libboost-all-dev
Or you can call
aptitude search boost
find packages you need and install them using the apt-get command.
6,38311014
Get the version of Boost that you require. This is for 1.55 but feel free to change or manually download yourself:
wget -O boost_1_55_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download
tar xzvf boost_1_55_0.tar.gz
cd boost_1_55_0/
Get the required libraries, main ones are icu for boost::regex support:
sudo apt-get update
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev libboost-all-dev
Boost's bootstrap setup:
./bootstrap.sh --prefix=/usr/
Then build it with:
and eventually install it:
sudo ./b2 install
12.2k95177
Installing Boost on Ubuntu with an example of using boost array:
Install libboost-all-dev and aptitude
sudo apt-get install libboost-all-dev
sudo apt-get install aptitude
aptitude search boost
Then paste this into a C++ file called main.cpp:
#include &iostream&
#include &boost/array.hpp&
int main(){
boost::array&int, 4& arr = {{1,2,3,4}};
cout && "hi" && arr[0];
Compile like this:
g++ -o s main.cpp
Run it like this:
Program prints:
73.8k33295246
Get the version of Boost that you require. This is for 1.55 but feel free to change or manually download yourself:
wget -O boost_1_55_0.tar.gz http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download
tar xzvf boost_1_55_0.tar.gz
cd boost_1_55_0/
Get the required libraries, main ones are icu for boost::regex support:
sudo apt-get update
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev
Boost's bootstrap setup:
./bootstrap.sh --prefix=/usr/local
If we want MPI then we need to set the flag in the user-config.jam file:
user_configFile=`find $PWD -name user-config.jam`
echo "" && $user_configFile
Find the maximum number of physical cores:
n=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
Install boost in parallel:
sudo ./b2 --with=all -j $n install
Assumes you have /usr/local/lib setup already. if not, you can add it to your LD LIBRARY PATH:
sudo sh -c 'echo "/usr/local/lib" && /etc/ld.so.conf.d/local.conf'
Reset the ldconfig:
sudo ldconfig
Actually you don`t need "install" or "compile" anything before using boost in your project. You can just download and extract the boost library to any location on your machine, which is usually like /usr/local/.
When you compile your code, you can just indicate the compiler where to find the libraries by -I. For example, g++ -I /usr/local/boost_1_59_0 xxx.hpp
Hope this helps.
For Windows 10 Ubuntu application:
sudo apt-get install libboost-all-dev
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled17:40 提问
caffe安装过程中boost::未定义问题
各位大神,我在ubuntu16.04中安装caffe,进行到make all的时候报了如下错误:
CXX/LD -o .build_release/test/test_all.testbin src/caffe/test/test_caffe_main.cpp
.build_release/src/caffe/test/test_benchmark.o:在函数‘void boost::this_thread::sleep &(boost::date_time::subsecond_duration const&)’中:
test_benchmark.cpp:(.text._ZN5boost11this_thread5sleepINS_9date_time18subsecond_durationINS_10posix_time13time_durationELl1000EEEEEvRKT_[_ZN5boost11this_thread5sleepINS_9date_time18subsecond_durationINS_10posix_time13time_durationELl1000EEEEEvRKT_]+0x25a):对‘boost::this_thread::hidden::sleep_until(timespec const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::thread::start_thread_noexcept()’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::thread::detach()’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::detail::thread_data_base::~thread_data_base()’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::thread::native_handle()’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::thread::interrupt()’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::this_thread::interruption_point()’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::detail::set_tss_data(void const*, boost::shared_ptrboost::detail::tss_cleanup_function, void*, bool)’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::thread::interruption_requested() const’未定义的引用
.build_release/lib/libcaffe.so:对‘vtable for boost::detail::thread_data_base’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::detail::get_current_thread_data()’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::thread::joinable() const’未定义的引用
.build_release/lib/libcaffe.so:对‘typeinfo for boost::detail::thread_data_base’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::detail::get_tss_data(void const*)’未定义的引用
.build_release/lib/libcaffe.so:对‘boost::thread::join_noexcept()’未定义的引用
collect2: error: ld returned 1 exit status
Makefile:603: recipe for target '.build_release/test/test_all.testbin' failed
make: *** [.build_release/test/test_all.testbin] Error 1
一直没有找到有效的解决办法.麻烦遇到过的朋友指点迷津.定重谢!
按赞数排序
加上 -DBOOST_THREAD_USE_LIB=1
编译参数看看
通常是版本不对引起,试着换个版本的boost
您说的是Makefile.config里面这个么?
Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
我看了下 /usr/lib /路径下有libboost_thread.so libboost_system.so这些文件, /usr/local/lib路径下有libboost_graph.so libboost_regex.so libboost_thread.so...这些文件,但是还是出现上面的错误.
加到编译路径这个,我理解的是不是不对.
这个格式好点,方便您看.
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐博主最新文章
博主热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)直接执行命令:
&sudo apt-get& install libboost-dev
创建一个 boost_test.cpp 文件,写入
#include&iostream&
#include&boost/lexical_cast.hpp&
int main()
int a = boost::lexical_cast&int&("<span style="color: #");
std::cout && a &&std::
return <span style="color: #;
执行命令:
g++ boost_test.cpp -o boost_test
./boost_test
最终结果为:
参考教程:
------------------------------------------------------------------------------------------------------------
阅读(...) 评论()博主最新文章
博主热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)

我要回帖

更多关于 ubuntu boost 安装 的文章

 

随机推荐