node-odbc icon indicating copy to clipboard operation
node-odbc copied to clipboard

npm install error OSX

Open brandonpsmith opened this issue 8 years ago • 2 comments

OSX 10.12.5 Node 8.1.2 NPM 5.0.3

unixodbc installed with Homebrew Homebrew symlinks the sql.h file from the Cellar to /usr/local/include

When I try to run "npm install odbc" I get the error below.

../src/odbc.h:30:10: fatal error: 'sql.h' file not found #include <sql.h> ^ 1 error generated.

After some googling ... I noticed some user's were setting an environment variable CPLUS_INCLUDE_PATH with /usr/local/include then running "npm install odbc". I tried this and the install completed with no errors. I'm not sure how this fixed the install but it did. I'm just reporting this for future OSX user's that have the same issue.

export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/include

brandonpsmith avatar Jun 21 '17 21:06 brandonpsmith

I think module needs "include/sql.h" file to compile successfully at installation time. When you are setting "CPLUS_INCLUDE_PATH" env variable it is simply telling the module to search "sql.h" at respective path location. So it looks like while installing from npm directly user need to set "CPLUS_INCLUDE_PATH" env variable path (I am not sure this is the case for node 8.X only or with every versions of node). If it is the case then I must suggest to owner- that please automatically set CPLUS_INCLUDE_PATH var path from the installation script (you can check if "include/sql.h" exist on that path - if yes then set the path, else give user a note to set path accordingly).

Thanks

rhtpandeyIN avatar Jun 22 '17 04:06 rhtpandeyIN

For those who land here and are still unsuccessful with their installs, try installing unixodbc via brew instead of macports. Solved my problem!

philippefutureboy avatar Jul 19 '18 16:07 philippefutureboy