How to install sdl3 library?

cd src
dir

Directory of D:\oyun-zig\src

27.03.2025 04:38 .
27.03.2025 04:38 …
27.03.2025 03:36 1.257 main.zig
27.03.2025 04:38 382 root.zig
2 File(s) 1.639 bytes
2 Dir(s) 303.941.304.320 bytes free

In your build.zig you need to change

.root_source_file = b.path("main.zig"),

to

.root_source_file = b.path("src/main.zig"),

I don’t know how to do this. main.zig is already in the src folder. Do you want me to take the main.zig file in the src folder and put it in the upper folder, namely game-zig? Should it be in the same place as build.zig?

No leave the file where it is and edit it, with some editor. If you want you can open it with some text editor.

I need to sleep soon.

I think it would make sense if you had in person help from somebody that has learned these things in the last few years, because they would know where they have learned it and what to recommend to you. (I learned these things a long time ago and haven’t used windows in the last years)

These are basics, most programming resources will assume that you know how to do these things, when you don’t know them, we should find you a person that can teach it, or a tutorial that can teach and explain it.

D:\oyun-zig\src>zig build run
run
└─ run breakout
└─ zig build-exe breakout Debug native 1 errors
main.zig:1:7: error: duplicate struct member name ‘std’
const std = @import(“std”);
^~~
main.zig:17:7: note: duplicate name here
const std = @import(“std”);
^~~
main.zig:1:1: note: struct declared here
const std = @import(“std”);
^~~~~
error: the following command failed with 1 compilation errors:
C:\zig\zig.exe build-exe D:\oyun-zig.zig-cache\o\b8a31048b1c4056d5c891c5def0fdfc7\SDL3.lib -ODebug -I D:\oyun-zig.zig-cache\o\0acc5620de2d781ff496ea20c3a797d9 -Mroot=D:\oyun-zig\src\main.zig D:\oyun-zig.zig-cache\o\817f1dcf5033dc59c0f9acfadbb54548\SDL_uclib.lib -lkernel32 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -ladvapi32 -lsetupapi -lshell32 -ldinput8 -lc --cache-dir D:\oyun-zig.zig-cache --global-cache-dir C:\Users\XX\AppData\Local\zig --name breakout --zig-lib-dir C:\zig\lib\ –listen=-
Build Summary: 6/11 steps succeeded; 1 failed
run transitive failure
└─ run breakout transitive failure
├─ zig build-exe breakout Debug native 1 errors
└─ install transitive failure
└─ install breakout transitive failure
└─ zig build-exe breakout Debug native (+3 more reused dependencies)
error: the following build command failed with exit code 1:
D:\oyun-zig.zig-cache\o\163a5abc2eb329a0e60b7713e11cf367\build.exe C:\zig\zig.exe C:\zig\lib D:\oyun-zig D:\oyun-zig.zig-cache C:\Users\XX\AppData\Local\zig --seed 0xb470bb00 -Z94fbc49aeec5ecb5 run

I’m so sorry. I took too much of your time.
Thank you for all your help and efforts.
I also noticed that you need to know languages ​​like C or Zig at a very advanced level. I think if you don’t know these languages ​​at an advanced level, you have no chance if you are a beginner and new learner. I think it’s not suitable for someone learning from scratch.

You just need to break it down into manageable chunks, so that you don’t learn a hundred different things all at once.

And for that it is good to know, what you know, so it would help if you described a bit what you know to do with the computer, have you programmed with any other programming language before?

It might make sense to start with some other programming language that comes with a windows specific tutorial if you feel more comfortable with that, it depends on how fast you learn, if you can find and apply learning material and so on.

This means that the file contains the same line multiple times, probably got duplicated via copy-paste, edit the file so it is only contained once.

Thanks, I don’t want to deal with it anymore. I’ve been struggling with this for days, even weeks. I first tried it with the C language. I had very little knowledge of the C language before. I tried it with Visual Code, but I couldn’t install it. I tried it with Codeblocks, but it didn’t work. I couldn’t introduce the SDL library. I watched hundreds of articles and video tutorials, but it didn’t work. I’ve been trying it with Zig for a week or two, but I still haven’t been successful. It was very challenging and tiring.

I didn’t think loading a library in a language would be this difficult.

I worked with HTML-CSS-JS before. Then I worked with PHP.

I think you need to change how you approach things, it seems to me as if you are trying to grasp at quick solutions and giving up before you have understood why something didn’t work, than moving on to something else that also doesn’t work.

You need to pick something and stick with it and understand it, otherwise you may move on to another thing always right before you begin to understand it.

The error message you showed before, shows that you made progress, the build process worked, it gave you an error message, that is progress, focus on that, getting errors, learning to read and understand the error messages is part of what you need to learn.

It is your choice what you pick to learn and stick with, but choose something to stick with, instead of hopping from one thing to the next.

Why did you want to use sdl3?

I actually would recommend you raylib instead, because it is simpler, here is an example project:

2 Likes

You are right in what you say. It is normal to get errors. It requires effort. But it has been weeks, even a few months if we consider the whole thing. During this time, I have not been able to add a library and see a screen even if it says hello world. Although months have passed, I do not want to bother anymore since I have not been able to add the library, run it and start learning. Otherwise, I am aware of this. Even if I add the library, it will take me months or even a year or two to learn that library. But I could never start. I could not even get a single screen output. In such a long time. This much was too much for me, so I quit. First I tried Raylib. I could not install it either. Also, as a result of my research, Raylib only handles the graphical part. It does not support features such as sound, keyboard, player controller. I want to make a game. I have a few game ideas in mind. I wanted to bring them to life. Maybe it would take me a few years. But I wanted to make it. I can only handle the visual part with Raylib. All operations such as sound control etc. are incomplete. Separate libraries are required for them. SDL offers a complete solution that meets all needs for game makers. It is necessary to use game engines higher than sdl, such as unreal unity.

raylib has support for all of that and more

Don’t make up limiting beliefs in your mind. You need to learn a few things and become better at learning how to learn things and it could be reduced to a much shorter time.

Do you mean it is un-necessary?

Raylib or SDL are enough to create complete games.

It was written like that in the articles I read about raylib. Maybe it was like that a few years ago. There are also some libraries and sound keyboard support. But I understood the advantage of sdl as being compact and containing everything. I didn’t say raylib and sdl or game engines are unnecessary. Games can be made with all of them. People only make choices based on resource consumption, hardware consumption or game size and content. Games can be made with all of them. I don’t limit myself. When I said I would do it in a few years, I didn’t accept learning alone. Learning plus creating the story of my game in all its aspects, creating the sections, designing and creating things like sound will take time. Then making the game, making it playable, doing tests, etc. these are long processes.

I nominate @Sze for the medal of “the most helpful dude on ziggit, like, ever”.

13 Likes

Just wanted to second that and thank you @Sze!

@ahmet111:
I also think you should not be discouraged! It seems to me, that you were just overwhelmed, because you picked a very complex topic to start with. Most tutorials for this, as you also noticed, already assume quite a bit of knowledge.

Maybe you need to start with more basic things, and work your way up! Are there any in-person computer or programming courses in your area that you could attend?
I am not too familiar with online courses, so unfortunately I cannot recommend any, maybe someone else here can?
Maybe ChatGPT could also help you if you give it more basic questions, but it could also be that it just always give you overwhelming answers for your knowledge level.

If you still have some patience in you, don’t give up, make small steps, and eventually, you will learn!

5 Likes