Compile node-sqlite in windows

Source: Internet
Author: User
Tags gz file install node

Nodejs is becoming increasingly more lightweight and efficient. However, nodejs 0.10 does not have a native database. Recently, we are preparing to use a database for data persistence and a preliminary preparation for using sqlite.

The sqlite Library Under nodejs. You can install node-sqlite using npm install. However, it cannot be installed in windows. By the way, some people say that nodejs is used in linux, so you don't have to consider it in windows. But you need to know that windows has the most users, and we cannot forget the most users at any time. Find the relevant information. The installation fails because the windows binary Installation File of node-sqlite is not available and must be compiled during installation. This section describes how to compile node-sqlite in windows. But in fact there are still many differences. Here we will record it and give it to you later.
First, install vc express. It is a compiler and cannot be compiled without it. I downloaded the 2010 version. There are two installation methods. One is network installation. After you download and run the tool, the actual installation file will be downloaded for more than one hour. You can also install the version offline. Here, the version is more than 1 GB. This is a collection of express. You can choose security.
Download the node compilation version here. Note that it is not the installation version. Then run vcbuild. bat in it to generate a connectable version.
Download node-sqlite for windows. This version does not contain gyp, so it cannot be compiled directly. Manual compilation is required through the express 2010 interface.
First, extract the sqlite-autoconf-3070800.tar.gz file under depsto sqlite3.

Then set the parameters. You can set parameters in either of the following ways: Edit node_extension.SAMPLE.props directly and change the name to node_extension.props. One is to rename node_extension.SAMPLE.props directly to node_extension.props. Then open the node-sqlite3.sln. On the properties page of The node-sqlite3, modify the c/c ++/General/Additional include directory and add the directory containing node. h. Node. h does not know where it is? The downloaded node compilation version is in \ src \ under node. The following is different from the description. Add uv. h and v8.h under the node \ deps \ uv \ include and \ deps \ v8 \ include respectively. On the properties page of The node-sqlite3, add the directory for node. lib to the linker/General/additional library directory.

Start build. Then there will be a bunch of errors:

1> d: \ sqlite-win \ node-sqlite3-windows \ src \ statement. cc (121): error C2664: "uv_queue_work": you cannot convert parameter 4 from "void (_ cdecl *) (uv_work_t *)" to "uv_after_work_cb"
1> no function with this name exists within the range matching the target type.
In this way, change & baton-> request, Work_Prepare, Work_AfterPrepare to & baton-> request, Work_Prepare, (uv_after_work_cb) Work_AfterPrepare

You also need to change macros. change & baton-> request, Work _ # type, Work_After ## type) to & baton-> request, Work _ # type, (uv_after_work_cb) Work_After # type) in h)

However, an error occurs during the link:

1> ------ generated: Project: node_sqlite3, configuration: Debug Win32 ------
1> C: \ Program Files \ MSBuild \ Microsoft. Cpp \ v4.0 \ Microsoft.CppBuild.tar gets (299,5): warning MSB8004: the Output directory does not end with a slash. The generated instance adds a slash because the slash must be included to correctly calculate the Output directory.
1> creating Library D: \ sqlite-win \ node-sqlite3-windows \ lib \ node_sqlite3.lib and Object D: \ sqlite-win \ node-sqlite3-windows \ lib \ node_sqlite3.exp
1> database. obj: error LNK2001: the external symbol that cannot be parsed "class v8: Isolate * node: node_isolate "(? Node_isolate @ node @ 3PAVIsolate @ v8 @)
1> statement. obj: error LNK2001: the external symbol that cannot be parsed "class v8: Isolate * node: node_isolate "(? Node_isolate @ node @ 3PAVIsolate @ v8 @)
1> D: \ sqlite-win \ node-sqlite3-windows \ lib \ node_sqlite3.node: fatal error LNK1120: 1 external command that cannot be parsed
============ Generate: 0 successful, 1 failed, 0 latest, skipped 0 ==========

I guess it is a link error. Find the relevant file. In node. cc, "class v8: Isolate * node: node_isolate" is defined as follows:

// Declared in node_internals.hIsolate * node_isolate = NULL; the following content is also found in node_internals.h: namespace node {// Defined in node. ccextern v8: Isolate * node_isolate; but I don't know why a link error occurs. Please kindly advise which C/C ++ expert. After compilation, you can install it.
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.