• 2012-11-10

    Compiling levelDB on Windows Cygwin

    Views: 16045 | 1 Comment

    The official levelDB does not support Cygwin platform, trying to compile it on Cygwin may get the error message:”Unknow platform”. Anyway, levelDB works on Windows Cygwin environment, all you have to do is to manually modify some files.

    First, make sure your Cygwin has gcc-4 installed, not gcc-3:

    $ gcc -v
    gcc version 4.5.3 (GCC)

    Then, edit build_detect_platform under levelDB source code folder, make it looks like this:

    case "$TARGET_OS" in

    The “CYGWIN_*” codes is added. Then edit port/port_posix.h, make it looks like this:

    #if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\
        defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) ||\
        defined(OS_ANDROID) || defined(OS_HPUX) || defined(CYGWIN)
    // Use fread/fwrite/fflush on platforms without _unlocked variants
    #define fread_unlocked fread
    #define fwrite_unlocked fwrite
    #define fflush_unlocked fflush

    The ” || defined(CYGWIN)” is added, or you may got this error if you try to run make:

    util/env_posix.cc:50: error: `fread_unlocked' undeclared (first use this function)

    Now, you can compile levelDB on Windows Cygwin:


    If you can find the file libleveldb.a in levelDB source code folder, it’s sucessfull. levelDB is just a library, not a standalone server, so we write a simple CPP code example to test it:

    #include <iostream>
    #include "leveldb/db.h"
    int main(){
        leveldb::DB* db;
        leveldb::Options options;
        leveldb::Status status;
        options.create_if_missing = true;
        status = leveldb::DB::Open(options, "./testdb", &db);
        std::string key = "abc";
        std::string value = "123";
        std::string ret;
        std::cout << value;
        status = db->Put(leveldb::WriteOptions(), key, value);
        status = db->Get(leveldb::ReadOptions(), key, &ret);
        std::cout << ret;
        return 0;

    Compile this code(file named a.cpp) and run with command:

    g++ a.cpp -Iinclude -L. -lleveldb; ./a
    Posted by ideawu at 2012-11-10 12:09:50 Tags: ,
  • 2010-12-13

    An experience of Google interview

    Views: 7564 | 1 Comment

    Recently, I had a experience of Google interview(Beijing, China), I went through for three rounds of the interview. Firstly a phone interview, secondly an on-site interview in Google building, thirdly also an interview in Google building but with two people.

    We didn’t talk too much on the phone during first call from Google HR, a kind lady. Actually, it was because my spoken English, you know, I didn’t even speak a English word during the past threes year. But I suggest I should directly go to there office and have a face-to-face interview.

    Continue reading »

    Posted by ideawu at 2010-12-13 23:17:17
  • 2010-11-12

    Free Lucky Lottery Software

    Views: 7392 | No Comments

    Written in JavaScript+HTML+CSS, run on most web browser, such as Firefox, Internet Explorer, Chrome, Opera. Free of charge.

    Play Online Now >>

    Posted by ideawu at 2010-11-12 14:43:48
  • 2010-08-21

    Hello World!

    Views: 6994 | No Comments

    A Programmer’s blog. All things about C, C++, PHP, Python, HTML, CSS, JavaScript, Linux, Web development, Network Programming.

    Posted by ideawu at 2010-08-21 12:00:38
|<<<12>>>| 2/2 Pages, 9 Results.