Re: Using bindbc-sdl with D
On 12/03/2023 4:27 PM, idsize wrote: On Sunday, 12 March 2023 at 02:24:31 UTC, Richard (Rikki) Andrew Cattermole wrote: If you add the appropriate versions and copy the files to your project directory (including bindbc-loader) that should work however as long as you compile it in. I've never used a package manager before so the entire process of using one is still strange to me. When using SDL2 with C, I have all of the SDL2 files within my MinGW install. To compile I use 'gcc example.c -lmingw32 -lSDL2 -lSDL2main'. Could I use a method similar to that? Yeah pretty much the same thing in principle. Pass the D files to the compiler (including the bindings, dynamic bindings are not like headers, they load the DLL at runtime not during linking like static bindings), tell it the versions needed for the bindings and it should work. When you do a successful build with the verbose flag it'll tell you what commands were used to build and link it. That should give you some pointers of what is required (although there will be extra flags/versions specified that you probably won't need).
Re: Using bindbc-sdl with D
On Sunday, 12 March 2023 at 02:24:31 UTC, Richard (Rikki) Andrew Cattermole wrote: If you add the appropriate versions and copy the files to your project directory (including bindbc-loader) that should work however as long as you compile it in. I've never used a package manager before so the entire process of using one is still strange to me. When using SDL2 with C, I have all of the SDL2 files within my MinGW install. To compile I use 'gcc example.c -lmingw32 -lSDL2 -lSDL2main'. Could I use a method similar to that? Also here is the full (but not verbose) error log: ''' Starting Performing "debug" build using C:\D\dmd2\windows\bin64\dmd.exe for x86_64. Building bindbc-sdl 1.3.0: building configuration [staticBC] failed launching cl.exe /P /Zc:preprocessor /PD /nologo C:\Users\idoug\AppData\Local\dub\packages\bindbc-sdl-1.3.0\bindbc-sdl\source\bindbc\sdl\ctypes.c /FIC:\D\dmd2\windows\bin64\..\..\src\druntime\import\importc.h /Fictypes.i C:\Users\idoug\AppData\Local\dub\packages\bindbc-sdl-1.3.0\bindbc-sdl\source\bindbc\sdl\config.d(127,16): Error: C preprocess command cl.exe failed for file C:\Users\idoug\AppData\Local\dub\packages\bindbc-sdl-1.3.0\bindbc-sdl\source\bindbc\sdl\ctypes.c, exit status 1 Error C:\D\dmd2\windows\bin64\dmd.exe failed with exit code 1. '''
Re: Using bindbc-sdl with D
On Sunday, 12 March 2023 at 02:52:27 UTC, ryuukk_ wrote: On Sunday, 12 March 2023 at 02:12:45 UTC, idsize wrote: [...] Hello, and welcome! Looks like the new version of that library is broken, i am having the same issue [...] Thanks! It compiled and ran your example successfully.
Re: Using bindbc-sdl with D
On 12/03/2023 4:01 PM, ryuukk_ wrote: So this is a dub issue? Nope, dub is doing everything ok, this is for ImportC. It is able to find the linker, why can't it find the preprocessor? Its probably not installed. We don't ship a C toolchain, it uses the system one (MSVC, which you would normally get via Visual Studio).
Re: Using bindbc-sdl with D
On Sunday, 12 March 2023 at 02:59:20 UTC, Richard (Rikki) Andrew Cattermole wrote: On 12/03/2023 3:24 PM, Richard (Rikki) Andrew Cattermole wrote: But ugh that error looks weird. That would imply its trying to run the C preprocessor for ImportC. That does not sound right at all, I don't see any C headers/code in bindbc-sdl repo (not that it needs it). Gonna need to see the entire error log for that to know whats going on (and possibly the verbose output). Ah huh, there is one! https://github.com/BindBC/bindbc-sdl/blob/master/source/bindbc/sdl/ctypes.c That explains it. So this is a dub issue? It is able to find the linker, why can't it find the preprocessor?
Re: Using bindbc-sdl with D
On 12/03/2023 3:24 PM, Richard (Rikki) Andrew Cattermole wrote: But ugh that error looks weird. That would imply its trying to run the C preprocessor for ImportC. That does not sound right at all, I don't see any C headers/code in bindbc-sdl repo (not that it needs it). Gonna need to see the entire error log for that to know whats going on (and possibly the verbose output). Ah huh, there is one! https://github.com/BindBC/bindbc-sdl/blob/master/source/bindbc/sdl/ctypes.c That explains it.
Re: Using bindbc-sdl with D
On Sunday, 12 March 2023 at 02:12:45 UTC, idsize wrote: I started learning D a few weeks ago and am enjoying it so far. I would like to use SDL with D and found bindbc-sdl, but I cannot figure out how to make it work. From my understanding, I'll need to use 'dub fetch bindbc-sdl' to download it, and then run 'dub build bindbc-sdl' to build it, before I can use it. Fetching it works, but it always fails to build. I get this error: 'failed launching cl.exe /P /Zc:preprocessor /PD /nologo ... '. Additionally, a more general question about bindbc, is it possible to skip using dub altogether? Like would placing the bindbc files inside of 'C:\D\dmd2\src\druntime\import' work directly? Hello, and welcome! Looks like the new version of that library is broken, i am having the same issue Reverting to previous (1.2.4) one is working (delete the dub.selection.json): Download SDL: https://github.com/libsdl-org/SDL/releases/tag/release-2.26.4 And put the dll in your project folder ```json { "name": "hellosdl", "dependencies": { "bindbc-sdl": "1.2.4", }, "versions": [ "SDL_2_26" ], } ``` ```D import bindbc.sdl; import core.stdc.stdio; void main() { // here we load the dll auto ret = loadSDL(); // here handle cases where it failed to load the dll if (ret != sdlSupport) { if (ret == SDLSupport.noLibrary) { // dll not found } else if (ret == SDLSupport.badLibrary) { // wrong DLL, perhaps 32bit vs 64bit? } return; } // all good, let's use SDL SDL_Window* window = null; SDL_Surface* screenSurface = null; if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError()); return; } window = SDL_CreateWindow("hello_sdl2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN); if (window == null) { fprintf(stderr, "could not create window: %s\n", SDL_GetError()); return; } screenSurface = SDL_GetWindowSurface(window); bool running = true; while (running) { SDL_Event ev; while (SDL_PollEvent(&ev)) { switch (ev.type) { case SDL_QUIT: running = false; break; default: break; } } SDL_FillRect(screenSurface, null, SDL_MapRGB(screenSurface.format, 0x00, 0x00, 0xFF)); SDL_UpdateWindowSurface(window); } SDL_DestroyWindow(window); SDL_Quit(); } ``` I filled an issue on the tracker: https://github.com/BindBC/bindbc-sdl/issues/50
Re: Using bindbc-sdl with D
On 12/03/2023 3:12 PM, idsize wrote: I started learning D a few weeks ago and am enjoying it so far. I would like to use SDL with D and found bindbc-sdl, but I cannot figure out how to make it work. Welcome! From my understanding, I'll need to use 'dub fetch bindbc-sdl' to download it, and then run 'dub build bindbc-sdl' to build it, before I can use it. Fetching it works, but it always fails to build. I get this error: 'failed launching cl.exe /P /Zc:preprocessor /PD /nologo ... '. You don't need to do that, add it as a dependency in your dub package and dub will do the rest. But ugh that error looks weird. That would imply its trying to run the C preprocessor for ImportC. That does not sound right at all, I don't see any C headers/code in bindbc-sdl repo (not that it needs it). Gonna need to see the entire error log for that to know whats going on (and possibly the verbose output). Additionally, a more general question about bindbc, is it possible to skip using dub altogether? Like would placing the bindbc files inside of 'C:\D\dmd2\src\druntime\import' work directly? Yes, but not that way. Druntime/phobos are both distributed compiled, the import directories tell the compiler what has been compiled in and allow access to templates defined by the library (which you then compile). If you add the appropriate versions and copy the files to your project directory (including bindbc-loader) that should work however as long as you compile it in.
Using bindbc-sdl with D
I started learning D a few weeks ago and am enjoying it so far. I would like to use SDL with D and found bindbc-sdl, but I cannot figure out how to make it work. From my understanding, I'll need to use 'dub fetch bindbc-sdl' to download it, and then run 'dub build bindbc-sdl' to build it, before I can use it. Fetching it works, but it always fails to build. I get this error: 'failed launching cl.exe /P /Zc:preprocessor /PD /nologo ... '. Additionally, a more general question about bindbc, is it possible to skip using dub altogether? Like would placing the bindbc files inside of 'C:\D\dmd2\src\druntime\import' work directly?
Re: SDL with D
According to the Derelict page, there already are unofficial bindings. But I guess they wouldn't work with Derelict2 anyway.
Re: SDL with D
On 7/12/2011 4:21 PM, Dainius (GreatEmerald) wrote: I see. And what about Lua? I see lots and lots of different libraries for that on dsource, and there is even some support in Derelict as well. I assume that LuaD is the one in active development and most fitting for current D2? Derelict has no Lua binding yet. It's on the todo list. I'm waiting for Lua 5.2 to be released.
Re: SDL with D
I see. And what about Lua? I see lots and lots of different libraries for that on dsource, and there is even some support in Derelict as well. I assume that LuaD is the one in active development and most fitting for current D2?
Re: SDL with D
Derelict has an SDL binding, you should take a look at that. There's a D2 Derelict branch in svn. I've used Derelict with OpenGL, works ok. I haven't tested SDL though. See http://www.dsource.org/projects/derelict.
SDL with D
Can D interface with SDL directly? Right now the program I'm writing uses C as a sort of a wrapper for D and SDL to communicate, and I guess it would be simpler, cleaner and more reliable if D could call SDL functions directly. If it works, is there anything I should keep in mind about it?