Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@trevorld
Copy link
Contributor

@trevorld trevorld commented Jun 28, 2025

  • This compiled locally on my Linux laptop with gcc 11.4.0 and R CMD check passed with R 4.5.1 with zero notes/errors/warnings.

  • When compiling there were a couple [-Wpedantic] warnings about warning: extra ;

  • There was also a couple [-Wsign-compare] warnings of comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<QPDFPageObjectHelper>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]

  • There are new optional qpdf features that seem to need new headers for OpenSSL, GNUTLS, and/or Zopfli:

    • I've undefined USE_CRYPTO_GNUTLS, USE_CRYPTO_OPENSSL, ZOPFLI to disable these
    • I've not included libqpdf/QPDFCrypto_openssl.o and libqpdf/QPDFCrypto_gnutls.o in the LIBQPDF target in the Makevars
  • Procedure to update bundled library:

    1. I replaced the contents in src/include/ and src/libqpdf with contents from the v12.2.0 tag of qpdf source using rsync --delete --checksum.
    2. I renamed src/libqpdf/qpdf/qpdf-config.h.in to src/libqpdf/qpdf/qpdf-config.h and manually defined and undefined the variables:
    • If the variable previously existed here use the same values (or continue to leave it commented out with a #undef)
    • Removed variables previously existed if they no longer seem to be used by the bundled qpdf
    • I've undefined USE_CRYPTO_GNUTLS, USE_CRYPTO_OPENSSL, ZOPFLI as mentioned previously
    • I've enabled the "native" crypto feature which I'm not entirely sure what this means but it seems to compile for me locally without external headers
    • I've undefined HAVE_MALLOC_INFO and HAVE_OPEN_MEMSTREAM which seemed to work fine on Linux but caused issues with Windows and/or macOS
  1. I manually updated Makevars so that in the LIBQPDF target every .cc file in src/libqpdf has a correspending .o except for libqpdf/QPDFCrypto_openssl.o and libqpdf/QPDFCrypto_gnutls.o

closes #23

trevorld added 3 commits June 27, 2025 16:48
* qpdf v12.2.0 is most recent release
  and is supposed to be the last release
  using C++-17 which should be supported
  by `gcc-8` as still used by `rhel8`.
* `libqpdf` copied over from `qpdf` v12.2.0 sources
  using `rsync --delete --checksum` and all changes
  to that directory commited in this commit.
@trevorld
Copy link
Contributor Author

Compilation error from R-CMD-check.yaml / macos-14 (release) was:

libqpdf/QUtil.cc:38:11: fatal error: 'malloc.h' file not found
# include <malloc.h>
          ^~~~~~~~~~
1 error generated.
make: *** [libqpdf/QUtil.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: compilation failed for package ‘qpdf’

Compilation error from R-CMD-check.yaml / windows-latest (release) was

libqpdf/QUtil.cc: In function 'size_t QUtil::get_max_memory_usage()':
libqpdf/QUtil.cc:1953:15: error: 'open_memstream' was not declared in this scope
 1953 |     FILE* f = open_memstream(&buf, &size);
      |               ^~~~~~~~~~~~~~
libqpdf/QUtil.cc:1957:5: error: 'malloc_info' was not declared in this scope
 1957 |     malloc_info(0, f);
      |     ^~~~~~~~~~~
make: *** [C:/R/etc/x64/Makeconf:294: libqpdf/QUtil.o] Error 1
make: *** Waiting for unfinished jobs....
ERROR: compilation failed for package 'qpdf'

@trevorld
Copy link
Contributor Author

The R-CMD-check.yaml / windows-latest (4.2) seems to fail because R 4.2 defaults to C++-14 but this bundled version of qpdf needs C++-17. It seems we need to add something like CXX_STD = CXX17 to src/Makevars via the configure but only if R is less than R 4.3 otherwise CRAN might complain? Is something like the following the approach you'd want to do or is their a simpler way to do this?

The rocky-8 amd64 seems be failing for unrelated reasons with no artifact to examine:

 Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
Execution halted
Error: Process completed with exit code 1.

@jeroen
Copy link
Member

jeroen commented Jun 28, 2025

I think setting CXX_STD = CXX17 in src/Makevars is allowed? Let's try it and see if it gives a note.

@jeroen
Copy link
Member

jeroen commented Jun 28, 2025

The RHEL-8 issue was a bug on my end, sorry for that. Should be fixed in a few minutes.

@jeroen
Copy link
Member

jeroen commented Jun 28, 2025

The linking error on Windows 4.2 seems to suggest we are missing libqpdf/QPDFJob.cc ? Although I am not sure why it would only be needed on that platform.

@jeroen jeroen merged commit c801a6b into ropensci:master Jun 28, 2025
17 checks passed
@jeroen
Copy link
Member

jeroen commented Jun 28, 2025

Thanks!

@trevorld trevorld deleted the issue23update.qpdf branch June 28, 2025 21:01
@jeroen
Copy link
Member

jeroen commented Jun 29, 2025

This is on CRAN now. Let me know if you have additional suggestions.

@jeroen
Copy link
Member

jeroen commented Jun 30, 2025

Hmm it looks like the build now fails with LTO -> #25

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

Successfully merging this pull request may close these issues.

Bundle a newer version of qpdf

2 participants