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

nanodbc.cpp compile issue with codecvt header file #377

Closed
mahmutbilgen opened this issue Jul 1, 2020 · 19 comments
Closed

nanodbc.cpp compile issue with codecvt header file #377

mahmutbilgen opened this issue Jul 1, 2020 · 19 comments

Comments

@mahmutbilgen
Copy link

Issue Description and Expected Result

During the installation of odbc with R install function ( install.packages('odbc', type = 'source') ) nanodbc.cpp required codecvt header file.

Database

Reproducible Example

install.packages(repos="https://cran.rstudio.com/", 'odbc')
Warning in install.packages :
  unable to access index for repository https://np-r-packages.corpdom.com:8443/prod-cran/latest/src/contrib:
  cannot open URL 'https://np-r-packages.corpdom.com:8443/prod-cran/latest/src/contrib/PACKAGES'
Installing package into/apps/userhomes/user1/R/x86_64-pc-linux-gnu-library/3.6’
(aslibis unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/odbc_1.2.3.tar.gz'
Content type 'application/x-gzip' length 311896 bytes (304 KB)

downloaded 304 KB

** installing *source* packageodbc...
** packageodbcsuccessfully unpacked and MD5 sums checked
** using staged installation
Found odbc_config cflags and libs!
PKG_CFLAGS=-DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include 
PKG_LIBS=-L/usr/lib64 -lodbc
** libs
(cd cctz && \
make libcctz.a CC="gcc -std=gnu99" CXX="g++ -std=gnu++11" AR="ar" ARFLAGS=rv CXXPICFLAGS="-fpic")
make[1]: Entering directory `/tmp/Rtmp6f4myD/R.INSTALL310961c711b0/odbc/src/cctz'
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_format.o src/time_zone_format.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_if.o src/time_zone_if.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_impl.o src/time_zone_impl.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_info.o src/time_zone_info.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_libc.o src/time_zone_libc.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_lookup.o src/time_zone_lookup.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_posix.o src/time_zone_posix.cc
ar rv libcctz.a time_zone_format.o time_zone_if.o time_zone_impl.o time_zone_info.o time_zone_libc.o time_zone_lookup.o time_zone_posix.o
ar: creating libcctz.a
a - time_zone_format.o
a - time_zone_if.o
a - time_zone_impl.o
a - time_zone_info.o
a - time_zone_libc.o
a - time_zone_lookup.o
a - time_zone_posix.o
make[1]: Leaving directory `/tmp/Rtmp6f4myD/R.INSTALL310961c711b0/odbc/src/cctz'
g++ -std=gnu++11 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include  -I"/apps/userhomes/user1/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include -Icctz/include -Inanodbc -I. -DBUILD_REAL_64_BIT_MODE -DNANODBC_ODBC_VERSION=SQL_OV_ODBC3 -fpic -fpic  -g -O2  -c odbc_result.cpp -o odbc_result.o
g++ -std=gnu++11 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include  -I"/apps/userhomes/user1/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include -Icctz/include -Inanodbc -I. -DBUILD_REAL_64_BIT_MODE -DNANODBC_ODBC_VERSION=SQL_OV_ODBC3 -fpic -fpic  -g -O2  -c connection.cpp -o connection.o
g++ -std=gnu++11 -I"/opt/R/3.6.3/lib/R/include" -DNDEBUG -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include  -I"/apps/userhomes/user1/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include -Icctz/include -Inanodbc -I. -DBUILD_REAL_64_BIT_MODE -DNANODBC_ODBC_VERSION=SQL_OV_ODBC3 -fpic -fpic  -g -O2  -c nanodbc/nanodbc.cpp -o nanodbc.o
nanodbc/nanodbc.cpp:40:19: fatal error: codecvt: No such file or directory
 #include <codecvt>
                   ^
compilation terminated.
make: *** [nanodbc.o] Error 1
ERROR: compilation failed for packageodbc* removing/apps/userhomes/user1/R/x86_64-pc-linux-gnu-library/3.6/odbcWarning in install.packages :
  installation of packageodbchad non-zero exit status

The downloaded source packages are in/tmp/RtmpKc8hns/downloaded_packages
Session Info
devtools::session_info()
#> output
@mahmutbilgen
Copy link
Author

I have installed previous version 1.2.2 and works for me with below R command

devtools::install_version('odbc', '1.2.2', repos="https://cran.rstudio.com/" )

@tim-graf
Copy link

tim-graf commented Jul 1, 2020

I experience the same problem, when trying to install odbc 1.2.3 on our Corporate R-Studio Server running Suse Enterprise Linux.

> install.packages("odbc")
Installing package into ‘/data_neu/R/xxxxx/R/x86_64-suse-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/odbc_1.2.3.tar.gz'
Content type 'application/x-gzip' length 311896 bytes (304 KB)
==================================================
downloaded 304 KB

* installing *source* package ‘odbc’ ...
** package ‘odbc’ successfully unpacked and MD5 sums checked
** using staged installation
Found odbc_config cflags and libs!
PKG_CFLAGS=-DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include 
PKG_LIBS=-L/usr/lib64 -lodbc
** libs
(cd cctz && \
make libcctz.a CC="gcc -std=gnu99" CXX="g++ -std=gnu++11" AR="ar" ARFLAGS=rv CXXPICFLAGS="-fpic")
make[1]: Entering directory '/data_neu/R/xxxxx/tmp/RtmpEQRXr5/R.INSTALL5e213f5b0989/odbc/src/cctz'
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_format.o src/time_zone_format.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_if.o src/time_zone_if.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_impl.o src/time_zone_impl.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_info.o src/time_zone_info.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_libc.o src/time_zone_libc.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_lookup.o src/time_zone_lookup.cc
g++ -std=gnu++11  -Wall -Iinclude -std=c++11 -pthread  -O -fpic -MMD  -c -o time_zone_posix.o src/time_zone_posix.cc
ar rv libcctz.a time_zone_format.o time_zone_if.o time_zone_impl.o time_zone_info.o time_zone_libc.o time_zone_lookup.o time_zone_posix.o
ar: creating libcctz.a
a - time_zone_format.o
a - time_zone_if.o
a - time_zone_impl.o
a - time_zone_info.o
a - time_zone_libc.o
a - time_zone_lookup.o
a - time_zone_posix.o
make[1]: Leaving directory '/data_neu/R/xxxxx/tmp/RtmpEQRXr5/R.INSTALL5e213f5b0989/odbc/src/cctz'
g++ -std=gnu++11 -I"/usr/lib64/R/include" -DNDEBUG -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include  -I"/data_neu/R/ba29970/R/x86_64-suse-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include -Icctz/include -Inanodbc -I. -DBUILD_REAL_64_BIT_MODE -DNANODBC_ODBC_VERSION=SQL_OV_ODBC3 -fpic -fpic  -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables  -c odbc_result.cpp -o odbc_result.o
g++ -std=gnu++11 -I"/usr/lib64/R/include" -DNDEBUG -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include  -I"/data_neu/R/ba29970/R/x86_64-suse-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include -Icctz/include -Inanodbc -I. -DBUILD_REAL_64_BIT_MODE -DNANODBC_ODBC_VERSION=SQL_OV_ODBC3 -fpic -fpic  -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables  -c connection.cpp -o connection.o
g++ -std=gnu++11 -I"/usr/lib64/R/include" -DNDEBUG -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include  -I"/data_neu/R/ba29970/R/x86_64-suse-linux-gnu-library/3.6/Rcpp/include" -I/usr/local/include -Icctz/include -Inanodbc -I. -DBUILD_REAL_64_BIT_MODE -DNANODBC_ODBC_VERSION=SQL_OV_ODBC3 -fpic -fpic  -fmessage-length=0 -grecord-gcc-switches -fstack-protector -O2 -Wall -D_FORTIFY_SOURCE=2 -funwind-tables -fasynchronous-unwind-tables  -c nanodbc/nanodbc.cpp -o nanodbc.o
nanodbc/nanodbc.cpp:40:19: fatal error: codecvt: No such file or directory
 #include <codecvt>
                   ^
compilation terminated.
Makevars:20: recipe for target 'nanodbc.o' failed
make: *** [nanodbc.o] Error 1
ERROR: compilation failed for package ‘odbc’
* removing ‘/data_neu/R/xxxxx0/R/x86_64-suse-linux-gnu-library/3.6/odbc’
* restoring previous ‘/data_neu/R/xxxxx/R/x86_64-suse-linux-gnu-library/3.6/odbc’
Warning in install.packages :
  installation of package ‘odbc’ had non-zero exit status

The downloaded source packages are in
	‘/data_neu/R/xxxxx/tmp/RtmpDDlJR2/downloaded_packages’
> devtools::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                              
 version  R version 3.6.1 (2019-07-05)       
 os       SUSE Linux Enterprise Server 12 SP4
 system   x86_64, linux-gnu                  
 ui       RStudio                            
 language (EN)                               
 collate  en_US.UTF-8                        
 ctype    en_US.UTF-8                        
 tz       Europe/Berlin                      
 date     2020-07-01                         

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source        
 assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.6.1)
 backports     1.1.6   2020-04-05 [1] CRAN (R 3.6.1)
 callr         3.4.3   2020-03-28 [1] CRAN (R 3.6.1)
 cli           2.0.2   2020-02-28 [1] CRAN (R 3.6.1)
 crayon        1.3.4   2017-09-16 [1] CRAN (R 3.6.1)
 desc          1.2.0   2018-05-01 [1] CRAN (R 3.6.1)
 devtools    * 2.3.0   2020-04-10 [1] CRAN (R 3.6.1)
 digest        0.6.25  2020-02-23 [1] CRAN (R 3.6.1)
 ellipsis      0.3.0   2019-09-20 [1] CRAN (R 3.6.1)
 fansi         0.4.1   2020-01-08 [1] CRAN (R 3.6.1)
 fs            1.4.1   2020-04-04 [1] CRAN (R 3.6.1)
 glue          1.4.0   2020-04-03 [1] CRAN (R 3.6.1)
 magrittr      1.5     2014-11-22 [1] CRAN (R 3.6.1)
 memoise       1.1.0   2017-04-21 [1] CRAN (R 3.6.1)
 packrat       0.5.0   2018-11-14 [1] CRAN (R 3.6.1)
 pkgbuild      1.0.7   2020-04-25 [1] CRAN (R 3.6.1)
 pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.6.1)
 prettyunits   1.1.1   2020-01-24 [1] CRAN (R 3.6.1)
 processx      3.4.2   2020-02-09 [1] CRAN (R 3.6.1)
 ps            1.3.2   2020-02-13 [1] CRAN (R 3.6.1)
 R6            2.4.1   2019-11-12 [1] CRAN (R 3.6.1)
 remotes       2.1.1   2020-02-15 [1] CRAN (R 3.6.1)
 rlang         0.4.5   2020-03-01 [1] CRAN (R 3.6.1)
 rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.6.1)
 rstudioapi    0.11    2020-02-07 [1] CRAN (R 3.6.1)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.6.1)
 testthat      2.3.2   2020-03-02 [1] CRAN (R 3.6.1)
 usethis     * 1.6.0   2020-04-09 [1] CRAN (R 3.6.1)
 withr         2.2.0   2020-04-20 [1] CRAN (R 3.6.1)

[1] /data_neu/R/xxxxx/R/x86_64-suse-linux-gnu-library/3.6
[2] /usr/lib64/R/library

@tim-graf
Copy link

tim-graf commented Jul 1, 2020

I could resolve the problem by putting the following line in my $HOME/.R/Makevars file:

CXX11 = g++ -DNANODBC_USE_BOOST_CONVERT=ON

As I have only a very unclear idea, what exactly I am doing there, please use with caution.

@aryoda
Copy link
Contributor

aryoda commented Jul 27, 2020

I could resolve the problem by putting the following line in my $HOME/.R/Makevars file:

CXX11 = g++ -DNANODBC_USE_BOOST_CONVERT=ON

Even with this workaround I could not compile the CRAN version from source:

nanodbc/nanodbc.cpp:38:41: fatal error: boost/locale/encoding_utf.hpp: No such file or directory
#include <boost/locale/encoding_utf.hpp>
                                         ^
compilation terminated.
make: *** [Makevars.win:17: nanodbc.o] Error 1

My environment is R on Windows:


> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

> devtools::find_rtools(debug = T)
Scanning R CMD config CC...
cc_path: C:/Users/Public/local_apps/R/Rtools/mingw_64/bin/gcc
install_path: C:/Users/Public/local_apps/R/Rtools
VERSION.txt
Rtools version 3.5.0.4
Found compatible gcc from R CMD config CC
[1] TRUE

IMHO this is a high prio bug since

  • it concerns the most-recent CRAN version (source)
  • the binary version on CRAN is older (1.2.2 instead of 1.2.3) and lacks some important bug fixes for MS SQL Server

@aryoda
Copy link
Contributor

aryoda commented Jul 27, 2020

Related to #375

See esp. the build error on r-oldrel-windows-ix86+x86_64:
https://cran.rstudio.org/web/checks/check_results_odbc.html

@R-Michael
Copy link

This error also occurs on the following System:

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: SUSE Linux Enterprise Server 12 SP4
Release: 4.12.14-95.37-default

@geekidharsh
Copy link

I am having the same issue with 1.2.3 installation of "odbc"

@dchiu911
Copy link

Any updates yet on this issue?

@kcmtest
Copy link

kcmtest commented Aug 17, 2020

it worked ...thank you

@aryoda
Copy link
Contributor

aryoda commented Aug 18, 2020

@krushnach80 Great news 👍

Could you please post some instructions here how you have installed the package so that it worked (I guess via devtools::github_install).

At least the CRAN version 1.2.3 is still not installable (same error message) so new CRAN release may still be required...

@kcmtest
Copy link

kcmtest commented Aug 18, 2020

@krushnach80 Great news

Could you please post some instructions here how you have installed the package so that it worked (I guess via devtools::github_install).

At least the CRAN version 1.2.3 is still not installable (same error message) so new CRAN release may still be required...

I did run this

devtools::install_version('odbc', '1.2.2', repos="https://cran.rstudio.com/")

and it worked

@aryoda
Copy link
Contributor

aryoda commented Aug 19, 2020

@krushnach80 I think the bug is still there at CRAN. Version 1.2.2 never had a problem and the Windows binary version at CRAN is 1.2.2 but the source version is 1.2.3 (which is the one causing the build error).

If I try to install from CRAN via install.packages("odbc", type = "source") on Windows I still get the same "codecvt" error.

I have also just tried to install via devtools::install_github("r-dbi/odbc") which installs from head but get the same error.

So I would say the bug is still open in the github as well as CRAN version...

PS: Using version 1.2.2 is no good option for me since 1.2.3 has a few important bug fixes for me...

@harrismcgehee
Copy link

Does following r-lib/cpp11#69 help?

g++ --version might be too low?

I could install 1.2.3 when my g++ version was updated.

@ghost
Copy link

ghost commented Sep 22, 2020

@harrismcgehee what's your g++ version?

I am asking because I got the same issue on the following system (g++ 4.8.5):

R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

@aryoda
Copy link
Contributor

aryoda commented Sep 24, 2020

@dkjoluju I have just tried again to install the source pkg from CRAN and still get the same error.

install.packages("odbc", type = "source")

Yes, it may be related to an old g++ version but this version was delivered together with rtools:

During the installation a typical compiler call looks like:

C:/Users/xxx/R/Rtools/mingw_32/bin/g++ -std=gnu++11 -Wall -Iinclude -std=c++11 -pthread -O -MMD -c -o time_zone_if.o src/time_zone_if.cc

My g++/gcc versions are newer (4.9.3) but not the newest:

C:\Users\xxx\R\Rtools\mingw_32\bin>g++ --version
g++ (i686-posix-dwarf, Built by MinGW-W64 project) 4.9.3

C:\Users\xxx\R\Rtools\mingw_64\bin>gcc.exe --version
gcc.exe (x86_64-posix-seh, Built by MinGW-W64 project) 4.9.3

devtools says:

> devtools::find_rtools(T)
Scanning R CMD config CC...
cc_path: C:/Users/xxx/R/Rtools/mingw_64/bin/gcc
install_path: C:/Users/Public/local_apps/R/Rtools
VERSION.txt
Rtools version 3.5.0.4
Found compatible gcc from R CMD config CC
[1] TRUE

SessionInfo is still the same:

sessionInfo()

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
...

@aryoda
Copy link
Contributor

aryoda commented Sep 24, 2020

@harrismcgehee

g++ --version might be too low?
I could install 1.2.3 when my g++ version was updated.

How did you install a newer g++ version (on Windows)? Just via Rtools?

According to the Rtools web site Rtools 3.5 is the correct version for my R version 3.6.1.

If an old version of g++ in Rtools should be the reason for the problem it would mean that odbc could only be installed from the sources on Windows with R 4.x which uses Rtools 4.x...

@harrismcgehee
Copy link

@dkjoluju

> g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
> /opt/rh/devtoolset-9/root/bin/g++ --version
g++ (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

I use ~/.R/Makevars to use a different g++ when installing/compiling packages.

# added 7/28/20 to allow odbc to compile
# I don't understand what CC or CXX represent
# I referenced https://stackoverflow.com/a/43527031/4386615
CC=/opt/rh/devtoolset-9/root/bin/gcc
CXX=/opt/rh/devtoolset-9/root/bin/g++

@aryoda
I am on Linux.

@jimhester
Copy link
Contributor

Fixed by a713d4e

@vishalsharma3003
Copy link

Try Lowering down the version of BH package to 1.78.0-0:

devtools::install_version("BH", "1.78.0-0")

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

10 participants