windows 下的 master emacs 无法加载 rime 的动态链接库

使用的是这里打包的 emacs,通过对应的 scoop bucket 安装的,安装这个是因为,这个包带有 native compt 支持

安装完成后发现 emacs-rime 编译 dll 顺利,但是会报告以下问题:

rime--load-dynamic-module: Module could not be opened: "c:/Users/jinzh/.emacs.d/elpaca/builds/rime/librime-emacs.dll", "找不到指定的程序。"

通过 vs 的 dumpbin 分析 librime-emacs 动态链接库可以看到,仅仅是依赖三个库:

  • KERNEL32.dll
  • msvcrt.dll
  • librime.dll

该三个库均确定在系统的 PATH 中,因为 scoop 源中官方的 emacs 加载 rime 模块很顺利

这究竟是为何呢?

并且已经通过以下代码测试过,该版本的 emacs 支持动态模块加载

(if (boundp 'module-file-suffix)
    (message "Dynamic module loading is supported.")
  (message "Dynamic module loading is not supported."))

rime–load-dynamic-module . 找不到程序

报错信息简化之后,好像再说找不到 Emacs 的动态模组。

能再详细说说吗 我不太懂emacs的这个加载原理

你的配置包含这一句么?

(rime-emacs-module-header-root "/opt/homebrew/include")

不包含该句,zsbd

但是 dll 编译是顺利的,还需要额外指定头文件吗 我在使用29.3的时候不加这个也没问题

不太清楚 Windows 下 Emacs 的配置和情况,自 24.1 之后就没有在 Windows 下用过 emacs。

但之前我看 emacs-rime 的配置上,说明了需要这个动态模组,去编译必须的文件。

应该不是该问题

解决了吗, 我也遇到相同的问题, 使用 scoop install emacs-kl 安装的

我的已经解决了,之前是通过scoop 安装了 gcc, mingw, librime等,现在是通过scoop 安装msys2, 然后把msys2的mingw64环境变量放到最前面,然后通过mingw64环境运行emacs,成功用上了rime

还是不对,是用的29.4版本。。

rime 那个库用老版本看看。

1.scoop install emacs-kl 2.scoop install msys2 (msys2安装 ucrt64的依赖) 3.ucrt64环境:手动执行下面的命令 gcc lib.c -o librime-emacs.dll -fPIC -O2 -Wall -I c:/Users/oj/scoop/apps/emacs-kl/current/include/ -shared -lrime 4.启动就正常了

1 个赞

我用ucrt的gcc编译后还是不行啊

$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\Users\jinzh\scoop\apps\msys2\2024-07-27\ucrt64\bin\gcc.exe
COLLECT_LTO_WRAPPER=C:/Users/jinzh/scoop/apps/msys2/2024-07-27/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-14.2.0/configure --prefix=/ucrt64 --with-local-prefix=/ucrt64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/ucrt64/include --libexecdir=/ucrt64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,rust,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/ucrt64 --with-mpfr=/ucrt64 --with-mpc=/ucrt64 --with-isl=/ucrt64 --with-pkgversion='Rev1, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --enable-plugin --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (Rev1, Built by MSYS2 project)

要不你换 pyim 吧