www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Statically compiled binary with C interop crashes.

reply yabobay <yabobay yahoo.com> writes:
I'm using [dray](https://code.dlang.org/packages/dray) in my 
project with dub, here's the relevant parts of the dub.json:

```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?
Apr 17
parent reply Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote:
 I'm using [dray](https://code.dlang.org/packages/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.
Apr 17
parent reply yabobay <yabobay yahoo.com> writes:
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](https://code.dlang.org/packages/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
Apr 18
parent Steven Schveighoffer <schveiguy gmail.com> writes:
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](https://code.dlang.org/packages/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
Apr 18