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

Precompiled node-oracle #18

Closed
bchr02 opened this issue Feb 9, 2015 · 211 comments
Closed

Precompiled node-oracle #18

bchr02 opened this issue Feb 9, 2015 · 211 comments

Comments

@bchr02
Copy link

bchr02 commented Feb 9, 2015

If you are having issues installing node-oracledb or if you don't have a build environment and are looking to install a pre-compiled version of node-oracledb then check out my new npm module oracledb-pb, which can be installed like so:
npm install oracledb-pb

Then, within your app, instead of:
var oracledb = require('oracledb');
use:
var oracledb = require('oracledb-pb');

oracledb-pb is an unofficial oracledb module which I have published to npm for the benefit of allowing the community to get up and running with oracledb quickly. It's only dependency is the Microsoft Visual C++ Runtime. The module even downloads and installs the necessary Oracle Instant Client Packages for you and adds the folder to your PATH environment variable.

oracledb-pb is based on the work outlined below and you could optionally follow the below instructions instead which outlines how to install oracledb directly from my fork instead. For small projects I recommend oracledb-pb but for anything large scale or something that you will be publishing to npm I don't recommend it. The main reason is because it is not officially supported by Oracle and another reason is because I can't make any guarantees as to how frequently or how long term I can maintain it.

Fork with a working setup here.

Install instructions:

The following instructions allows one to install oracledb (from my fork) without needing a build environment.

Requirements: One must have an environment for which a binary has been built for. The table below under the section "List of available binaries" contains the binaries that I have compiled thus far. The list is limited because an automated build system is not yet utilized and I am manually needing to create these for each environment.

  1. Open command prompt and navigate to the folder where you would like to install oracledb.
  2. Paste the following command: npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
  3. Before pressing enter, at the --toolset option, change the oci version and msvs version so they match your environment. For example, --toolset=oci12.1-msvs2015 means you have the 12.1 version of the Oracle Client library and 2015 version of Visual Studio's C++ Redistributable. UPDATE: actually I made a mistake. With OCI 12.1 it's the 2010 Redistribuatable that is needed not the 2015. I will be correcting this but in the meantime you will need to use ...msvs2015 option when installing while making sure you have the 2010 Redistributable installed. Sorry for the confusion.
  4. Press Enter to run the command and once finished, if you scroll up, you should see the words "is installed via remote".
  5. Once installed you must make sure the correct Oracle libraries are available in PATH. The version must match a version listed in the above table. Currently only 12.1 have prebuilts***

List of available binaries as of Jan 9th 2017

oracledb Version Platform Arch Node ABI Version OCI version MS VS C++ Redist. Version Install Command
1.12.2 Linux 64bit 51 (Node v7) 12.1 n/a npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1
1.12.2 Linux 64bit 48 (Node v6) 12.1 n/a npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1
1.12.2 Windows 64bit 51 (Node v7) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.12.2 Windows 64bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.11 Windows 64bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.11 Windows 64bit 46 (Node v4) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.11 Windows 64bit 14 (Node v0.12) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 64bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 48 (Node v6) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 64bit 46 (Node v4) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 46 (Node v4) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 14 (Node v0.12) 12.1 2015 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2015
1.10.1 Windows 32bit 14 (Node v0.12) 12.1 2012 npm install https://github.com/bchr02/node-oracledb#prebuild_support --toolset=oci12.1-msvs2012

Instructions to build and package can be found here: #392

@Bigous
Copy link
Contributor

Bigous commented Feb 9, 2015

+1

@sagiegurari
Copy link

that would be inconsistent with any other node module i saw which has c code in it.
It would actually break the concept of npm install/update.

agree its a pain to set everything up in windows, but its a one time thing and you have all tools provided by Microsoft free.

The only issue is the 64bit support, meaning, to 64 bit compiler from microsoft is not free so you will have to use 32bit node.js exe to run those modules, otherwise you won't be able to load those 32bit compiled libs.

@Bigous
Copy link
Contributor

Bigous commented Feb 10, 2015

Hi @sagiegurari,

That's true, when you talk about node module - but I have seen some modules which use phanton in the test cases and when it fails to compile, it downloads the precompiled phanton and works like a charm. Node itself is not in that way too, it's distributed precompiled.

But here we are talking about an Oracle Client. All oracle clients provided by oracle are distributed compiled. And this one is a wrapper to a compiled one (OCI). So, I cannot see a point in providing one client half compiled and half to be compiled.

It would be better if Oracle could compile it and distribute it together with the instant client itself or in a separated ZIP file which could be downloaded by npm install, just like it does with ODP.NET.

@cjbj
Copy link
Member

cjbj commented Feb 10, 2015

@sagiegurari regarding 64 bit, is this usable?: http://www.visualstudio.com/products/visual-studio-community-vs (Can you tell I rarely use Windows?)

@bchr02
Copy link
Author

bchr02 commented Feb 10, 2015

After doing some research, there appears to be a lot of node community support for pre-compiled modules: see npm/npm#1891 and nodejs/node-v0.x-archive#4398

Based on what I'm reading, it seems there are at least two possible solutions:

  1. use node-pre-gyp - some minor gochas:
    • On Windows you'll need to make sure your users have the right C++ runtime installed.
    • On OS X you'll need to make sure you compile your module with the desired value passed to the -mmacosx-version-min flag.
    • On Linux you'll need to make sure to create your binaries on the oldest system you want to support. This means practically that if you create your binaries on Ubuntu Precise they will work on Ubuntu Precise and any other linux distro more recent (like Debian Sid or Ubuntu Trusty).
  2. use module-foundry - I believe this would be something that Oracle would need to create on their end to use as part of their build process. This will allow them to build for Linux, SmartOS and Windows.

@cjbj What do you think? Can we implement any one of these two options? node-pre-gyp appears to be the easiest to implement. What are your thoughts?

@cjbj
Copy link
Member

cjbj commented Feb 11, 2015

Great to see the enthusiasm. Keep the ideas and references coming.

To be realistic, we have a lot of base things to do first, before branching out to building binaries.

@sagiegurari
Copy link

Hi @cjbj
seems I'm a bit outdated and the new express editions do support 64bit compilation.
They have a X86_ x64 cross-compiler which means its a 32bit compiler that is able to generate 64 bit executables. so we should be ok here.
I took the info from:
https://msdn.microsoft.com/en-us/library/hs24szh9.aspx
Issue is that it shows it needs windows 8.

as for the community edition, I see no where any statement on what is actually supports and I have never tried it.

@ghost
Copy link

ghost commented Jul 9, 2015

Module foundry looks good.

@bchr02
Copy link
Author

bchr02 commented Jul 23, 2015

@cjbj any update on this getting done before node-oracle is out of beta?

@cjbj
Copy link
Member

cjbj commented Jul 23, 2015

Not even on the radar, sorry. Priorities change dynamically, so once we have LOBs etc we will revisit it.

@cjbj
Copy link
Member

cjbj commented Jul 24, 2015

@bchr02 on a related topic, do you have any fresh comments for the Windows installation section of INSTALL.md https://github.com/oracle/node-oracledb/blob/master/INSTALL.md#instwin

@bchr02
Copy link
Author

bchr02 commented Jul 29, 2015

@cjbj Sorry for taking so long to respond. I have been busy. Overall the updated Windows installation section is excellent. It has a lot of helpful information and, for the most part, contains all the information one would need for a successful installation. I think you have done a good job.

I do have a few comments though:

Under section 6.1 you write:

You will also need the matching Visual C++ Redistributable for Visual Studio.

It would be helpful to the reader if they knew that, at least with Visual Studios 2013, and I believe with older versions as well, that the Visual C++ Redistributable is automatically installed with it. However this is probably a moot point though because I realized that you could safely uninstall Visual C++ Redistributable, reboot your system to make sure it's fully uninstalled and you could still compile and use the oracedb module. Perhaps we should eliminate the comment of needing the redistributable altogether. I have tested and verified this to be true with a test system running Windows 7 x64 and Visual Studio 2013.

Under section 6.3 where you write:

Optionally rename the resulting directory to C:\oracle\instantclient

I like this naming convention but why not be consistent with the directories under section 6.4 where you write:

set OCI_LIB_DIR=C:\oracle\instantclient_12_1\sdk\lib\msvc
set OCI_INC_DIR=C:\oracle\instantclient_12_1\sdk\include

I would rename these to:

set OCI_LIB_DIR=C:\oracle\instantclient\sdk\lib\msvc
set OCI_INC_DIR=C:\oracle\instantclient\sdk\include

Under section 6.4

The first paragraph discusses the need to use a Visual Studio command prompt or running certain batch files. I never had to do either of those things. Maybe it would be good to add a comment as to when this would be needed. I have installed oracledb on many different type of windows systems with various versions of Visual Studios and have never needed to do this. So if I were seeing this trying to do an install for the first time, it would slow me down. When I install the oracledb, I have had success by either opening a regular command prompt via Start, Run, cmd or by opening the node.js command prompt via Start, All Programs, Node.js, Node.js command prompt.

@bchr02
Copy link
Author

bchr02 commented Jul 29, 2015

@cjbj By the way, I noticed that there have been some requests for a video demonstrating the installation of oracledb on Windows, so I created one. Please check it out and let me know what you think: Video - install of oracledb on Windows 7 x64

@cjbj
Copy link
Member

cjbj commented Jul 29, 2015

@bchr02 great job on the video, which I'm watching at the moment. I'll address your earlier comments too in a while. The install guide has already greatly improved with your input and this should make it better. (In the video at about the 4 minute mark you mentioned the OCCI interface. node-oracledb uses OCI not OCCI).

@cjbj
Copy link
Member

cjbj commented Jul 29, 2015

One good reason to distribute binaries of some form is gyp's dependency on Python 2.7, which will become more and more a liability in future as platforms start to ship Python 3 by default.

Reference: nodejs/node-gyp#193

@bchr02
Copy link
Author

bchr02 commented Jul 29, 2015

@cjbj

(In the video at about the 4 minute mark you mentioned the OCCI interface. node-oracledb uses OCI not OCCI).

Oops, good catch! I will splice the video to fix this. :-) No worries. Let me know if there is anything else you find.

@bchr02
Copy link
Author

bchr02 commented Jul 30, 2015

@cjbj Okay, so I corrected the video, but I was not able to keep the same link address. Therefore, the video is now located here. I will also update the link in my original video post. Thanks.

@bchr02
Copy link
Author

bchr02 commented Jul 30, 2015

@cjbj If the community were to create a pull request that utilized node-pre-gyp to conditionally use pre-built binaries based on processor architecture and platform (and would fall back on compiling), would you accept it?

@cjbj
Copy link
Member

cjbj commented Jul 31, 2015

@bchr02 @Bigous I'd love to see the plan or a prototype PR - you have both signed the OCA so no issues on that side, even if other parts of the process take some time. Using node-pre-gyp seems a logical step forward.

@bchr02
Copy link
Author

bchr02 commented Jul 31, 2015

@cjbj Okay, in that case we will start working on something.

@Bigous how to you want to proceed? I know from your pull requests that you have more experience than me with node-gyp. Therefore, do you prefer to take the lead on this and we can use your own fork? If not, for whatever reason, maybe you have a busy schedule, I could take the lead and we could use my fork here: bchr02/node-oracledb.

I do not have a lot of experience with node-gyp let alone node-pre-gyp, so I may not be the best person to take the lead. Nevertheless, I don't think I would have a problem figuring things out.

Lastly, if there is anyone else in the community who has experience with node-pre-gyp and is interested to help, please let us know. Thanks.

@Bigous
Copy link
Contributor

Bigous commented Aug 1, 2015

Hi @cjbj and @bchr02.

I think this is the best way, It will be my first time doing this too. I think you could lead us on that Bill.

I started reading about node-pre-gyp and it requires (obviously) a host to store the tar with the binary distributions. It recommends S3 from Amazon. I need a little bit more research to understand it correctly, but It can be an start.

@bchr02
Copy link
Author

bchr02 commented Aug 9, 2015

@cjbj please don't forget to let me know your thoughts on #18 (comment) Thanks.

@cjbj
Copy link
Member

cjbj commented Aug 9, 2015

@bchr02 thanks for the URL. I was looking for your comments yesterday but my search foo & time available time let me down.

@cjbj
Copy link
Member

cjbj commented Aug 16, 2017

It's been a while, but along with the technical improvements to building brought by using ODPI-C in node-oracledb 2, there has been some progress on 'official' binaries. My current thoughts are:

  1. Have a lightweight downloader JS script, invoked by a package.json "install" script that downloads a binary, if one is available for the architecture. So npm install oracledb would install a binary.

  2. If a suitable binary is not found, the npm install oracledb log would give an error message telling users to compile from source using a command like npm install oracle/node-oracledb.git#dev-2.0. Running this would be the equivalent of installing node-oracledb v1, where a compiler, Python 2.7 etc are needed. The same syntax can be used in package.json dependencies, if you know that a pre-built binary isn't available.

Oracle client libraries would still need to be installed separately, since that needs a click through.

Unlike the node-gyp solution @bchr02 has been using in oracledb-pb the proposed idea does not fallback to compile from source when no binary is found. This make the installer & install footprint much smaller, faster, less error prone, and not rely on a bunch of 3rd party libraries.

We may/should be able to build binaries for some Node.js versions on Linux OL6, Windows and probably macOS. This would cater for most users, so not many people would have to install from GitHub.

Comments welcome.

I had a working installer script, that was waiting some time from @dmcghan et al to review. However in discussions with the powers-that-be, we need to change it a bit. If anyone has a simple pure-JS unzip implementation (with no 3rd party licenses) they want to contribute under the OCA ... send it through. We need to bundle the LICENSE with the oracledb.node binary. At the simplest we could not use ZIP format, but could concatenate the LICENSE and binary into one single file (for each architecture), and upload that to GitHub. Our install script would request the concatenated file and split it back into LICENSE and binary. However we need to make sure that GitHub would serve it with the correct MIME type. Using a ZIP would be cleaner than this simple solution.

@bchr02
Copy link
Author

bchr02 commented Aug 17, 2017

@cjbj I'm glad progress is being made with this. I think your approach makes sense. Hopefully the last bits of this could get sorted out so you could go live with it. Please keep the momentum going!

@cjbj
Copy link
Member

cjbj commented Aug 17, 2017

@bchr02 thank you - and thanks for all the work and ideas that have got us this far with node-oracledb.

@cjbj
Copy link
Member

cjbj commented Nov 20, 2017

Pre-built node-oracledb binaries are getting closer. I just pushed v2.0.14-dev with the proposed binary install scripts. Please code review and hammer on them to report issues and create pull requests.

Before releasing any actual binaries we need to complete the formalization of infrastructure & release processes, plus triple check the corporate gatekeepers don't have any last minute concerns, and do some testing - of course.

The package/README.md shows how you can create and host your own binaries if you want. You just create a generic install package, a binary package (one for each platform/Node version), and a SHA file.

My thoughts are to release binaries for macOS, Windows and Linux, for Node 4,6,8 & maybe 9.
The Linux binaries would be built on Oracle Linux 6.

Comments are welcome.

@lakamsani
Copy link

I assume Linux binaries will work on RHEL. Will they work on Ubuntu, CentOS or a micro Linux like Alpine which I think is CentOS derived.

@cjbj
Copy link
Member

cjbj commented Nov 27, 2017

@lakamsani I'm expecting they'll work on anything with the right glibc, which means not on Alpine Linux and not on RHEL5 or OL5 or things of that era. We're not planning on testing non Oracle Linux at the moment. Building from source will still work where it currently does.

@cjbj
Copy link
Member

cjbj commented Nov 27, 2017

Check out the pre-built binaries.

npm install https://github.com//oracle/node-oracledb/releases/download/v2.0.14/oracledb-2.0.14.tgz

This is a development release. See #716 for known issues and more information.

Yes, you still need Oracle client libraries installed separately.

@cjbj
Copy link
Member

cjbj commented Nov 27, 2017

It's probably better to keep pre-built binaries discussion here instead of #716 (which is locked!), so here it is:

  • Pre-built binaries for Node 4,6,8 and 9 are available on Github for macOS, Windows 64-bit and Linux 64-bit. The Linux binaries were built on Oracle Linux 6.

  • Yes, you still need Oracle client libraries installed separately.

  • Test installing by running:

npm install https://github.com//oracle/node-oracledb/releases/download/v2.0.14/oracledb-2.0.14.tgz

Node-oracledb v2 user documentation is still on the dev-2.0 branch

If binaries are not available for your platform, the INSTALL doc shows the syntax to compile from source code: npm install oracle/node-oracledb.git#v2.0.14

Warning: there will be further changes to node-oracledb before a production 2.0 release is made, see #716.

@cjbj
Copy link
Member

cjbj commented Nov 28, 2017

I've made the 2.0.14 dev package installable via npm. Install with:

npm install oracledb@dev

@cjbj
Copy link
Member

cjbj commented Nov 28, 2017

@bchr02 is it working for you? Is the new approach to not fallback to compilation looking OK?

@bchr02
Copy link
Author

bchr02 commented Nov 28, 2017

@cjbj Yes, it's looking great. I just tested it on Windows 10 Pro x64 and it worked flawlessly!

I still needed to npm install instantclient and then add it to path by adding the following line to the very top of my main file process.env['PATH'] = 'instantclient;' + process.env['PATH'];

Are you planning on building this in?

@cjbj
Copy link
Member

cjbj commented Nov 28, 2017

@bchr02 excellent.

I wasn't thinking of auto detecting an instant client on Windows. But suggestions and MRs are welcome.

@cjbj
Copy link
Member

cjbj commented Dec 14, 2017

I've started the process of releasing node-oracledb 2.0.15. Binaries are on GitHub now. Please test as below, so I know the version is OK to publish to npm. I plan to publish it tomorrow.

To try the 'binary installer':

 npm install https://github.com/oracle/node-oracledb/releases/download/v2.0.15/oracledb-2.0.15.tgz

These two commands will download and compile source code:

  npm install oracle/node-oracledb.git#v2.0.15
  npm install https://github.com/oracle/node-oracledb/releases/download/v2.0.15/oracledb-src-2.0.15.tgz

@cjbj
Copy link
Member

cjbj commented Dec 14, 2017

Node-oracledb v2 is out on npm: https://blogs.oracle.com/opal/node-oracledb-20-with-pre-built-binaries-is-on-npm

I'll close this issue out. Thanks @bchr02 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests