Libc functions undefined when linking

Ben Jones fake at fake.fake
Tue Jan 4 21:40:43 UTC 2022


On Tuesday, 4 January 2022 at 21:34:46 UTC, Adam D Ruppe wrote:
> On Tuesday, 4 January 2022 at 21:22:26 UTC, Ben Jones wrote:
>>>   * frame #0: 0x0000000000000000
>
> That's null, meaning the library wasn't loaded.
>
> simpledisplay actually doesn't need -lX11 since it always 
> dynamic loads the libraries. Normally it throws when this fails 
> though instead of keeping null but that check is also 
> initialized in a static constructor....
>
> With your different build process though, do you still have a D 
> main? If druntime is not fully initialized these libs won't 
> load nor will it set the success flag. So that'd leave null.
>
> You can also quite possibly try to load it yourself:
>
>         xlib.loadDynamicLibrary();
>         xext.loadDynamicLibrary();
>
> in your main and see if it works. Then the variable to check is 
> `if(!librariesSuccessfullyLoaded)` and see if it set it up.

Ah, that was the issue.  I had a linker error when I had a normal 
d main, so I made main `extern(C)`.  Looks like that wasn't 
actually necessary (I think maybe I had actually just put the .o 
with main in the wrong place so the symbol was missing).  
Reverting it to extern(D) fixed it on mac and linux.  Thanks so 
much for the help!


More information about the Digitalmars-d-learn mailing list