Linux(centos)编译安装boost

 理论上,本文适用于boost的各个版本,尤其是最新版本1.48.0;适用于各种C++编译器,如VC6.0(部分库不支持),VS2003,VS2005,VS2008,VS2010,gcc,C++ Builder等。

1.下载boost源文件

http://www.boost.org/users/download/ 

2.安装

cd /home/boost_1_48_0/
首先需要编译bjam: ./bootstrap.sh --prefix=/home/boost-1.48.0/sdk/  设置库安装路径

通过bjam编码boost库: ./bjam  install


3.设置环境变量
        在/etc/profile.d新建可执行文件boost.sh,添加文件内容:

#!/bin/sh
BOOST_INCLUDE=/home/boost-1.48.0/sdk/include/boost 
BOOST_LIB==/home/boost-1.48.0/sdk/lib
export BOOST_INCLUDE BOOST_LIB 


命令行执行:source /etc/profile.d/boost.sh
        以后在编译程序时,只需要用:-I$BOOST_INCLUDE -L$BOOST_LIB 即可,还要使用-l指定了链接库。

 

然后, /etc/ld.so.conf 文件添加so库的环境变量 /home/boost-1.48.0/sdk/lib(主要关键问题)

修改完成后,通过ldconfig命令进行重启



4.遇到的问题及解决方案
安装过程出现很多和bz及python库相关的错误,解决方案如下

命令方式

sudo apt-get install libbz2-dev    yum install python-dev
或
yum install libbz2-dev   yum install python-dev

图像界面方式

   点击Applications---->Add/Remove Software 去安装这个包文件


PS 安装过程中的错误:

libs/iostreams/src/bzip2.cpp:20:56: error: bzlib.h: 没有那个文件或目录
libs/iostreams/src/bzip2.cpp:31: error: ‘BZ_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:32: error: ‘BZ_RUN_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:33: error: ‘BZ_FLUSH_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:34: error: ‘BZ_FINISH_OK’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:35: error: ‘BZ_STREAM_END’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:36: error: ‘BZ_SEQUENCE_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:37: error: ‘BZ_PARAM_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:38: error: ‘BZ_MEM_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:39: error: ‘BZ_DATA_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:40: error: ‘BZ_DATA_ERROR_MAGIC’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:41: error: ‘BZ_IO_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:42: error: ‘BZ_UNEXPECTED_EOF’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:43: error: ‘BZ_OUTBUFF_FULL’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:44: error: ‘BZ_CONFIG_ERROR’ was not declared in this scope
libs/iostreams/src/bzip2.cpp:48: error: ‘BZ_FINISH’ was not declared in this scope
//mostly like above....

 

 

./boost/python/detail/wrap_python.hpp:50:23: error: pyconfig.h: No such file or directory
./boost/python/detail/wrap_python.hpp:75:24: error: patchlevel.h: No such file or directory
./boost/python/detail/wrap_python.hpp:78:2: error: #error Python 2.2 or higher is required for this version of Boost.Python.
./boost/python/detail/wrap_python.hpp:142:21: error: Python.h: No such file or directory
./boost/python/instance_holder.hpp:34: error: ‘PyObject’ has not been declared
./boost/python/instance_holder.hpp:41: error: expected ‘;’ before ‘(’ token
./boost/python/instance_holder.hpp:45: error: ‘PyObject’ has not been declared
./boost/python/detail/wrapper_base.hpp:21: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:23: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:30: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:34: error: expected initializer before ‘*’ token
./boost/python/detail/wrapper_base.hpp:43: error: ‘PyObject’ has not been declared
./boost/python/detail/wrapper_base.hpp:44: error: ISO C++ forbids declaration of ‘PyObject’ with no type
./boost/python/detail/wrapper_base.hpp:44: error: ‘PyObject’ is neither function nor member function; cannot be declared friend

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
以下是在 CentOS 9 上安装 MySQL 8.0 源码的步骤: 1. 首先,你需要安装必要的依赖项: ``` sudo yum install -y cmake gcc gcc-c++ ncurses-devel bison openssl-devel ``` 2. 下载 MySQL 8.0 的源码: ``` wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.23.tar.gz ``` 3. 解压源码包: ``` tar -zxvf mysql-8.0.23.tar.gz ``` 4. 进入源码目录: ``` cd mysql-8.0.23 ``` 5. 创建一个 build 目录: ``` mkdir build ``` 6. 进入 build 目录: ``` cd build ``` 7. 运行 cmake 命令来配置 MySQL: ``` cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DENABLE_DTRACE=0 \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DWITH_BOOST=../boost ``` 注意:以上命令中,`-DCMAKE_INSTALL_PREFIX` 参数指定了 MySQL 的安装目录,`-DMYSQL_DATADIR` 参数指定了数据文件存放的目录,`-DSYSCONFDIR` 参数指定了 MySQL 的配置文件存放的目录。 8. 编译安装 MySQL: ``` make && sudo make install ``` 9. 设置 MySQL 的配置文件: ``` sudo cp support-files/mysql.server /etc/init.d/mysql sudo chmod +x /etc/init.d/mysql sudo chkconfig --add mysql sudo chkconfig --level 345 mysql on sudo cp support-files/my-default.cnf /etc/my.cnf sudo sed -i 's/^# basedir/ basedir/' /etc/init.d/mysql sudo sed -i 's/^# datadir/ datadir/' /etc/init.d/mysql sudo service mysql start ``` 10. 默认情况下,MySQL 的 root 用户没有密码,你需要执行以下命令来设置密码: ``` sudo /usr/local/mysql/bin/mysql_secure_installation ``` 以上就是在 CentOS 9 上安装 MySQL 8.0 源码的步骤。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

allenjiao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值