'rocksdb'에 해당되는 글 1건

  1. 2014/04/23 용비 Cygwin에서 rocksdb 빌드하기
1. gflags 설치
wget https://gflags.googlecode.com/files/gflags-2.0-no-svn-files.tar.gz
tar -xzvf gflags-
2.0-no-svn-files.tar.gz
cd gflags-2.0
./configure && make && sudo make install
2. snappy 설치
wget https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz
tar -xzvf snappy-1.1.1.tar.gz
cd snappy-1.1.1
./configure && make && sudo make install
3. apt-cyg 설치 (Cygwin Console에서 수행:yum이나 apt-get과 비슷한 기능)
svn --force export http://apt-cyg.googlecode.com/svn/trunk/ /bin/
chmod +x /bin/apt-cyg
4. zlib 설치
apt-cyg install zlib
apt-cyg install zlib-devel
5. bzip2 설치
apt-cyg install bzip2
apt-cyg install bzip2-devel
6. rocksdb 설치
6.1. rocksdb 소스 다운로드
https://
github.com/facebook/rocksdb 에서 zip파일 다운로드 후
c:\cygwin\home\user계정 폴더로 옮김
Cygwin Console에서 압축 해제
unzip rocksdb_master.zip
6.2. build_detect_platform 수정
cd rocksdb_master
cd build_tools
vi build_detect_platform
아래 항목을 찾아서 다음과 같이 변경
PLATFORM_CXXFLAGS="-std=c++11" => PLATFORM_CXXFLAGS="-std=gnu++11"
case "$TARGET_OS"  in 을 찾아서 아래 항목 추가
CYGWIN_*)
PLATFORM=OS_LINUX
COMMON_FLAGS="$COMMON_FLAGS $MEMCMP_FLAG -lpthread -DOS_CYGWIN"
PLATFORM_LDFLAGS="-lpthread"
PORT_FILE=port/port_posix.cc
;;
6.3. Makefile 수정
아래 항목을 찾아서 수정
WARNING_FLAGS = -Wall -Werror => WARNING_FLAGS = -Wall
6.4. include/rocksdb/slice.h 파일에 다음 내용 추가
#include <cstdio>
6.5. include/rocksdb/status.h 파일에 다음 내용 추가
#include <sstream>
#include <cstdlib>
#if defined(OS_CYGWIN)
namespace std {
template <class Tdigit>
string to_string(Tdigit value)
{
stringstream stream;  
stream << value;  
return stream.str();  
}  
inline int stoi(const string& str)  
{  
return ::atoi(str.c_str());  
}  
}  
#endif
6.6.port/port_posix.h 파일 수정
#if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\  
    defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) ||\  
    defined(OS_ANDROID) || defined(OS_CYGWIN)  
// Use fread/fwrite/fflush on platforms without _unlocked variants  
#define fread_unlocked fread  
#define fwrite_unlocked fwrite  
#define fflush_unlocked fflush  
#endif
6.7. util/env_posix.cc 파일 수정
assert 주석 처리
public:  
  PosixRandomAccessFile(const std::string& fname, int fd,  
                        const EnvOptions& options)  
      : filename_(fname), fd_(fd), use_os_buffer_(options.use_os_buffer) {  
    //assert(!options.use_mmap_reads);  
  }
defined(OS_CYGWIN) 추가

  virtual uint64_t NowNanos() {
#ifdef OS_LINUX || OS_CYGWIN
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);
    return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;
#elif __MACH__
    clock_serv_t cclock;
    mach_timespec_t ts;
    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
    clock_get_time(cclock, &ts);
    mach_port_deallocate(mach_task_self(), cclock);
#endif
    return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec;
  }
6.8. Compile시 Error
./util/log_buffer.h에서 timeval now_tv 변수에 대한 오류가 발생할 경우
./util/log_buffer.h 파일에 #include <sys/time.h> 추가
snappy, gflags library Error like next
/usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: cannot find -lsnappy /usr/lib/gcc/i686-pc-cygwin/4.8.2/../../../../i686-pc-cygwin/bin/ld: cannot find -lgflags collect2: error: ld returned 1 exit status Makefile:251: recipe for target 'db_bench' failed make: *** [db_bench] Error 1
case "$TARGET_OS" in 의 CYGWIN_*) 부분에서 다음 항목 추가
 PLATFORM_LDFLAGS="-lpthread -L/usr/local/lib"
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://www.yongbi.net/rss/response/590