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

unable to build on CentOS7 #298

Open
vrnhgd opened this issue Jul 24, 2023 · 3 comments
Open

unable to build on CentOS7 #298

vrnhgd opened this issue Jul 24, 2023 · 3 comments

Comments

@vrnhgd
Copy link

vrnhgd commented Jul 24, 2023

Thanks for putting this in the open source space!

I'm trying to use this package w/ Node 16 on CentOS7 but having issues building. It looks like node-gyp can't find types defined like SQLDATEN or SQLDATETIMEOFFSETN.

I think this is a simple linker or install issue but I can't find references to these types anywhere.

Can you please help me figure out what I'm missing with the build setup?

Building using GCC and G++ x86_64-conda-linux-gnu-cc (conda-forge gcc 11.2.0-16) 11.2.0

npm verb pkgid msnodesqlv8@4.1.0
npm verb node v16.20.1
npm verb npm  v8.19.4

Relevant error snippets from the build:

npm ERR! ../src/BoundDatum.cpp: In member function 'void mssql::BoundDatum::bind_var_char_array_bcp(const v8::Local<v8::Value>&)':
npm ERR! ../src/BoundDatum.cpp:210:38: error: expected primary-expression before ';' token
npm ERR!   210 |                 sql_type = SQLVARCHAR;
npm ERR!       |                                      ^
npm ERR! ../src/BoundDatum.cpp: In member function 'void mssql::BoundDatum::bind_w_var_char_array_bcp(const v8::Local<v8::Value>&)':
npm ERR! ../src/BoundDatum.cpp:297:28: error: 'SQLNCHAR' was not declared in this scope; did you mean 'SQLWCHAR'?
npm ERR!   297 |                 sql_type = SQLNCHAR;
npm ERR!       |                            ^~~~~~~~
npm ERR!       |                            SQLWCHAR
npm ERR! ../src/BoundDatum.cpp: In member function 'void mssql::BoundDatum::bind_var_binary_array_bcp(const v8::Local<v8::Value>&)':
...
npm ERR! ../src/BoundDatum.cpp: In member function 'void mssql::BoundDatum::reserve_date(SQLLEN)':
npm ERR! ../src/BoundDatum.cpp:958:36: error: 'SQLDATEN' was not declared in this scope; did you mean 'SQLDATE'?
npm ERR!   958 |                         sql_type = SQLDATEN;
npm ERR!       |                                    ^~~~~~~~
npm ERR!       |                                    SQLDATE
npm ERR! ../src/BoundDatum.cpp: In member function 'void mssql::BoundDatum::reserve_time(SQLLEN)':
npm ERR! ../src/BoundDatum.cpp:1075:36: error: 'SQLTIMEN' was not declared in this scope; did you mean 'SQLTIME'?
npm ERR!  1075 |                         sql_type = SQLTIMEN;
npm ERR!       |                                    ^~~~~~~~
npm ERR!       |                                    SQLTIME
npm ERR! ../src/BoundDatum.cpp: In member function 'void mssql::BoundDatum::reserve_time_stamp(SQLLEN)':
npm ERR! ../src/BoundDatum.cpp:1136:36: error: 'SQLDATETIME2N' was not declared in this scope; did you mean 'SQL_DATETIME'?
npm ERR!  1136 |                         sql_type = SQLDATETIME2N;
npm ERR!       |                                    ^~~~~~~~~~~~~
npm ERR!       |                                    SQL_DATETIME
npm ERR! ../src/BoundDatum.cpp: In member function 'void mssql::BoundDatum::reserve_time_stamp_offset(SQLLEN)':
npm ERR! ../src/BoundDatum.cpp:1172:36: error: 'SQLDATETIMEOFFSETN' was not declared in this scope
npm ERR!  1172 |                         sql_type = SQLDATETIMEOFFSETN;
npm ERR!       |                                    ^~~~~~~~~~~~~~~~~~
...
npm ERR!       |                                    ^~~~~~~
npm ERR! make: *** [Release/obj.target/sqlserverv8/src/BoundDatum.o] Error 1
@TimelordUK
Copy link
Owner

hello

these should be contained in ms dev include header file

make: Leaving directory '/home/me/dev/js/sql/v8/node_modules/msnodesqlv8/build'
gyp info ok
me@DESKTOP-LCTQPPK:~/dev/js/sql/v8/node_modules/msnodesqlv8$ grep SQLDATETIMEOFFSETN /opt/microsoft/msodbcsql18/include/*.h
#define SQLDATETIMEOFFSETN                  0x2b
me@DESKTOP-LCTQPPK:~/dev/js/sql/v8/node_modules/msnodesqlv8$
me@DESKTOP-LCTQPPK:~/dev/js/sql/v8/node_modules/msnodesqlv8$ ls -alrt /opt/microsoft/msodbcsql18/include/*.h
-rw-r--r-- 1 root root 44040 Jan  3  2023 /opt/microsoft/msodbcsql18/include/msodbcsql.h

which on Ubuntu is alongside the library

me@DESKTOP-LCTQPPK:~/dev/js/sql/v8/node_modules/msnodesqlv8$ ls -l /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.2.so.1.1
-rwxr-xr-x 1 root root 2084624 Jan  3  2023 /opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.2.so.1.1

you may get an idea by looking at one of supplied Docker image files - you likely will also need the odbc dev package

sudo apt-get install -y unixodbc-dev

the locations of where to look are in binding.gyp

it is likely you need to add the location of header files in this file as this is not a supported distribution

see Red Hat section here

https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16&tabs=redhat18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline

have all equialent steps been taken as below on your install

sudo su

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#RHEL 7 and Oracle Linux 7
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo

#RHEL 8 and Oracle Linux 8
curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo

#RHEL 9
curl https://packages.microsoft.com/config/rhel/9.0/prod.repo > /etc/yum.repos.d/mssql-release.repo

exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install -y msodbcsql18
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install -y mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo yum install -y unixODBC-devel
Previous versions

near top of build node-gyp should print the found header filed such as below

 ACTION binding_gyp_sqlserverv8_target_print_variables src/BeginTranOperation.cpp
cflags_cpp -std=c++17 | arch: x86_64 | link_path: -L/usr/local/lib -L/usr/local/ssl/lib64/ -L/home/linuxbrew/.linuxbrew/lib/ -L/usr/lib -L. | msodbc_include_folders /opt/microsoft/msodbcsql18/include/ /home/linuxbrew/.linuxbrew/include/ /opt/microsoft/msodbcsql17/include/ /home/linuxbrew/.linuxbrew/include/ 

these are the found locations you will need the required path to include above to show up here for build to work

note I personally have not ever built the driver on this platform - you may be unlucky even after this and the code fails due to compiler compatibility.

@vrnhgd
Copy link
Author

vrnhgd commented Jul 24, 2023

ah. I'm using libmsodbcsql-17.5.so.2.1 and none of those are defined in the header msodbcsql.

do you think it's in unixodbc-dev as well?

@TimelordUK
Copy link
Owner

I did build a docker image for cento7 which may help as a reference - this does work with driver. I ran into problems with the cpp runtime and eventually pulled gcc 11.2 from src, built that and then built latest node 16 with that compiler before building openssl from src so everything was consistent (else we crash with classic double free SEGV)

this image would likely take hrs to build depending on machine CPU speed but it does produce as we see below a working environment.

apprunner@00ee9bd9dcb4 msnodesqlv8]$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[apprunner@00ee9bd9dcb4 msnodesqlv8]$ gcc --version
gcc (GCC) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[apprunner@00ee9bd9dcb4 msnodesqlv8]$ node --version
v16.20.1
[apprunner@00ee9bd9dcb4 msnodesqlv8]$ node samples/javascript/streaming.js
run with Driver={ODBC Driver 18 for SQL Server}; Server=DESKTOP-VIUCH90;UID=linux; PWD=linux; Database=node;Encrypt=no;
submitted select top 5 * from master..syscolumns elapsed 4 ms
meta = [
    {
        "size": 128,
        "name": "name",
        "nullable": true,
        "type": "text",
        "sqlType": "nvarchar"
    },
    {
        "size": 10,
        "name": "id",
        "nullable": false,
        "type": "number",
        "sqlType": "int"
    },

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