问题
- electron调用dll,打包是怎么配置的,现在可以在打包前正确调用,但是打包之后运行exe报错
- dll文件是一起打包进exe里面的,还是和exe分离的
本地开发环境
打包配置,及运行打包后的exe
代码
import path from 'path'
import ffi from 'ffi-napi'
const libm = ffi.Library(path.resolve('resources/Dll4.dll'), {
add: ['int', ['int', 'int']]
})
export default libm
//vite.config.js
import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {
resolve: {
alias: {
'@renderer': resolve('src/renderer/src')
}
},
plugins: [vue()]
},
pluginOptions: {
//复制resources下的文件到根目录
extraResources: {
form: 'resources/Dll4.dll',
to: './'
}
}
})
相关问题
https://github.com/node-ffi-napi/node-ffi-napi/issues/154