error: ‘alarm’ was not declared in this scope 解决

0. 在编译librangetree-v1.2 (C++ 2D 范围树) 的bench出现 “error: ‘alarm’ was not declared in this scope ”错误

[ghui@StuOS bench]$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure --prefix=/usr --libexecdir=/usr/lib --with-gmp=/usr/local/gmp-5.0.5 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 --with-ppl=/usr/local/ppl-0.11 --with-cloog=/usr/local/cloog-0.16.2 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++,fortran,go,java,lto,objc,obj-c++ --enable-multilib --disable-bootstrap --with-system-zlib --build=x86_64-linux-gnu --enable-lto --with-cpu=athlon64 --enable-cloog-backend=isl --enable-objc-gc --disable-werror --enable-interwork --with-gnu-ld
Thread model: posix
gcc version 4.8.0 20121004 (experimental) (GCC) 
[ghui@StuOS bench]$ pwd
/home/Ghui/Desktop/librangetree-v1.2/bench
[ghui@StuOS bench]$ ls
countspeed.cpp  example.png  Makefile  mil.cpp  scaling.cpp  timing.h  viz.cpp
[ghui@StuOS bench]$ make
g++ -Wall -Wextra -I ..   countspeed.cpp ../ranget.h timing.h   -o countspeed
g++ -Wall -Wextra -fopenmp -I .. -fopenmp  scaling.cpp ../ranget.h timing.h   -o scaling
scaling.cpp: In function ‘int main()’:
scaling.cpp:70:10: error: ‘alarm’ was not declared in this scope
   alarm(2);
          ^
make: *** [scaling] Error 1

2. 在scaling.cpp包含#include <unistd.h>如下:

#include <unistd.h>
#include "timing.h"
#include <omp.h>
#include <signal.h>


3. 再次编译:

[ghui@StuOS bench]$ make
g++ -Wall -Wextra -fopenmp -I .. -fopenmp  scaling.cpp ../ranget.h timing.h   -o scaling
g++ -Wall -Wextra -I ..   mil.cpp ../ranget.h timing.h   -o mil
[ghui@StuOS bench]$ ls
countspeed  countspeed.cpp  example.png  Makefile  mil  mil.cpp  scaling  scaling.cpp  timing.h  viz.cpp


By iomato

iomato.dev@Gmail.com

09:50 - 2013-01-05

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值