Q:

Getting relocation R_x86_64_32 error when compiling assembly file. Works on one VM, not on another

The full error the console is handing back to me is below. I'm using Lubuntu on VirtualBox and VMware (tried both). For some reason it works on my laptop but not on my desktop. After trying to find out more myself through many message forums it seems like something might be wrong with ld itself on my system but I'm not skilled enough to figure out what's going wrong. I know "1 exit status" means failure but that's about it. I don't know why it's failing. Has nothing to do with my code if it'll run on one machine and not the other.
The language I'm programming in is Assembly using the YASM compiler. The script for compilation is linked below the error code
Error code:
/usr/bin/ld: funcs.o: relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

Compiling script:
g++ -g -c $1.cpp -lglut -lGLU -lGL -lm
yasm -g dwarf2 -f elf64 $2.asm -l $2.lst
g++ -g -o $1 $1.o $2.o -lglut -lGLU -lGL -lm

Note that while the above script is slightly more complicated, a simple script such as the one below will not work either.
yasm -g dwarf2 -f elf64 $1.asm
yasm -g dwarf2 -f elf64 $2.asm
gcc -g -o $1 $1.o $2.o

A:

The solution to this problem was to switch from Lubuntu 16.10 to Lubuntu 14.04. The program ended up working fine on my system on that version. Not sure what the source of the error was beyond that. 

