首先需要从github将这个项目的存储库克隆到本地目录中。
git clone https://github.com/dmlc/rabit.git在当前目录中显示名为rabit的文件
然后进入rabit文件时,输入产生lib文件
lib文件夹本来是空的,但在lib中,README.md这样写道:
thisfolderholdsthelibraryfilegeneratedbythecompiler.togeneratethelibraryfile,typemakeintheprojectrootfolder.ifyouwantmpi
因此,必须编译文件以生成lib文件。
Makefile文件已存在于rabit目录中。 只需在rabit目录下输入make即可。 将显示类似于以下内容的库文件:
这些文件介绍如下。
文件列表
rabit.a the rabit包库
normallyyouneedtolinkwiththisone
rabit _ mock.atherabitpackagelibrarywithmocktest
thislibraryallowsadditionalmock-test
rabit _ MPI.a the MPI后台库
linkagainstthislibrarymakestheprogramusempiallreducethislibraryisnotfault-tolerant rabit _ empty.adummypackageimplemplementatatitatitatitiotion anythingonlyintroducedtominimizecodedependencyforprojectsthatonlyneed
singlemachinecode http://www.Sina.com /
生成库文件后,必须添加环境变量CPLUS_INCLUDE_PATH、LIBRARY_PATH和LD_LIBRARY_PATH
C_INCLUDE_PATH是头文件的搜索路径
LIBRARY_PATH是静态库搜索路径。 编译时包含
LD_LIBRARY_PATH是动态库搜索路径。 链接时包含
这三个项目分别设定如下。
导出cplus _ include _ path=/home/./rabit/include 3360 $ cplus _ include _ pathexportlibrary _ path=/home /
更改配置文件: vi /etc/profile写入文档末尾
导出cplus _ include _ path=/home/./rabit/include 3360 $ cplus _ include _ pathexportlibrary _ path=/home /
导出cplus _ include _ path=/home/./rabit/include 3360 $ cplus _ include _ pathexportlibrary _ path=/home/rabit/lib:$LD_library_path在Terminal命令行窗口中直接使用Exprary临时导出cplus _ include _ path=/home/./rrry 要写入include 3360 $ cplus _ include _ pathexportlibrary _ path=/home的lib : $ library _ pathexportld _ library _ path
创建测试文件rabittest.cpp
/* rabit test.CPP */# include iostream # include rabit.hint main (int argc,char *argv[] () STD 33603: cout ' hellout ) STD : cout rabit :3360 getrank (; std:cout 'n '; 返回(0; }使用以下命令进行编译:
如果g-orabittestrabittest.CPP-lr abit-STD=gnu0x成功,则在当前目录中显示可执行文件
然后,用./rabittest测试就可以了。
设置环境变量
设置完成之后测试是否成功
错误1:rabit.h : nosuchfileordirectory
环境变量的设定有错误,需要重新设定。
错误2:error :‘nullptr’wasnotdeclaredinthisscope
网上关于c 11的原因,据说只要在g命令后加上-std=gnu 0x这个项目就可以了