Quantcast
Viewing all articles
Browse latest Browse all 290

Cmake中如何指定添加库参数

最近在研究如果用CPU挖ETHASH类型的矿

在Ubuntu下很简单,在CentOS下很麻烦啊。

首先clone项目

git clone --depth=1 https://github.com/avatar-lavventura/ethminer.git  

然后下载miniupnpc依赖包,必须是1.6-6的,1.5以下的不行

wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/miniupnpc-1.6-6.el6.art.x86_64.rpm  
wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/miniupnpc-devel-1.6-6.el6.art.x86_64.rpm  

安装依赖包

yum install leveldb-devel  

安装cmake3的编译环境

yum install centos-release-scl epel-release  
yum install cmake3 devtoolset-4-gcc* hwloc-devel libmicrohttpd-devel openssl-devel make  
scl enable devtoolset-4 bash  

然后进入ethminer编译,过程会报错

[ 73%] Linking CXX executable eth
../../deps/src/boost/stage/lib/libboost_thread.a(thread.o):thread.cpp:function boost::this_thread::no_interruption_point::hidden::sleep_until(timespec const&): error: undefined reference to 'clock_gettime'
../../deps/src/boost/stage/lib/libboost_thread.a(thread.o):thread.cpp:function boost::this_thread::no_interruption_point::hidden::sleep_until(timespec const&): error: undefined reference to 'clock_gettime'
../../deps/src/boost/stage/lib/libboost_thread.a(thread.o):thread.cpp:function boost::this_thread::hidden::sleep_for(timespec const&): error: undefined reference to 'clock_gettime'

是少功能clock_gettime,这个功能是在-lrt库内有。

那么,如何让cmake3编译的时候加上这个库呢?

一句话:

cmake3 -DCMAKE_EXE_LINKER_FLAGS="-lrt" ..  

不过编译出来的ethminer,用cpu挖ethash效率是真的低,完全跟GPU无法比,放弃之。


Viewing all articles
Browse latest Browse all 290

Trending Articles