简体   繁体   English

如何在 Windows 上构建 qpdf?

[英]How to build qpdf on Windows?

When running the checks for my R-package (via devtools::check() ) I face the warning ''qpdf' is needed for checks on size reduction of PDFs .在运行对我的 R 包的检查时(通过devtools::check() ),我面临警告''qpdf' is needed for checks on size reduction of PDFs I found this question were it was suggested (if I understood the answer correctly) to run Sys.which(Sys.getenv("R_QPDF", "qpdf")) and see whether qpdf is found or not.我发现这个问题是建议(如果我正确理解答案)运行Sys.which(Sys.getenv("R_QPDF", "qpdf"))并查看是否找到 qpdf 。 In my case this just returns在我的情况下,这只是返回

qpdf ""

so, I think I didn't install qpdf correctly.所以,我想我没有正确安装 qpdf。 Unfortunately it seems to be quite complicated to install qpdf on Windows.不幸的是,在 Windows 上安装 qpdf 似乎相当复杂。 My first side question is: does it really is so painful and complicated to install qpdf for Windows or is there an easy solution?我的第一个问题是:为 Windows 安装 qpdf 真的那么痛苦和复杂,还是有一个简单的解决方案?

I've followed the instructions until it is said to add C:\\MinGW-w64\\bin and C:\\MinGW-w64\\lib\\mingw to the PATH variable.我一直按照说明进行操作,直到据说将 C:\\MinGW-w64\\bin 和 C:\\MinGW-w64\\lib\\mingw 添加到 PATH 变量中。 But then I don't find further specific instructions to install qpdf, only about how to build qpdf with different other programs.但是后来我没有找到安装qpdf 的进一步具体说明,只是关于如何使用不同的其他程序构建qpdf。 The second side question is: is my assumption correct that after I've build qpdf it is installed ?第二个问题是:我的假设是否正确,在我构建了qpdf 之后它被安装了 But the real question is: What is the best way to build qpdf?但真正的问题是:构建 qpdf 的最佳方法什么? I tried the ./config-mingw32 and ./config-mingw64 commands from the section "Building with MinGW" in my C:\\MinGW\\msys\\1.0\\bin\\bash.exe but got the error messages ./config-mingw32: No such file or directory and have no idea how to fix this issue.我在 C:\\MinGW\\msys\\1.0\\bin\\bash.exe 的“Building with MinGW”部分尝试了./config-mingw32./config-mingw64命令,但收到了错误消息./config-mingw32: No such file or directory ,也不知道如何解决这个问题。


I'm using Windows 10, R version 3.3.2 Patched (2017-01-07 r71934) -- "Sincere Pumpkin Patch" and RStudio 1.0.136.我使用的是 Windows 10,R 版本 3.3.2 已修补(2017-01-07 r71934)——“Sincere Pumpkin Patch”和 RStudio 1.0.136。

You basically do not need to build the file on windows.您基本上不需要在 Windows 上构建文件。 Please follow three steps below:请按照以下三个步骤操作:

  1. Download qpdf for windows from https://sourceforge.net/projects/qpdf/?source=typ_redirecthttps://sourceforge.net/projects/qpdf/?source=typ_redirect下载适用于 Windows 的 qpdf
  2. Extract files in a temp folder提取临时文件夹中的文件
  3. Copy the contents of the bin folder to %SystemRoot%\\System32bin文件夹的内容复制到 %SystemRoot%\\System32

job done!任务完成!

Sys.which(Sys.getenv("R_QPDF", "qpdf"))
                             qpdf 
"C:\\WINDOWS\\SYSTEM32\\qpdf.exe" 

To flesh out an answer provided elsewhere :充实其他地方提供答案

If you are running the 32-bit version of R, it is important that you download the 32-bit version of qpdf, which is the version linked from the SourceForge homepage.如果您运行的是 32 位版本的 R,那么下载qpdf 的 32 位版本很重要,这是从 SourceForge 主页链接的版本。 If you are running a 64-bit installation of R, you will need to do a bit of digging to locate the 64-bit version of qpdf, which is buried a little more deeply (version 10.0.1 is listed here ).如果您正在运行 R 的 64 位安装,则需要进行一些挖掘才能找到埋藏更深的 64 位版本的 qpdf(此处列出10.0.1 版)。

Rather than copying files to C:/Windows/System32 , a potentially safer option is to extracted the zipped qpdf directory to C:\\Program Files .不是将文件复制到C:/Windows/System32 ,一个可能更安全的选择是将压缩的 qpdf 目录解压缩到C:\\Program Files If you do this, you'll need to add C:\\Program Files\\qpdf-version_number\\bin to your system PATH under the environment variables.如果这样做,您需要将C:\\Program Files\\qpdf-version_number\\bin到环境变量下的系统PATH

  • To do this within R, run Sys.setenv('PATH' = paste0('C:\\Program Files\\qpdf-version_numer\\bin;', Sys.getenv('PATH')))要在 R 中执行此操作,请运行Sys.setenv('PATH' = paste0('C:\\Program Files\\qpdf-version_numer\\bin;', Sys.getenv('PATH')))
  • To do this in Windows, open the start menu, type "edit the system environment variables" to open the System Properties, and at the bottom of the "Advanced" tab click "Environment variables".要在 Windows 中执行此操作,请打开开始菜单,键入“编辑系统环境变量”以打开“系统属性”,然后在“高级”选项卡底部单击“环境变量”。 Find the "Path" entry under "System variables" and click "Edit".在“系统变量”下找到“路径”条目,然后单击“编辑”。 Then, re-start R so it picks up the modified PATH .然后,重新启动 R 以获取修改后的PATH

One further step may be required to convince Windows that pqdf is safe to run.可能需要进一步的步骤来让 Windows 相信 pqdf 可以安全运行。 Navigate to C:\\Program Files\\qpdf-version_numer\\bin and execute qpdf.exe (by double-clicking).导航到C:\\Program Files\\qpdf-version_numer\\bin并执行qpdf.exe (双击)。 Windows 10 throws up a security warning, as it's an unrecognized executable file. Windows 10 发出安全警告,因为它是一个无法识别的可执行文件。 You'll need to use the more options link to find the button to run the program.您需要使用更多选项链接来找到运行程序的按钮。 This done, Windows will recognize the file as safe to run and allow other software, including R, to use it.完成后,Windows 会将该文件识别为可以安全运行并允许其他软件(包括 R)使用它。

Setup MSVC environment, then configure and build as follows:设置MSVC环境,然后配置和构建如下:

./config-msvc
make

Here is a more detailed steps: https://github.com/qpdf/qpdf/blob/master/README-windows.md这是更详细的步骤: https : //github.com/qpdf/qpdf/blob/master/README-windows.md

Hope it helps.希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM