Windows compiler Leveldb

Source: Internet
Author: User

Prerequisites, download the Boost library and compile

Once the boost library is ready, you can compile leveldb.

First, download the Leveldb-windows, which is on GitHub

One.

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:\0AA--master\leveldb-master directory, so the use of E:\0AA--master\leveldb-maste

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

7 Completing the Import

Two. Check the configuration section

Boost library in the E:\LIB\boost64 directory, configured as a 64-bit platform in the project's property page

Include the Leveldb,boost header files that need to be included, and the boost Lib is included in the

  

(Manually exclude all *_test.cc and *_bench.cc files from the project, removing all xxx_text.c C xxxx_bench.cc test and performance test related source files from the project.) This article compiles without doing this part of the parentheses)

Exclude files from other platforms
port/port_android.cc
port/port_posix.cc

util/env_posix.cc

Three. Modify the source code

1.db\c.cc file 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

In the 2.port\port.h file
Note that the Windows system is used
adding in precompilation
#elif defined (leveldb_platform_windows)

#include "Port/port_win.h"

Four. Problems encountered during the compilation process:

1. Cannot open include file: "Sys/mman.h": no such file ordirectory

This problem was first compiled, and the second re-import project redo did not occur when this problem occurred. Probably because the port/port_posix.cc file was not excluded for the first time.

2. Unable to open the include file: "Pthread.h": No such file or directory

Download the latest version of Pthreads-w32-2-9-1, downloaded after the decompression, you can see a total of three folders, the main use of the "Pre-built.2" folder under the three folders, respectively, is a dynamic link library, header files, static link library, and then configure the header file and static link library, Configure the dynamic link library.

16907821

3. Unable to open the include file: "Sqlite3.h": No such file or directory

Download the sqlite3.h and include it in the configuration

Https://www.cnblogs.com/superbi/p/4980127.html

4. Unable to open the include file: "Kcpolydb.h": No such file or directory

http://fallabs.com/kyotocabinet/winpkg/

Download the kcpolydb.h and include it in the configuration

5. Cannot open include file: "Endian.h": Nosuch file or directory

Endian.h is the header file that is involved in the Linux compilation, which is compiled in Windows and does not require this header file.

6.vs2012: "snprintf" cannot find an identifier

41900045

The format of the snprintf () function is similar to printf, and is a function used in C that is included in the #include <stdio.h> header file.

However, the snprintf () function is not a function specified in standard C + +, so in many compilers, the vendor provides its corresponding version of the implementation. In GCC, the function name is snprintf (), and in VS is called _snprintf. So change to _snprintf when you need to use snprintf (), or add it at the precompiled Office:

#if _msc_ver

#define SNPRINTF _snprintf

#endif

7. Can dirent.h be used under Windows?

Download Dirent-master, head file included in

You can then compile the build LevelDB.lib

In use, in addition to Leveldb's head and static library, there are several boost libraries required

Libboost_date_time-vc120-mt-gd-x64-1_67.lib
Libboost_filesystem-vc120-mt-gd-x64-1_67.lib
Libboost_system-vc120-mt-gd-x64-1_67.lib
Libboost_thread-vc120-mt-gd-x64-1_67.lib
Libboost_chrono-vc120-mt-gd-x64-1_67.lib

Windows compiler Leveldb

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.