Ubuntu配置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 
#include 

using namespace std;
int main(){
  boost::array 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 &

你可能感兴趣的:(炼丹玄学)