Linux下编译leveldb报错,leveldb ubuntu 11.04下编译失败问题

我在最新的ubuntu11.04下编译leveldb的时候发现问题,但是在更早前的这个版本很正常:

yufeng@yufeng-laptop:/usr/src/leveldb$ make

g++ -c -DLEVELDB_PLATFORM_POSIX -I. -I./include -std=c++0x -g2 db/db_bench.cc -o db/db_bench.o

In file included from ./port/port.h:14:0,

from ./util/coding.h:17,

from ./db/dbformat.h:13,

from ./db/db_impl.h:9,

from db/db_bench.cc:8:

./port/port_posix.h:14:22: fatal error: cstdatomic: 没有那个文件或目录

compilation terminated.

make: *** [db/db_bench.o] 错误 1

我的编译环境:

$ cat /etc/lsb-release

DISTRIB_ID=Ubuntu

DISTRIB_RELEASE=11.04

DISTRIB_CODENAME=natty

DISTRIB_DESCRIPTION="Ubuntu 11.04"

$ gcc -v

Using built-in specs.

COLLECT_GCC=/usr/bin/gcc-4.5.real

COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/lto-wrapper

Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/x86_64-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/x86_64-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu

Thread model: posix

gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)

头文件cstdatomic找不到, 简单的google下发现4.5的gcc这个头文件改名成atomic

It seems that cstdatomic was renamed to atomic in newer GCC versions.

Replacing cstdatomic include with atomic include in the header worked

for me.

解决方法很简单:

修改./port/port_posix.h:14 成

#include

现在再实验下:

$ make

...

#跑测试案例

$ make check

bingo, 玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值