Even though the file mode is 0777, Android does not allow files on shared storage to be executed by mounting with noexec.
If you run
/system/bin/mount | grep /storage
You'll find something like this:
/data/media on /storage/emulated type sdcardfs (rw,nosuid,nodev,noexec,noatime,low_uid=1023,low_gid=1023,gid=9997,multi_user,mask=0007,reserved=100MB)
^~~~~~
The actual mount point may vary (/storage/sdcard0), but it's surely mounted with noexec.
You should move the executable to Termux's home directory (or somewhere in an ext4 mountpoint) before trying to execute it. That's what CppDroid does. It only runs executables in internal storage, though the source code may be stored anywhere.
If you want to run in Termux, follow this:
$ cp <your-program> ~/a.out
$ chmod 777 ~/a.out
$ ~/a.out
program output
$
For the "position independent executable (PIE)" issue, I suggest you clear data for CppDroid. It uses GCC as compiler, which requires -pie option to generate PIE executable. If you know what settings are messed up you can also try fixing it by yourself.
The Clang compiler provided by Termux generates PIE executables by default.