Ubuntu配置Boost-python

本文详细记录了在Ubuntu系统中配置Boost-python的过程,包括安装Boost库、使用特定的编译命令以及修正代码中的引用。最终提供了一个可行的工作方案,帮助读者成功将Boost与Python模块结合。

Ubuntu配置Boost-python

目前配过最麻烦的环境之一…

一些不知道有没有用的预置步骤

  1. 安装cmake
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update

sudo apt-get install cmake
sudo apt-get upgrade

  1. 一个让我能成功编译Boost-Numpy的回答
sudo apt -y install libpython2.7-dev libboost-python-dev
git clone https://github.com/ndarray/Boost.NumPy
cd Boost.Numpy
mkdir build
cd build
cmake ..
make 
sudo make install

replace in your code boost/python/numpy.hpp with boost/numpy.hpp also replace namespace np = boost::python::numpy with namespace np = boost::numpy

一个复杂的编译命令:

g++ -o graphFac_ext.so -fPIC -shared graphFac.cpp -lboost_python -lboost_numpy -I/usr/local/include -I/usr/include/x86_64-linux-gnu/python2.7/ -I/usr/include/python2.7 -std=c++11

能成功编译,但编译出来还差了点东西。没办法在python里用

一个能work的方案

  1. 安装Boost
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>

using namespace std;
int main(){
  boost::array<int, 4> arr = {{1,2,3,4}};
  cout << "hi" << arr[0];
  return 0;
}

Compile like this:

g++ -o s main.cpp

Run it like this:

./s

Program prints:

hi1
  1. 生成python的module

用链接里的makefile文件,make一下就行了,注意module的路径组织。

一些无关命令的备份

./line -train ./clean/cora.trans.edgelist.line -output ./result/cora.trans.edgelist.line1.out -binary 0 -size 128 -order 1 -negative 5 -samples 100 -rho 0.025 -threads 8
./line -train ./clean/blogCatalog.trans.edgelist.line -output ./result/blogCatalog.trans.edgelist.line1.out -binary 0 -size 128 -order 1 -negative 5 -samples 100 -rho 0.025 -threads 8
./line -train ./clean/PPI.trans.edgelist.line -output ./result/PPI.trans.edgelist.line1.out -binary 0 -size 128 -order 1 -negative 5 -samples 100 -rho 0.025 -threads 8
./line -train ./clean/friendship.trans.edgelist.line -output ./result/friendship.trans.edgelist.line1.out -binary 0 -size 128 -order 1 -negative 5 -samples 100 -rho 0.025 -threads 8

python -m openne --method lle --input data/gowalla/Gowalla.trans.train.20 --output data/gowalla/Gowalla.trans.train.20.spectral.out

nohup python -m openne --method lle --input data/gowalla/Gowalla.trans.train.20 --output data/gowalla/Gowalla.trans.train.20.spectral.out > gowalla.log &

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值