zoukankan      html  css  js  c++  java
  • Ghostscript 中 ps2pdf 命令在 windows msys 下的运行错误问题。

      前两天看到了 miloyip/game-programmer 这个项目觉得特别有用,真是好东西,明确了指出了学习路线,尤其是新手。不过打开看,有些书对应的亚马逊链接是无效的,比如《Tricks of the 3D Game Programming Gurus》等书的链接都是:https://www.amazon.com/dp// 这种无效链接,于是我就 fork 了一份把这些链接都补上了,提交了一个 pull request,就看作者什么时候能通过 merge 了,修改好我就尝试编译测试,由于是直接通过 make 生成,我 windows 本机已经安装了 msys,于是我就安装了 windows 版本的:Graphviz 2.38Ghostscript 9.16 (ps2pdf), cpdf, 安装完后把可执行文件的目录添加到 PATH 系统环境变量,Ghostscript 需要把安装目录下的 bin, lib,都添加进去;ok 以后运行发现到最后总是 提示 ps2pdfwr: gs not found;翻阅了下本地 manual Ps2pdf.htm,其中写道:

    All of these scripts actually call a script named ps2pdfwr or ps2pdfxx. The Unix ps2pdfwr script assumes that the Ghostscript executable is named gs; it is unlikely that you will need to change this. The DOS and MS Windows ps2pdfxx.bat script uses the value of the GSC environment variable, if defined, as the name of the executable; otherwise the script assumes the executable is named gswin32c. So in these environments, if the executable has a different name, you must set GSC to the name of the executable.

      即是说 ps2pdf 最终就是调用 ps2pdfwr 或者 ps2pdfxx,这两个脚本在 unix 下使用可执行文件:gs,不需要任何修改,但在 dos 和 windows 下 ps2pdfxx.bat 先使用 GSC 环境变量的值,如果未定义此环境变量则默认使用的可执行文件为 gswin32c,所以如果你安装的是64位话,可执行文件是 gswin64c.exe,所以需要添加名称 GSC 的环境变量,值为 gswin32c。

      但是按照上述步骤操作后,依然提示同样错误,打开 ps2pdfxx 后,脚本为:

    GS_EXECUTABLE=gs
    gs="`dirname "$0"`/$GS_EXECUTABLE"
    if test ! -x "$gs"; then
        gs="$GS_EXECUTABLE"
    fi
    GS_EXECUTABLE="$gs"
    
    ... 省略 ...
    
    exec "$GS_EXECUTABLE" $OPTIONS -q -P- -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sstdout=%stderr "-sOutputFile=$outfile" $OPTIONS -c .setpdfwrite -f "$infile"

      这里没有使用 GSC 环境变量,而是直接使用了 gs 作为可执行文件名称,外部修改 GS_EXECUTABLE 的值,或者设置成环境变量也没用,因为一开始就被修改成 "gs" 了,不过这个问题直接使用 cmd 命令行是没有问题的,只在 msys 命令行下有这个错误,于是我就直接加了个名为 gs 的 shell 脚本放到 lib 下,内容为:

    gs="`dirname "$0"`/$GSC"
    if test ! -x "$gs"; then
        gs="$GSC"
    fi
    exec "$gs" "$@"

      重新在 msys 命令行中 make 或者直接使用 ps2pdf 命令来测试,之前的 "gs not found" 的错误不见了,文档的整个编译生成过程顺利通过。

  • 相关阅读:
    java面试-Java内存模型(JMM)
    github常用操作
    java面试-生产环境服务器变慢,谈谈你的诊断思路
    java面试-JVM调优和参数配置,如何查看JVM系统参数默认值
    java面试-死锁产生、定位分析和修复
    Scalable IO in Java【java高效IO】
    java面试-JDK自带的JVM 监控和性能分析工具用过哪些?
    Docker简介
    使用docker部署项目
    公司系统遇到的问题,虽然解决了,但是,不知道原因。贴下图片,供下次参考
  • 原文地址:https://www.cnblogs.com/yaukey/p/6583188.html
Copyright © 2011-2022 走看看