淺談LevelDB在ubuntu 11.04下編譯失敗的問題
我在***的ubuntu11.04下編譯leveldb的時候發(fā)現(xiàn)問題,但是在更早前的這個版本很正常:
- 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
我的編譯環(huán)境:
- $ 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下發(fā)現(xiàn)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
現(xiàn)在再實驗下:
- $ make
- ...
- #跑測試案例
- $ make check
bingo, 玩得開心!
原文鏈接:http://blog.yufeng.info/archives/1319
【編輯推薦】