jeroen / mongolite

Fast and Simple MongoDB Client for R
https://jeroen.github.io/mongolite/
284 stars 64 forks source link

R rtools failed to install(build) old archived mongolite_1.6.tar.gz #246

Open yuanqingye opened 1 year ago

yuanqingye commented 1 year ago

I want to install mongodb in R. Since our production system is using old mongodb, the new R mongolite version couldn't get connect. So I decide to install the old version from archive.

However, my win10 using R 4.2.1 faced 1 critical errors

I already downloaded archived package mongolite_1.6.tar.gz from (https://cran.r-project.org/src/contrib/Archive/mongolite/)

I run the command: (the first argument need to be replaced by your downloaded location of file)

install.packages("~/mongolite_1.6.tar.gz", repos = NULL) Then I got error message:

 gcc -shared -s -static-libgcc -o mongolite.dll tmp.def bson.o client.o collection.o cursor.o gridfs.o hex.o mongo_log.o reader.o utils.o -L. -L../windows/openssl-1.1.0f/lib/x64 -Lmongoc -lstatmongoc -Lbson -lstatbson -lssl -lcrypto -lcrypto -lgdi32 -lcrypt32 -lws2_32 -lsecur32 -ldnsapi -lz -Lc:/rtools42/x86_64-w64-mingw32.static.posix/lib/x64 -Lc:/rtools42/x86_64-w64-mingw32.static.posix/lib -LD:/R/R-42~1.1/bin/x64 -lR
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: ../windows/openssl-1.1.0f/lib/x64/libcrypto.a(pem_lib.o):pem_lib.c:(.text+0xfd): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: ../windows/openssl-1.1.0f/lib/x64/libcrypto.a(eng_openssl.o):eng_openssl.c:(.text+0xb): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: ../windows/openssl-1.1.0f/lib/x64/libcrypto.a(eng_openssl.o):eng_openssl.c:(.text+0x18f): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: ../windows/openssl-1.1.0f/lib/x64/libcrypto.a(ui_openssl.o):ui_openssl.c:(.text+0x19): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: ../windows/openssl-1.1.0f/lib/x64/libcrypto.a(ui_openssl.o):ui_openssl.c:(.text+0x782): undefined reference to `__imp___iob_func'
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: ../windows/openssl-1.1.0f/lib/x64/libcrypto.a(ui_openssl.o):ui_openssl.c:(.text+0x7a2): more undefined references to `__imp___iob_func' follow
collect2.exe: error: ld returned 1 exit status
no DLL was created

My sessionInfo()

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_China.utf8  LC_CTYPE=Chinese (Simplified)_China.utf8    LC_MONETARY=Chinese (Simplified)_China.utf8
[4] LC_NUMERIC=C                                LC_TIME=Chinese (Simplified)_China.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Rcpp_1.0.9     jsonlite_1.8.0
jeroen commented 1 year ago

Can you try a newer version of mongolite? The version you are using did not support R4.2.

yuanqingye commented 1 year ago

Can you try a newer version of mongolite? The version you are using did not support R4.2.

Thank you very much for your reply However, if I install the latest version of mongolite, then there is a error message:

Error: Server at 172.19.90.152:3717 reports wire version 4, but this version of libmongoc requires at least 6 (MongoDB 3.6)

Which I believe the package I used is new but our server's mongo db is old, any way to solve this issue? Or do you have already build version of archived packages so I don't need rtools to build my self from the source?

jeroen commented 1 year ago

OK so it looks like the wire version was bumped in libmongoc 1.21.1: https://github.com/mongodb/mongo-c-driver/releases/tag/1.21.0

If we look at the NEWS file from mongolite this means you need mongolite version 2.4.1 or older. There is no need to go all the way back to 1.6.

You can try to install a binary build of 2.4.1 from the CRAN snapshots here: https://cran.microsoft.com/snapshot/2022-03-22/web/packages/mongolite/index.html

So you do:

install.packages("mongolite", repos = "https://cran.microsoft.com/snapshot/2022-03-22")

Or you can try to build it from source from the archive:

install.packages('https://cran.r-project.org/src/contrib/Archive/mongolite/mongolite_2.4.1.tar.gz', repos = NULL)
yuanqingye commented 1 year ago

OK so it looks like the wire version was bumped in libmongoc 1.21.1: https://github.com/mongodb/mongo-c-driver/releases/tag/1.21.0

If we look at the NEWS file from mongolite this means you need mongolite version 2.4.1 or older. There is no need to go all the way back to 1.6.

You can try to install a binary build of 2.4.1 from the CRAN snapshots here: https://cran.microsoft.com/snapshot/2022-03-22/web/packages/mongolite/index.html

So you do:

install.packages("mongolite", repos = "https://cran.microsoft.com/snapshot/2022-03-22")

Or you can try to build it from source from the archive:

install.packages('https://cran.r-project.org/src/contrib/Archive/mongolite/mongolite_2.4.1.tar.gz', repos = NULL)

Sure, thank you very much. I will try it later and let you know the feed back~

yuanqingye commented 1 year ago

OK so it looks like the wire version was bumped in libmongoc 1.21.1: https://github.com/mongodb/mongo-c-driver/releases/tag/1.21.0

If we look at the NEWS file from mongolite this means you need mongolite version 2.4.1 or older. There is no need to go all the way back to 1.6.

You can try to install a binary build of 2.4.1 from the CRAN snapshots here: https://cran.microsoft.com/snapshot/2022-03-22/web/packages/mongolite/index.html

So you do:

install.packages("mongolite", repos = "https://cran.microsoft.com/snapshot/2022-03-22")

Or you can try to build it from source from the archive:

install.packages('https://cran.r-project.org/src/contrib/Archive/mongolite/mongolite_2.4.1.tar.gz', repos = NULL)

Hi I think I can successfully connected to our mongodb through the mongolite the version you provided. Thank you.