I referenced this link because it addresses the same error you are getting:
final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status
I don’t know if your problem is due to the g++ version you are using, but there have been cases where installing a different version of some software has, for some reason, resolved the issue. The post “Cannot set mode in MAVProxy”, while lengthy, may illustrate what I am talking about.
FYI:
From my desktop:
david@hp-office:~$ g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Here is a snippet from my System Information report:
System: Host: hp-office Kernel: 5.4.0-74-generic x86_64 bits: 64 compiler: gcc v: 7.5.0
Desktop: Cinnamon 4.4.8 wm: muffin dm: LightDM Distro: Linux Mint 19.3 Tricia
base: Ubuntu 18.04 bionic
The latest version of g++ is 11.
I realize that “try this, try that, etc.” to resolve a problem is not very satisfying. However, often problems are caused by version incommpatabilites.
Hope that this is of some help.