Windows compiler Leveldb

Source: Internet
Author: User
Tags windows x64

Windows compiler Leveldb


Flyfish 2015-7-8


Leveldb is an open source disk where Key-value storage is written by Google Jeffrey Dean and Sanjay Ghemawat.


Environment
Operating system: Windows x64
Compiler: VC2010

Configuration

Need boost library support, need to compile the boost library to 64-bit version first


1 File-"New-" Create a new project from an existing code file
Open the Create new project from Existing Code File wizard window


2 What type of project do you want to create? Select Visual C + +
3 Project file location Select Source Location leveldb-windows folder location
Here the source file is in the E:\LIB\leveldb-windows directory, so the use of E:\LIB\leveldb-windows


4 project name fill in LevelDB
5 Selecting a static library (LIB) project using the Visual Studio project type
If the static library (LIB) project is not successfully imported, you can first select the Windows Application project


6 in Settings for setting up the "debug" configuration
Preprocessor definition Fill Leveldb_platform_windows;os_win


Include search path fill E:\LIB\leveldb-windows; E:\LIB\leveldb-windows\include
You can not fill it out. Late can be configured in the project properties



Check the configuration section of the Boost library under the E:\LIB\boost64 directory
Configure the 64-bit platform in the project's property page


Configuration Properties-General-type of configuration
Static library (. Lib)


Configuration Properties-"c/c++-" general-"additional Include Directories"
E:\LIB\boost64; E:\LIB\leveldb-windows; E:\LIB\leveldb-windows\include


Configuration Properties-"c/c++-" general-"preprocessor-" preprocessor definition
Leveldb_platform_windows;os_win


Linker-"General-" additional library directory or library Manager-additional library directory
E:\LIB\boost64\stage\lib

Exclude Files
Manually exclude all *_test.cc and *_bench.cc files from the project


Exclude files from other platforms
port/port_android.cc
port/port_posix.cc
util/env_posix.cc
If there are other platforms also excluded


change the source of the place
1 db\c.cc files in the header file Unistd.h
Unistd.h is the name of the header file that provides access to the POSIX operating system APIs in the C and C + + programming languages. is the abbreviation for UNIX standard.
Not supported under Windows. Direct Comment
2 in the Port\port.h file
Note that the Windows system is used
adding in precompilation


#ifndef storage_leveldb_port_port_h_#define storage_leveldb_port_port_h_#include <string.h>//include the Appropriate platform specific file below.  If you are are//porting to a new platform, see "port_example.h" for documentation//of what the new port_<platform>.h F Ile must provide. #if defined (leveldb_platform_posix) #  include "port/port_posix.h" #elif defined (leveldb_platform _chromium) #  include "port/port_chromium.h" #elif defined (leveldb_platform_android) #  include "Port/port_ Android.h "#elif defined (leveldb_platform_windows)//New Part #  include ' Port/port_win.h ' #endif  




The added part is
#elif defined (leveldb_platform_windows)
#include "Port/port_win.h"


Compile to generate 64-bit Lib

The source and library files have been compiled.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Windows compiler Leveldb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.