欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

Ghostscript版本问题引发asy错误

最编程 2024-08-04 07:40:16
...

很简单的一个 asy 文件,就是插入一个 pdf 图片,然后想再画点东西上去,比如一条线,代码如下:

settings.tex="pdflatex";
label(KEY="1",graphic("test.pdf","width=16cm"));
draw(KEY="3", (-190,100)--(190,100), rgb(0,0,0)+0.5);

然而编译时却总是出错,如下:

Error: /undefined in .setfillconstantalpha
Operand stack:
   1
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1988   1   3   %oparray_pop   --nostringval--   1977   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:739/1123(ro)(G)--   --dict:0/20(G)--   --dict:79/200(L)--
Current allocation mode is local
Current file position is 344
GPL Ghostscript 9.50: Unrecoverable error, exit code 1
  _shipout(prefix,f,currentpatterns,format,wait,view,t);
          ^
/usr/local/share/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed

asy 版本是 2.82。如果把 draw 画线那句去掉倒是能输出,但一旦加上 draw 语句就出错。搜索找到https://sourceforge.net/p/asymptote/discussion/409349/thread/6fd84befa5/?limit=25 说是因为 ghostscript 版本的问题,9.52, 9.53 可以,而更早的版本则不行,但是 9.54 由于有 bug 也不行。一看我机器上的 gs 版本是 9.50,于是去官方下载最新的 9.56.1,选择编译好的版本,里面就一个可执行文件。系统上原来的 ghostscript 位于 /usr/bin/ghostscript -> /usr/bin/gs,由于路径里设了 /usr/local/bin 优先,于是把 9.56 版的 gs 可执行文件复制的 /usr/local/bin 下并链接一个 ghostscript,然后再运行 asy,正常了!

推荐阅读