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

Compile error under R version 4.3.1 (2023-06-16) on Ubuntu 22.04.3 LTS #180

Closed
sammyjava opened this issue Nov 2, 2023 · 8 comments
Closed

Comments

@sammyjava
Copy link

Thanks for writing this package! I'm getting the following error thrown during compilation under R version 4.3.1 (2023-06-16) on Ubuntu 22.04.3 LTS. Suggestions?

write_sheet_file_.cpp: In function ‘cpp11::r_string write_sheet_file_list_(const string&, const cpp11::list_of<cpp11::data_frame>&, const string&, bool, bool, bool, bool, const string&, const string&)’:
write_sheet_file_.cpp:158:21: error: invalid use of incomplete type ‘struct SEXPREC’
  158 |         write_df(x[i], sheet_names[i], row_names, col_names, na_as_string, padding, xml_file);
      |                     ^
In file included from /usr/lib/R/site-library/cpp11/include/cpp11/R.hpp:13,
                 from /usr/lib/R/site-library/cpp11/include/cpp11.hpp:3,
                 from write_sheet_file_.h:3,
                 from write_sheet_file_.cpp:1:
/usr/share/R/include/Rinternals.h:180:16: note: forward declaration of ‘struct SEXPREC’
  180 | typedef struct SEXPREC *SEXP;
      |                ^~~~~~~
write_sheet_file_.cpp:158:21: error: invalid initialization of reference of type ‘const cpp11::data_frame&’ from expression of type ‘SEXPREC’
  158 |         write_df(x[i], sheet_names[i], row_names, col_names, na_as_string, padding, xml_file);
      |                  ~~~^
write_sheet_file_.cpp:54:40: note: in passing argument 1 of ‘void write_df(const cpp11::data_frame&, const string&, bool, bool, bool, bool, std::ofstream&)’
   54 | void write_df(const cpp11::data_frame& x, const std::string& sheet_name, const bool row_names, const bool col_names,
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~^
make: *** [/usr/lib/R/etc/Makeconf:200: write_sheet_file_.o] Error 1
ERROR: compilation failed for package ‘readODS’
* removing ‘/home/shokin/R/x86_64-pc-linux-gnu-library/4.3/readODS’

The downloaded source packages are in
	‘/tmp/RtmpovBwdw/downloaded_packages’
Warning message:
In install.packages("readODS", repos = "https://ropensci.r-universe.dev") :
  installation of package ‘readODS’ had non-zero exit status
@chainsawriot
Copy link
Collaborator

@sammyjava Thank you for your report. I am actually using exactly the same computational environment and I have just tried to run install.packages("readODS", repos = "https://ropensci.r-universe.dev") and it worked. As this problem has been reported previously #174 , I think it could be an issue; and I will try to rewrite write_sheet_file_.cpp:158:21 to at least prevent this irreproducible error. I will give you an update later.

@sammyjava
Copy link
Author

sammyjava commented Nov 2, 2023

Thanks, @chainsawriot ! Sorry I didn't see that closed issue, I should have re-opened it. FWIW, I also got the compile error using install.packages("readODS", repos = "https://ropensci.r-universe.dev") so this is really odd. I'm using the R installed from r-base/jammy-cran40 4.3.1-4.2204.0 all, but since this is a compile error on a cpp file I suppose it's actually the C++ compiler throwing it, which is g++/jammy,now 4:11.2.0-1ubuntu1, perhaps that's a difference?

$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

chainsawriot added a commit that referenced this issue Nov 2, 2023
@chainsawriot
Copy link
Collaborator

@sammyjava Could you give this a try: remotes::install_github("ropensci/readODS@tryf180") ? Thank you very much!

@sammyjava
Copy link
Author

Thanks! I got the same compile error when I chose to NOT install any of the requested updates, which were:

 4: glue        (1.6.1 -> 1.6.2 ) [CRAN]
 5: utf8        (1.2.2 -> 1.2.4 ) [CRAN]
 6: fansi       (1.0.2 -> 1.0.5 ) [CRAN]
 7: cpp11       (0.4.2 -> 0.4.6 ) [CRAN]
 8: pillar      (1.7.0 -> 1.9.0 ) [CRAN]
 9: magrittr    (2.0.2 -> 2.0.3 ) [CRAN]
10: prettyunits (1.1.1 -> 1.2.0 ) [CRAN]
11: bit         (4.0.4 -> 4.0.5 ) [CRAN]
12: withr       (2.4.3 -> 2.5.2 ) [CRAN]
13: tidyselect  (1.1.2 -> 1.2.0 ) [CRAN]
14: tibble      (3.1.6 -> 3.2.1 ) [CRAN]
15: hms         (1.1.1 -> 1.1.3 ) [CRAN]
16: crayon      (1.5.0 -> 1.5.2 ) [CRAN]
17: stringi     (1.7.6 -> 1.7.12) [CRAN]

I can update one by one to see which one solves the problem if you like. Let me know.

@sammyjava
Copy link
Author

Oh, wait, it's a compile error. Shouldn't depend on CRAN package versions. Never mind. :) Or might it?

@sammyjava
Copy link
Author

Just in case it'd different, here it is:

g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG  -I'/usr/lib/R/site-library/cpp11/include'     -fpic  -g -O2 -ffile-prefix-map=/build/r-base-MHXHhT/r-base-4.3.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c write_sheet_file_.cpp -o write_sheet_file_.o
write_sheet_file_.cpp: In function ‘cpp11::r_string write_sheet_file_list_(const string&, const cpp11::list_of<cpp11::data_frame>&, const string&, bool, bool, bool, bool, const string&, const string&)’:
write_sheet_file_.cpp:158:43: error: invalid use of incomplete type ‘struct SEXPREC’
  158 |         cpp11::data_frame current_df = x[i];
      |                                           ^
In file included from /usr/lib/R/site-library/cpp11/include/cpp11/R.hpp:13,
                 from /usr/lib/R/site-library/cpp11/include/cpp11.hpp:3,
                 from write_sheet_file_.h:3,
                 from write_sheet_file_.cpp:1:
/usr/share/R/include/Rinternals.h:180:16: note: forward declaration of ‘struct SEXPREC’
  180 | typedef struct SEXPREC *SEXP;
      |                ^~~~~~~
write_sheet_file_.cpp:158:43: error: conversion from ‘SEXPREC’ to non-scalar type ‘cpp11::data_frame’ requested
  158 |         cpp11::data_frame current_df = x[i];
      |                                        ~~~^
make: *** [/usr/lib/R/etc/Makeconf:200: write_sheet_file_.o] Error 1

@chainsawriot
Copy link
Collaborator

@sammyjava It would be much better if you can at least update cpp11; because cpp11 0.4.2 is like 2 years ago.

@sammyjava
Copy link
Author

Good eye! Yup, that solved the compile problem, just updating cp11. Thanks!

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