Can't run executable built with Dub - OS thinks it is shared library

Stephen C schatelain at msn.com
Wed Oct 27 18:59:23 UTC 2021


On Wednesday, 27 October 2021 at 03:39:53 UTC, Elronnd wrote:>
On Wednesday, 27 October 2021 at 03:39:53 UTC, Elronnd wrote:
> Ensure that you have a file named 'app.d' in your source/src 
> directory.
>
> Alternately, set "targetType": "executable" in your dub.json.
>
> Alternately, fix whatever graphical thingy you are using that 
> lets you click on file names.

My project is a game (using graphics). I've set all the necessary 
fields in dub.json. I can run it from the command line which 
opens the window and starts the game correctly. But it will not 
run when started from the gui by clicking on the icon.

The output from the "file" command shows that the OS thinks this 
is a shared object. (see below)

_ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), 
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, 
BuildID[sha1]=7956a95c2464895f9b02c1dab1b11961a69f56f4, for 
GNU/Linux 3.2.0, not stripped_

I even created a Makefile and compiled it with make/dmd and I get 
the same result. Is this a Linux-specific issue when compiling 
with the -fPIC option (set in dmd.conf). And is it possible to 
compile a project using dmd without the -fPIC option?

I tried to remove -fPIC from dmd.conf, but it fails with the 
below message:

_relocation R_X86_64_32 against symbol `__dmd_personality_v0' can 
not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status_

This only started happening when I upgraded my Linux and DMD 
versions, so I assume it's a recent change in one of those.


More information about the Digitalmars-d mailing list