I am trying to get graphics working in D. All seems well with bindbc sdl, but I hit a nitpick: I prefer to be able to create a standalone executable when possible. I cannot get bindbc to be happy with sdl .a files. It's a small problem, but if there's a simple solution, I'm eager to hear it.
Thread overview | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 24, 2021 Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ishax | On Saturday, 24 April 2021 at 15:58:26 UTC, Ishax wrote: >I am trying to get graphics working in D. All seems well with bindbc sdl, but I hit a nitpick: I prefer to be able to create a standalone executable when possible. I cannot get bindbc to be happy with sdl .a files. It's a small problem, but if there's a simple solution, I'm eager to hear it. .a are object files for linux right? for static usage make sure you remove the part of code where you manually loadSDL, since it is not needed for static compilation make sure to use this subConfiguration: https://github.com/BindBC/bindbc-sdl#via-dub-subconfigurations and then make sure to add the lib to link in your "lflags" or as a "sourceFiles", both will work send us your dub.json file maybe some things are misconfigured? |
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to russhy | On Saturday, 24 April 2021 at 16:02:27 UTC, russhy wrote: >.a are object files for linux right? Are they? I'm not very familiar with c++. I'm using windows. For that matter I should mention I'm using dub in vscode. >send us your dub.json file maybe some things are misconfigured?
The following works fine but links dynamically:
|
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ishax | On Saturday, 24 April 2021 at 16:10:13 UTC, Ishax wrote: >On Saturday, 24 April 2021 at 16:02:27 UTC, russhy wrote: >.a are object files for linux right? Are they? I'm not very familiar with c++. I'm using windows. For that matter I should mention I'm using dub in vscode. >send us your dub.json file maybe some things are misconfigured?
The following works fine but links dynamically:
on windows, for static compilation you have to use ".lib" files, not ".a" also you are missing the
|
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to russhy | On Saturday, 24 April 2021 at 16:13:12 UTC, russhy wrote: >on windows, for static compilation you have to use ".lib" files, not ".a" also you are missing the
So I have the lib files. It's failing with only an exit code. No window is appearing. It's using the same D code as with the dynamic setup which I was able to produce a window with.
|
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ishax | Yet the .exe functions if I supply it with .dlls. Thats silly. |
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ishax | On Saturday, 24 April 2021 at 16:48:49 UTC, Ishax wrote: >It's using the same D code as with the dynamic setup which I was able to produce a window with. you didn't read my message Remove all the code used to loadSDL, it's not needed anymore with static compilation
This should work |
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to russhy | On Saturday, 24 April 2021 at 17:20:06 UTC, russhy wrote: >This should work I just tried your code. I get: I put the libraries straight into the project root this time.
|
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ishax | Try to add this in your dub file: libs "user32" "gdi32" "shell32" |
April 24, 2021 Re: Use bindbc-sdl statically | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ishax | On Saturday, 24 April 2021 at 16:44:09 UTC, Ishax wrote: >So I have the lib files. It's failing with only an exit code. No window is appearing. It's using the same D code as with the dynamic setup which I was able to produce a window with.
Hi, Linux programmer here who just went through the process of working with dll's and lib's on windows. In my current understanding, there are three ways of working with libraries:
Note that 2. & 3. are different things, but the files you need end in .lib in both cases. You'll have to check that your .lib files are actually static libraries, not import libraries. I am not sure if linking to outside sources is appropriate, so I will just copy-paste from stackoverflow: "Use the lib command. If it's static, lib will show you a pile of .obj files inside. Not so if it's am implib."
|