evan-buss / openbooks

Search and Download eBooks
https://evan-buss.github.io/openbooks/
MIT License
1.87k stars 59 forks source link

Binary not working on Raspbian (armv7l)? #123

Open cip123 opened 1 year ago

cip123 commented 1 year ago

Hello, I am trying to run the arm7 binary on Raspbian GNU/Linux 11 (bullseye) and I am running into the following error

bash: ./openbooks_linux_arm: cannot execute binary file: Exec format error

Am I missing something? Isn't it supposed to work on a Raspberry Pi?

Destreyf commented 1 year ago

@cip123 From what I can see on the build command (here) the arm version is built for arm64.

I'm not 100% sure, but I was under the impression that the armv7l is a 32bit, which would be why it cannot be run on that particular processor. Which Pi is this on?

It's possible to build for armv7 but I'm not sure if the resulting executable will run, here's some basic instructions:

# Get the repo at the 4.5.0 tag
git clone -b v4.5.0 https://github.com/evan-buss/openbooks.git openbooks
cd openbooks

Here's the commands I was able to run on my machine to cross compile to 32bit armv7.

# Build web ui assets
cd server/app
npm install
npm run build
cd ../../cmd/openbooks

# Build golang binary
env GOARCH=arm GOARM=7 GOOS=linux go build -o ../../build/openbooks_linux_armv7

Some notes, from attempting to build, openbooks is currently using nodejs v18 (LTS/Hydrogen), I was able to build using golang v1.19.3.

My output file has the following file openbooks_linux_armv7 data:

openbooks_linux_armv7: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=o_IShGsCC4TvxpOPTfEq/1dWHVVefK_TpC8RlrxB_/EycU46G9JFhGg1AH9dxG/49FYgAO10g-ICsuJ5yu4, with debug_info, not stripped

The executable is ~16MB but I do not have a arm v7 system to test with so I don't know if the executable actually builds/runs correctly.

Hopefully this helps, if the armv7 builds work, it may be worth it to open a pull request with changes to the build system to include the armv7 build, but that's upto the community and ultimately @evan-buss to decide on supporting.