For OpenWrt users
IngwiePhoenix opened this issue · 2 comments
Hello!
I honestly did not know where else to put this - apologies in advance.
My homeserver, a FriendlyElec NanoPi R6s, came with FriendlyWrt which is an OpenWrt fork and I haven't really had any big incentive to move away from that - so I stuck with it. It did, however, cause little issues once in a while. One of them is that when building hydroxide, you will run into this:
/usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lresolv
collect2: error: ld returned 1 exit status
Now, the NanoPi R6s is far more powerful than what the average OpenWrt hardware is expected to be. So to make the most of it, installing apk
can be very helpful. So, here is the workaround:
- Use the latest Go from the official website; the opkg version is quite outdated by now (1.18.x)
- Install and bootstrap APK (
opkg install apk
, then update the apk keyring) - Once apk and go are both ready, install
gcompat
:apk add gcompat
- Since GCC is kinda stupid sometimes, you need to create a symlink:
ln -s /lib/libresolv.so.2 /usr/local/lib/libresolv.so
- GCC doesn't seem to like the
.2
at the end of the filename; so stripping it through linking works around it.
When you now run go build ./cmd/hydroxide
, you should get a nice and working build of Hydroxide!
root@FriendlyWrt /u/o/hydroxide ((v0.2.28)) [1]# ./hydroxide --help
usage: hydroxide [options...] <command>
Commands:
[...]
Hopefuly this helps someone, some day!
You should be able to build with CGO_ENABLED=0
for a completely static executable.
Oh, indeed. Disabling CGO didn't cross me, sorry.
Thank you for the hint!