digitalmars.D.learn - raylib-d how to program a simple moving circle.
- Alain De Vos (2/2) Nov 29 I can do "dub add raylib-d" but i have no clue to program a
- Alain De Vos (37/39) Nov 29 Following program has an import error
- Steven Schveighoffer (3/11) Nov 29 Makes no sense. Can you post the dub.json?
- Alain De Vos (18/34) Nov 29 I had Canvasity in dub.json , so i removed it.
- Alain De Vos (53/53) Nov 29 vscode no longer complains.
- Alain De Vos (3/3) Nov 29 I see i don't have the raylib library installed. And there is
- Alain De Vos (61/61) Nov 29 After installing raylib library on Debian ,
- Steven Schveighoffer (8/20) Nov 29 You are using an older version of gdc. I don't follow the gdc
- Alain De Vos (2/2) Nov 29 dub run raylib-d:install
- Steven Schveighoffer (9/23) Nov 29 This is because you didn't have the library available.
I can do "dub add raylib-d" but i have no clue to program a simple moving circle.
Nov 29
On Friday, 29 November 2024 at 21:37:48 UTC, Alain De Vos wrote:I can do "dub add raylib-d" but i have no clue to program a simple moving circle.Following program has an import error ``` import std.stdio: writeln; import raylib; //Error void main() { validateRaylibBinding(); // creating window //InitWindow(720, 640, "Dlang Raylib Window"); // loading texture //Texture2D image = LoadTexture("car.png"); // resizing the texture //image.width = image.height = 240; while(!WindowShouldClose()) { // process events // update // draw BeginDrawing(); // clear the screen ClearBackground(Colors.WHITE); // set background color to WHITE // draw "Hello, World!" DrawText("Hello, World!", 10, 10, 60, Colors.BLACK); // draw a square 50x50 DrawRectangle(100, 100, 50, 50, Colors.BLACK); // draw a circle of radius = 100 DrawCircle(100, 200, 50, Colors.BLACK); // draw the image //DrawTexture(image, 100, 400, Colors.WHITE); // display EndDrawing(); } // free res //UnloadTexture(image); // close the window and quit CloseWindow(); } ```
Nov 29
On Friday, 29 November 2024 at 22:02:23 UTC, Alain De Vos wrote:On Friday, 29 November 2024 at 21:37:48 UTC, Alain De Vos wrote:Makes no sense. Can you post the dub.json? -SteveI can do "dub add raylib-d" but i have no clue to program a simple moving circle.Following program has an import error ```d import std.stdio: writeln; import raylib; //Error ```
Nov 29
On Friday, 29 November 2024 at 22:35:14 UTC, Steven Schveighoffer wrote:On Friday, 29 November 2024 at 22:02:23 UTC, Alain De Vos wrote:I had Canvasity in dub.json , so i removed it. My current dub.json is : ``` { "authors": [ "x" ], "copyright": "Copyright © 2024, x", "dependencies": { "raylib-d": "~>5.5.1" }, "description": "A minimal D application.", "license": "proprietary", "name": "myprogram" } ```On Friday, 29 November 2024 at 21:37:48 UTC, Alain De Vos wrote:Makes no sense. Can you post the dub.json? -SteveI can do "dub add raylib-d" but i have no clue to program a simple moving circle.Following program has an import error ```d import std.stdio: writeln; import raylib; //Error ```
Nov 29
vscode no longer complains. But "dub run" gives, ``` dub run Starting Performing "debug" build using /usr/bin/dmd for x86_64. Up-to-date raylib-d 5.5.1: target for configuration [library] is up to date. Building myprogram ~master: building configuration [application] Linking myprogram /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/x/.dub/cache/myprogram/~master/build/application-debug-UNjmUV2QooI2uGd 4N2cYw/myprogram.o: in function `_Dmain': /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:16:(.text. Dmain[_Dmain]+0xe): undefined reference to `WindowShouldClose' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:22:(.text._ main[_Dmain]+0x1b): undefined reference to `BeginDrawing' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:23:(.text._ main[_Dmain]+0x34): undefined reference to `ClearBackground' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:26:(.text._ main[_Dmain]+0x5c): undefined reference to `DrawText' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:29:(.text._ main[_Dmain]+0x83): undefined reference to `DrawRectangle' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:32:(.text._ main[_Dmain]+0xad): undefined reference to `DrawCircle' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:38:(.text._ main[_Dmain]+0xb2): undefined reference to `EndDrawing' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:45:(.text._ main[_Dmain]+0xbc): undefined reference to `CloseWindow' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/x/.dub/cache/raylib-d/5.5.1/build/library-debug-VCS2IbF0QjMRz7j1LmY9HA/libraylib-d a(binding_1_868.o): in function `_D6raylib7binding21validateRaylibBindingFNbNiZv': /home/x/.dub/packages/raylib-d/5.5.1/raylib-d/source/raylib/binding.d:27:(.text._D6raylib7binding21validateRaylibBindingFNbNiZv[_D6raylib7binding21validateRaylibBi dingFNbNiZv]+0x11): undefined reference to `raylib_version' /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/x/.dub/packages/raylib-d/5.5.1/raylib-d/source/raylib/binding.d:27:(.text._D6raylib7binding21validateRaylibBindingFNbNiZv[_D6raylib7binding21validateRaylibBi dingFNbNiZv]+0x24): undefined reference to `raylib_version' collect2: error: ld returned 1 exit status Error: undefined reference to `WindowShouldClose` referenced from `_Dmain` Error: undefined reference to `BeginDrawing` referenced from `_Dmain` Error: undefined reference to `ClearBackground` referenced from `_Dmain` Error: undefined reference to `DrawText` referenced from `_Dmain` Error: undefined reference to `DrawRectangle` referenced from `_Dmain` Error: undefined reference to `DrawCircle` referenced from `_Dmain` Error: undefined reference to `EndDrawing` referenced from `_Dmain` Error: undefined reference to `CloseWindow` referenced from `_Dmain` Error: undefined reference to `raylib_version` referenced from `nothrow nogc void raylib.binding.validateRaylibBinding()` Error: undefined reference to `raylib_version` referenced from `nothrow nogc void raylib.binding.validateRaylibBinding()` perhaps a library needs to be added with the `-L` flag or `pragma(lib, ...)` Error: linker exited with status 1 cc /home/x/.dub/cache/myprogram/~master/build/application-debug-UNjmUV2QooI2uG w4N2cYw/myprogram.o -o /home/x/.dub/cache/myprogram/~master/build/application-debug-UNjmUV2QooI2 Gdw4N2cYw/myprogram -g -m64 -Xlinker --no-as-needed -Xlinker --export-dynamic -Xlinker -rpath=/usr/lib/dmd/2.109/lib64 /home/x/.dub/cache/raylib-d/5.5.1/build/library-debug-VCS2IbF0QjMRz7j1 mY9HA/libraylib-d.a -L/usr/lib/dmd/2.109/lib64 -lphobos2 -lpthread -lm -lrt -ldl Error /usr/bin/dmd failed with exit code 1. ```
Nov 29
I see i don't have the raylib library installed. And there is none available on redcore-linux(a gentoo derivative). Gone try debian now.
Nov 29
After installing raylib library on Debian , https://github.com/raysan5/raylib/releases Running "dub run" i get now the error : ``` dub run Fetching raylib-d 5.5.1 (getting selected version)... Performing "debug" build using /usr/bin/gdc for x86_64. raylib-d 5.5.1: building configuration "library"... /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:231:25: error: found ‘:’ when expecting ‘)’ 231 | return Vector2(x:(x + width), y:y); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:231:40: error: found ‘:’ when expecting ‘;’ following `return` statement 231 | return Vector2(x:(x + width), y:y); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:231:42: error: found ‘)’ when expecting ‘;’ following statement 231 | return Vector2(x:(x + width), y:y); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:231:42: error: found ‘)’ instead of statement 231 | return Vector2(x:(x + width), y:y); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:235:25: error: found ‘:’ when expecting ‘)’ 235 | return Vector2(x:x, y:(y + height)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:235:26: error: found ‘x’ when expecting ‘;’ following `return` statement 235 | return Vector2(x:x, y:(y + height)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:235:27: error: found ‘,’ instead of statement 235 | return Vector2(x:x, y:(y + height)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:239:25: error: found ‘:’ when expecting ‘)’ 239 | return Vector2(x:(x + width), y:(y + height)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:239:40: error: found ‘:’ when expecting ‘;’ following `return` statement 239 | return Vector2(x:(x + width), y:(y + height)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:239:53: error: found ‘)’ when expecting ‘;’ following statement 239 | return Vector2(x:(x + width), y:(y + height)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:239:53: error: found ‘)’ instead of statement 239 | return Vector2(x:(x + width), y:(y + height)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:243:25: error: found ‘:’ when expecting ‘)’ 243 | return Vector2(x:(x + width/2.0f), y:(y + height/2.0f)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:243:45: error: found ‘:’ when expecting ‘;’ following `return` statement 243 | return Vector2(x:(x + width/2.0f), y:(y + height/2.0f)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:243:63: error: found ‘)’ when expecting ‘;’ following statement 243 | return Vector2(x:(x + width/2.0f), y:(y + height/2.0f)); | ^ /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:243:63: error: found ‘)’ instead of statement 243 | return Vector2(x:(x + width/2.0f), y:(y + height/2.0f)); | ^ /usr/bin/gdc failed with exit code 1. ```
Nov 29
On Saturday, 30 November 2024 at 02:16:35 UTC, Alain De Vos wrote:After installing raylib library on Debian , https://github.com/raysan5/raylib/releases Running "dub run" i get now the error : ``` dub run Fetching raylib-d 5.5.1 (getting selected version)... Performing "debug" build using /usr/bin/gdc for x86_64. raylib-d 5.5.1: building configuration "library"... /home/x/.dub/packages/raylib-d-5.5.1/raylib-d/source/raylib/ra lib_types.d:231:25: error: found ‘:’ when expecting ‘)’ 231 | return Vector2(x:(x + width), y:y); | ^ ```You are using an older version of gdc. I don't follow the gdc releases, but it's possible even the latest available doesn't support named parameters, as that is a recent addition. In any case, I still recommend using the raylib-d:install script, and you can do this without having to install a library package from your OS. -Steve
Nov 29
dub run raylib-d:install solved the problem. Thanks
Nov 29
On Saturday, 30 November 2024 at 01:28:44 UTC, Alain De Vos wrote:vscode no longer complains. But "dub run" gives, ``` dub run Starting Performing "debug" build using /usr/bin/dmd for x86_64. Up-to-date raylib-d 5.5.1: target for configuration [library] is up to date. Building myprogram ~master: building configuration [application] Linking myprogram /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/x/.dub/cache/myprogram/~master/build/application-debug-UNjmUV2QooI2uGd 4N2cYw/myprogram.o: in function `_Dmain': /mnt/xxx_source/Languages_ok/dlangtut/dub/69_raylib_error/source/app.d:16:(.text. Dmain[_Dmain]+0xe): undefined reference to `WindowShouldClose' ```This is because you didn't have the library available. I highly recommend using the raylib-d:install script as mentioned in the [README](https://github.com/schveiguy/raylib-d?tab=readme-ov-file#method-1-install-appropriate-raylib-library-with-helper-tool) Not only does this copy the *exactly correct* library to your local directory, it also offers to update your dub.json to provide the appropriate linker directives for linking. -Steve
Nov 29