Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please Help: Trying to Build RELEASE for Windows with VS Express C++ 2010 #55

Closed
cmundi opened this issue Jan 7, 2012 · 7 comments
Closed

Comments

@cmundi
Copy link

cmundi commented Jan 7, 2012

I am very close to having a build, but I need a little help!

I hope this also helps someone else. I am using Windows XP Pro (yeah, yeah) with Visual Studio Express 2010 C++.

First, it would be good to tell three things:

  1. You need python installed and on your %PATH%. I'm using Python 2.7.
  2. You need to build node in a path with no spaces! Otherwsie, the vcbuild.bat will fail! I use C:\NODEV\
  3. Visual Studio 2008 and later project property pages are accessed by right-clicking on a project entry in the Solution Explorer pane.

So now I follow all the instructions at https://github.com/developmentseed/node-sqlite3/wiki/Building-On-Windows ** up to **

"Go to the "Property Manager" ... "

at which point I realize that VS Express 2008/2010 (and VS also I think) have slightly different interfacess from what I am used to. But I am an experienced visual studio user, so I press on.

I am in VS. The solution opens up in Release mode for me. This will be significant below.

** I need to know exactly what I'm supposed to be adding to the compiler and linker paths, but the instructions "change all three paths in "Additional Include Directories" to match those on your system" are pretty vague. Ok, fine, I think, I will just try to build and let VS tell me what it cannot find. But when I do this, I get exactly one error which will be familiar to VS developers:

deps\sqlite3\sqlite3.c(131070): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?

Thinking the sln file was maybe not created by a WIndows developer, I tell the compiler not to use precompiled headers and I try to build again. Now I get the kind of error I was looking for:

src\database.cc(2): fatal error C1083: Cannot open include file: 'node.h': No such file or directory.

So I add (in my case) C:\NODEV\node-v0.6.6\src to the compiler include path. Try to build again. Get this:

fatal error C1083: Cannot open include file: 'uv.h': No such file or directory

So I add C:\NODEV\node-v0.6.6\deps\uv\include to the compiler include path. Try to build again. Get this:

fatal error C1083: Cannot open include file: 'v8.h': No such file or directory

So I add C:\NODEV\node-v0.6.6\deps\v8\include to the compiler include path. Try to build again. Get this:

fatal error C1083: Cannot open include file: 'sqlite3.h': No such file or directory

So I add C:\Documents and Settings\root\Desktop\developmentseed-node-sqlite3-v2.1.1-15-ge6b1f79\developmentseed-node-sqlite3-e6b1f79\deps\sqlite3

to the compiler path. (This is where I unpacked node-sqlite sources for windows.)

Try to build again. Finally no more compiler errors and now get link errors. Good!

Read through the link errors. Guess. Add C:\NODEV\node-v0.6.6\Debug\lib to the linker path and add the following libs to the linker dependencies:

v8_base.lib
v8_nosnapshot.lib
v8_snapshot.lib
uv.lib
openssl.lib
http_parser.lib
zlib.lib

Try to build again.

I get numerous errors like this:

v8_base.lib(api.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in database.obj

This suggests ( ** please tell me **) that this has something to do with the fact that the vcbuild.bat file (for node) build node in Debug but the node-sqlite project is built in Release.

SO I switch the VS build configuration mode to Debug and try to build again. Ah! Most of the errors are gone, and now I have to set all the optrions for Debug mode. (ya gotta love VS!)

The first thing I notice (in Debug settings now) is that someone upstream has tried to fix the deps already with this:

$(ProjectDir)deps\sqlite3 except that they misspelled "Project".

That line does not work in any version of VS I have ever used anyway, because VS is not smart enough to descend paths. So I just go ahead and add the same paths as above.

So here I go adding the include and lib paths to the Debug config pretty much the same way I did above...

I see that "kkaefer" appears in teh lib path for the Debug configuration, so I think I am on the right path (bad pun!) now and change that to match the lib path from my Node build instead, which is C:\NODEV\node-v0.6.6\Debug\lib

Try to build... SUCCESS!!! YEAH!!! But what does this mean...

I now have node_sqlite3.node and sqlite3.lib and I have no idea what to do with them. ** Please Help The Newbie! **

Also, it is now apparent that in order to get node-sqlite built in release, I will first need to build node in Release. I guess I will be looking at the vcbuild.bat file (for node) next.

I apologize for the long post. I see there is much interest in node-sqlite for Winnows. Hopefully it helps someone else.

I would appreciate some advice on how to install the module now that I have built it!

Thanks

@springmeyer
Copy link
Contributor

I'm not aware of how to get a working Release build out of the existing Visual Studio file, so I just went with a gyp approach and upload my build to https://github.com/developmentseed/node-sqlite3/downloads.

@springmeyer
Copy link
Contributor

the 'vcbuild.bat' is a hack that uses the gyp file I just added (undocumented). I can document how to utilize it on Monday. Ping me then, as I'm out for the weekend now.

@cmundi
Copy link
Author

cmundi commented Jan 7, 2012

Thanks! (And that for the phenomenally quick reply!) Have an excellent weekend! -- Carlos

@cmundi
Copy link
Author

cmundi commented Jan 7, 2012

Adding some notes for discussion on Monday.

Clean start. Grabbed the node 0.6.7 sources and built node in Release (' vcbuild.bat release' ). Works.

Downloaded a fresh copy of the windows branch of node-sqlite3. Still using VS GUI for node-sqlite3 build.
Made usual changes to project settings (disable precompiled headers, add include and lib paths, rename target to have .node extension instead of .dll extension)
Good: node-sqlite3 compiles and links in Release.

Copied the node-sqlite3.node to %HOME_DIR%\test\node_modules.
Tried to run the example on the node-sqlite3 homepage. FAIL!
Node says: TypeError: Object # has no method 'verbose'
So I remember that the Windows branch may differ from the master branch. Try this:

var s = require('node_sqlite3'); // ok
var d = new s.Database(':memory:'); // FAIL

The error is...

 undefined:0


 TypeError: undefined is not a function

and node terminates abnormally. Back at the command line, I'm not sure where to start looking.

I remember the warnings I saw when building node-sqlite3 about (not having) __declspec(dllexport) on templates within classes which do have __declspec(dllexport) decoration. I'm 90% sure that's cosmetic, as usual.

Next I do a full-tree diff between the master and windows branches of node-sqlite3. All the windows #ifdefs look good. Verified that VS really is building with _WIN32 to get the right threading model.

Looked at the new gyp stuff. Tried. I seem to be missing something. Will definitely need to ask springmeyer.

Encouraged, but not quite feeling the node-on-Windows love yet. :)

@springmeyer
Copy link
Contributor

you need to make sure the node_sqlite3.node is copied into the lib folder and then you should put lib on your $NODEPATH. Then you do require('sqlite3');

@cmundi
Copy link
Author

cmundi commented Jan 11, 2012

Aha. I suspected (from grepping) for 'verbose' and learning that's
implementation was js stored in /lib) something like this. Thanks. I will
try this!
On Jan 10, 2012 8:18 PM, "Dane Springmeyer" <
reply@reply.github.com>
wrote:

you need to make sure the node_sqlite3.node is copied into the lib
folder and then you should put lib on your NODEPATH. Then you do
require('sqlite3');


Reply to this email directly or view it on GitHub:

#55 (comment)

@cmundi
Copy link
Author

cmundi commented Jan 11, 2012

Success!!! Sure enough. I missed (1) that having the js files in /lib is critical and (2) the name to 'require' depends a little on how which step in node's search logic finds it. Awesome. Thanks!

@cmundi cmundi closed this as completed Jan 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants