Ubuntu配置Boost-python
目前配过最麻烦的环境之一…
一些不知道有没有用的预置步骤
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
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的方案
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
用链接里的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 &
本文详细记录了在Ubuntu系统中配置Boost-python的过程,包括安装Boost库、使用特定的编译命令以及修正代码中的引用。最终提供了一个可行的工作方案,帮助读者成功将Boost与Python模块结合。

7158

被折叠的 条评论
为什么被折叠?



