Thread overview
Statically compiled binary with C interop crashes.
Apr 17
yabobay
Apr 18
yabobay
April 17

I'm using dray in my project with dub, here's the relevant parts of the dub.json:

    "dependencies" : {"dray": "~>4.2.0-r3"},
    "dflags-ldc": ["--static"],
    "lflags": ["-static"]

In my regular setup with Debian, i can compile and run my code dynamically just fine, but i wanted to make a static executable so i made an alpine container where i was able to do that, but running it gives me this:

INFO: Initializing raylib 4.2
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
WARNING: GLFW: Error: 65544 Description: X11: Failed to load Xlib
fish: Job 1, './ttn' terminated by signal SIGSEGV (Address boundary error)

Why would it need to load Xlib? Shouldn't it be packed in with the executable?

April 17

On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote:

>

I'm using dray in my project with dub, here's the relevant parts of the dub.json:

[...]

İt seems your issue is related to the raylib itself, neither the binding you use nor the d programming language. İnstalling x11 development package may resolve the issue.

April 18

On Wednesday, 17 April 2024 at 15:24:07 UTC, Ferhat Kurtulmuş wrote:

>

On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote:

>

I'm using dray in my project with dub, here's the relevant parts of the dub.json:

[...]

İt seems your issue is related to the raylib itself, neither the binding you use nor the d programming language. İnstalling x11 development package may resolve the issue.

I have the equivalent package installed both on the build machine and the machine i tried to run the code on. Also, no i shouldn't. It's supposed to be a statically linked binary

April 18

On Thursday, 18 April 2024 at 11:05:07 UTC, yabobay wrote:

>

On Wednesday, 17 April 2024 at 15:24:07 UTC, Ferhat Kurtulmuş wrote:

>

On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote:

>

I'm using dray in my project with dub, here's the relevant parts of the dub.json:

[...]

İt seems your issue is related to the raylib itself, neither the binding you use nor the d programming language. İnstalling x11 development package may resolve the issue.

I have the equivalent package installed both on the build machine and the machine i tried to run the code on. Also, no i shouldn't. It's supposed to be a statically linked binary

libglfw, which is embedded statically in raylib, is trying to dynamically open libx11.

https://github.com/raysan5/raylib/blob/c1fd98591d7996dd45a5ce9ecbb4b571607d417b/src/external/glfw/src/x11_init.c#L1269

So what it appears to be is, glfw tries to open a specified libx11, and fails, and then the program errors and exits.

The library selected is determined by a compiler directive (see above that line), you may have to rebuild raylib with the right directive based on what libx11 you have on the system.

Note, these are not dynamically linked libraries, but dynamically loaded libraries. That is, the system linker ldd is not pre-loading the library, raylib is finding the library and loading it at runtime.

-Steve