electron-userland/electron-builder

Uncaught Error: libsqlcipher.so.0: cannot open shared object file: No such file or directory.

pasupathy1611 opened this issue · 13 comments

  • Version: 20.7.1
  • Target: Linux, MAC, Windows

Is there any way to include the sqlcipher shared object in the build config.
I’m using https://github.com/mapbox/node-sqlite3 SQLCipher with --build-from-source and also attached the build property.

build.txt

node-sqlite3 doesn't provide prebuilt binaries and so, you can build app only on the target platform. Do build for Linux on Linux?

Yes I'm building for a linux dist on my local ubuntu machine.

Do the shared libraries get bundled in the asar?

No. You should bundle it somehow. What do you use — AppImage or Snap?

My target for
linux is AppImage
mac is DMG
windows is NSIS

Is there a recommended solution to include shared libs in a cross platform way?

"build": {
		"productName": "retail",
		"appId": "com.electron.evoluzin-retail",
		"compression": "store",
		"linux": {
			"category": "Office",
			"target": [
				{
					"target": "AppImage",
					"arch": [
						"x64"
					]
				}
			]
		},
		"mac": {
			"icon": "resources/osx/icon.icns",
			"category": "public.app-category.business",
			"target": [
				{
					"target": "dmg",
					"arch": [
						"x64"
					]
				}
			]
		},
		"dmg": {
			"icon": "resources/osx/dmg-icon.icns",
			"background": "resources/osx/dmg-background.png",
			"contents": [
				{
					"x": 110,
					"y": 150
				},
				{
					"x": 240,
					"y": 150,
					"type": "link",
					"path": "/Applications"
				}
			]
		},
		"win": {
			"target": [
				{
					"target": "nsis",
					"arch": [
						"x64"
					]
				}
			],
			"icon": "resources/windows/icon.ico"
		},
		"nsis": {
			"oneClick": true,
			"installerHeaderIcon": "resources/windows/setup-icon.ico"
		},
		"extraResources": [
			{
				"from": "build/assets",
				"to": "assets",
				"filter": [
					"db/*",
					"export/**/*",
					"data/**/*"
				]
			}
		],
		"directories": {
			"app": "build",
			"buildResources": "resources",
			"output": "dist"
		},
		"files": [
			"**/*",
			"!**/node_modules/*/{README.md,README,readme.md,readme,test}",
			"!**/node_modules/.bin",
			"!**/node_modules/fs-jetpack/spec${/*}",
			"!**/*.{o,hprof,orig,pyc,pyo,rbc,db,sql}",
			"!**/._*",
			"!**/{.DS_Store,.git,.hg,.svn,CVS,RCS,SCCS,__pycache__,thumbs.db,.gitignore,.gitattributes,.editorconfig,.idea,appveyor.yml,.travis.yml,circle.yml}",
			"!assets/{db,export,data}${/*}"
		],
		"nodeGypRebuild": false,
		"npmRebuild": false
	}

Got your error. So, it is definitely not your misconfiguration or user error.

Please try to copy shared lib (so file) to usr/lib. To do it, please define extraFiles configuration in the linux (under the field linux).

I hope this hint will help you. Please set debug env DEBUG=electron-builder and in this case stage dir for AppImage will be not deleted. So you can easily ensure after build that so file copied correctly.

Do know where to grab so file?

I have the location for the so files. /usr/local/lib/libsqlcipher.so

Do I place the dll files in usr/lib for windows? Or is there a different location for windows libs?

for windows

I guess sqlite3 binary for windows is static. You only need this for Linux (and maybe for macOS). That's why "under the field linux"

Using extraFiles configuration under the field linux in package.json for copying the library file it works. thank you.

sorry, using extraFiles is not working with the latest version of electron. but have to set the environment variable LD_LIBRARY_PATH is there any other way to get this work?

@pasupathy1611 extraFiles will be supported again in next 20.15.0 version.

I have seen many opened and closed issues redirecting to here, but I didn't find a clear example to figure out how to proceed with this. @develar Could you provide a good example?

@slorenzo adding this to package.json is what worked for us:

{
  "build": {
    "linux": {
      "target": [
        "Appimage",
        "snap"
      ],
      "extraFiles": [
        {
          "from": "/usr/lib/x86_64-linux-gnu/libhogweed.so.4",
          "to": "usr/lib/libhogweed.so.4"
        },
        {
          "from": "/usr/lib/x86_64-linux-gnu/libnettle.so.6",
          "to": "usr/lib/libnettle.so.6"
        }
      ]
    }
  }
}

from: is the file location on your build host
to: is the file location within the image

The AppImage layout looks like this when extracted with ./MyApp.AppImage --appimage-extract:

~/squashfs-root » tree
.
├── usr
│   ├── lib
│   │   ├── libhogweed.so.4
│   │   └── libnettle.so.6