 Hello and welcome! This video is part of a series on C programming. We're continuing on what we worked on yesterday. I am going to try and make this a quick video because it's just a continuation. So first of all, we're cross-compiling four windows on Linux. So if you're on a Linux system, check your package manager. I'm using a Debian-based system. So I'm going to use aptitude. I'm going to say search MingW and hit enter. And you can see right here we have MingW-W64. Might be named slightly different on your system, but look for something similar that install it. Once that is installed, we should be able to say I686-...all that. In our case, we want GCC as our compiler because we are compiling for C. And you can see that there's different options, but we're just going for the basic dash GCC here. Space. And at that point, we can compile just like we did before by giving it our C application dash O in the output. The problem with this is...it's not a problem. It just depends on your scenario. You're going to get a shell. Even if you create a GUI application for Windows, when you run this program, a shell is going to pop up and then your window is going to pop up and the shell is going to be there floating around in the background. And you may not want that. Obviously, if you have a GUI application or you just want to write an application that runs in the background and you can't see. So it's just like a background process, basically, with no window. So what we're going to do here is we're going to compile something so that that shell doesn't show up. And it's just giving a parameter to your compiler. But real quick, let's look at the application I wrote. I'm going to say it's, again, going to be if you go to the link in the description to my GitLab page. There should be a folder called C in there, a tutorial folder. And there are all the code we've written in this series is there. This is a very basic system command, just like on any other, you know, whether it's Linux or Mac OS or Windows, system will run a system command. I'm going to do dir and then type that into a files.temp. And actually, let me rename that so that I can just easily open it in notepad.txt. Okay, and I'm just doing that so that you can see that the program, because I'm going to click on the icon and you're not going to see anything happen. So I'm just going to create a file so that you can see that it did actually run. So now that we have that, it's just going to run that system command. So again, I 686 dash da da da GCC. And now I'm going to give it that input file dash Oh, I'm going to put it in my bin folder. I'll call it I'll call it hidden. So to I was called hide window.exe. And I'm going to say dash M windows. And it's that dash M windows is basically telling the compiler that this is a window application. It's supposed to have a GUI don't show the shell. Even though we're not creating a GUI window, that means nothing's going to show up. Again, I can check this file bin hide window. And you can see that it is an executable. Last time I said console, this time it says GUI, it thinks it's a GUI application, even though it is not a GUI application. So it's going to hide the shell for MS windows. So let's go ahead. I'm going to save that. I'm going to take it over to Windows machine to test out on real hardware. Okay, so I did make a mistake. But we'll see here in a minute, I went to a Windows machine. I went to my get lab page. I downloaded the executable. We compiled on Linux. When I downloaded it, I then went to open it. So here's the directory. You can see just that file is in there. And when I click on it, of course, Windows asked, are you sure you want to run this? And then I click run. But notice that when I run it, there is a shell window popping up, which should not be happening. And I compiled it properly, but I wrote the code improperly. So we did a system command, a system function to run a shell command, which even if you hide the main window, it's going to cause a shell to pop up. So I'm going back now to our C application that we wrote for right into a file. So again, I'll real quick, let me go into here. That's C. So instead of a system call, we're going to do this. So so using the system function again, it's going to cause a shell to pop up, even though in console application, it will just run it in the original console. If you have the hidden window, it will cause that window to pop up. So if you're going to run system commands, you're going to have to use it a different way. But using C code and not calling external commands using the system function such as this, so we're going to write to a file or append to a file just as we did in a previous video. So if I take that, and I compile it using x me or ming w 32, I don't know why I said x me, or actually, I guess it's a proud Min GW, I think is how it's supposed to be pronounced. We're going to compile that into a right file.exe using again, all we have to do is add the dash m windows, and it makes it a windows application. Again, if I file that the executable we just created, it says that it is a MS windows compilation. It's a GUI. Now, if we go back to the windows machine, and I download that and run it, you'll see that it will write to a file. And it will not cause a shell window to open up. So let's go ahead and look at that. So again, I'm at my get lab page, which should be linked to in the video description. I download that executable we just compiled on Linux for Windows. When I download it, I'm going to open up the folder it's in. So you can see it's just that executable, no text file. When I go to run it, of course, when it says that you're sure you want to run it. And I'm going to say, yeah, don't ask this again, because it's stupid you ask me. And then I click run. And we should see a text file being created. I'll click on the application a second time, you can see it had appended it a second time. Close the text document. And I will, I don't know why I opened that up again. That was a mistake. I will click on our executable a couple of times. You can see there's no shell window popping up. It is running in the background. And then I can open up that text file. And you can see that our expul did run multiple times every time I clicked it and it appended to it. So that's it. I do thank you for watching. Please visit films by chris.com. That's Chris the K there. You can search through all my videos. You can also, you know, go down to the software section where you can also search through my get lab page scripts I've written that are up online. And then my notes, which is basically all my pay spin. I think I have like 700 pay spin posts, but that's a searchable application for that. And of course, if you go to my get lab four slash malax 1000, you can always click on this link right here to get to that. And then under my get lab page, you can look for my bin. So for like my binary files, which a lot of them are not binary files, but that's why I called it. And that's capital M capital B. Under that, there's a C folder tutorials. And there you can find all our applications. And here you can see our C application that we just worked on today where that we create a few tutorials ago. But again, you can pile up for windows and you can also pile up for windows without a window pop up. So again, remember our original mistake, which was doing a system command, like this, even if you have the main window hidden, that's going to open up a console. So keep that in mind. I do thank you for watching. And I hope that you have a great day.