 Hey, everybody, this is Brian and raise your hand if you have been personally victimized by the year 2020. I know I have over some good news. Cute six has been released as of December 8th, 2020. So I'm a huge cute fan. If you've been watching this channel, you know that, however, I ran into some issues using cute and I want to go over some of those issues. But specifically what we're going to cover in this video is how to build cute from the sources. We're going to do this in both dynamic and static because I know if I don't do static, I'm going to get a lot of comments of how do you build in static. So let's dive in. First question you need to ask yourself is why do you want to build the code? Well, I'm going to show you my specific situation. So I'm going to run the maintenance tool. This is in the application installation directory for cute. It's just wherever cute's installed, you have this maintenance tool. Every operating system has this. Go ahead and run it. Now my specific situation is I got all excited. I went out here and yes, you have to log in with your cute account. I hate that, but it is what it is. I got all excited. I went to install cute six. I'm going to go add remove components and well, it just didn't work and I'm going to show you exactly what's going on in my specific system and why I'm building from the source. So a lot of people are inclined to just go check and then they wonder why they have a massive downloads because you're downloading all this stuff. So I'm going to uncheck that, especially on Windows, you can have huge download. I'm going to download just what I need. And in this case, it's the desktop GCC 64 bit, only 396 bags. So it's not huge. I'm going to hit next and update. Now I'm all excited and happy and I'm drinking my coffee and life is good, but we're about to experience an issue and the issue, I'll just try to summarize it. It's because I have a different version of Linux than the person who built this. And this is a fundamental problem with deploying software right around this market. It's going to explode and it's going to say, nope, can't do it. There we go. And it's going to say error during installation process, the output of Q make query is not parsable. Please file a bug. Wait what? And I posted this in a previous video, but let's go out here and let's find out what's going on. So I'm going to just paste this and it says, uh-oh, cannot even run Q make. I mean, if you know Q, you know, Q make is a fundamental part. So the reason is you need this version of this library. Oh, that's not good. So if I just open up another command line, let's just say LDD version, you can see that my specific version of Linux, I'm running Linux Mint, the newest version of Linux Mint is running it older, it's actually one, one minor version. So it's like, oh, stumbling block. So that is why I am going to build from the source here. So let's go ahead and back this out. I'm going to hit cancel and it's going to put it all the way back to the very beginning here. And I'm going to just restart this wizard just to be safe. Okay, I'm just going to live with you. I can't really blame Q. This is more of an operating system issue than it is a Q issue. It's still just a stumbling block. And most newbies aren't going to understand that. So you're going to get a flood of questions. I actually filed a bug report because that's what it's said to do in the dialogue. So I'm going to hit next, add, remove components. And we're going to download the source code. So I want to go to Qt 6 and I want to just do sources. And there are other things, for example, the docs and all that, but we're just going to do sources. Next and this is going to take a lot of disk space and it's going to put it right here. And there's going to be another folder pop up that says 6.00. I'm going to go ahead and say update. And this is just going to take a second to download. My internet connection has been fairly snappy despite the COVID-19 pandemic and everybody's at home streaming Netflix. So we're just going to give it a moment to download this. Feel free to skip ahead. But when this is done downloading, I'm going to show you where the source is and I'm going to make a backup copy of that. OK, now that we have actually finished, I'm going to hit finish here. You'll see there is our 6.0 folder. We have a source folder. Now, the first thing I want to do before I even start screwing around with this, especially if you're on a slower internet connection, is I'm going to copy and I'm going to paste. So we're going to make a copy of this. That way, if you have a slower internet connection, you're not trying to, well, you know, redownload everything if you screw it up. From there, I'm going to create two folders. I'm going to say build and create a folder, build, stash, static. And you can feel free to name these whatever you want, but the basic premise is we're going to configure the source. Then we're going to build it dynamically and then build it statically. So we have two copies of this. To begin, we need to configure the source code. So I'm going to go into our source code directory, and this looks big and scary. And if you start diving into this, this is the source code. You want to be a little bit careful. They have a nice readme, although the directions in the readme really did not work for my specific situation. So I'm going to just open a terminal and do what I've done in the past. I'm going to paste this command and don't squint your eyes or pause the video. I'm going to actually put it in the description of the video down below so you can just copy and paste it right in your terminal. But we're basically going to say configure this for release. And let me actually just make this a little bigger here so you can see it. We're going to configure for release. This is going to be the open source license. We're going to automatically confirm the license, otherwise it's going to pop up and say are you sure. And prefix this is going to tell it where we want it. Now I have build static. I want to just change that. This prefix right here, this is where it's going to be installed at. These are the folders that we previously created up here, build and build static. So we're going to build this dynamically first. Let me pop back to my command line. So I want this in the build folder. And I'm just going to hit Enter. And this may take a few minutes, depending on the speed of your computer. OK, after we have configured Qt, we need to build it. So I'm going to clear this out, just so we can see up here what's going on. I did try following the directions where it said run CMake, and it did not work for me. So I'm going to use make-j. And I want to kick off eight workers here. And this will hopefully use the bulk of my system, which is going to be an eight core system. And I'm going to hit Enter. And this is going to take a long time. So go get a cup of coffee. OK, I hope you enjoyed your little break. The build process is over. Hopefully, knock on wood, you see a screen like this, where you've got 100% with no errors. That means you have a successful build. Now, if you had some sort of error, you're going to want to copy that error, go to Google, and then try to find some resolution. Unfortunately, I would love to give you a lot of tips and tricks and stuff like that. But every time I've built Qt and it's failed, it's been something with either the operating system, missing libraries, wrong compiler version, something with your environment. So it's going to be very specific to your situation. But once you get it to the point where you've got a successful build, now we need to install it. So we're going to do this by, let's just go ahead and clear this out, I'm going to say make install. And this is going to put it in that build directory. So let me just pop open the build directory here. There's absolutely nothing in there. Make install is going to take everything and shove it in there. And this may take a few minutes. Mine's kind of going along a little quick. And we're just going to let this run because it seems to be zipping along. If it stops for a long time, I'm going to pause the video. Gotta love modern technology. These new hard drives are actually really fast compared to my old hard drives. All right, speeding right along here and maybe, maybe, maybe, I see a lot of 100%. And a whole lot of installing, there we go. Wow, it's a lot of output here. So if we flip back to our build directory, now you see we have all this stuff here that wasn't here before. This is cute. So we can go out here and actually, let's look for Q make here. Let's right click properties. Let's make sure this is executable. And I'm going to open a terminal in here and I'm going to say, Q make. And ta-da, it magically runs. So we have successfully built this and we've got all their dependencies and everything's working and we can move on to the next step. The next step is we need to install a kit. And this sounds confusing, but it's actually pretty straightforward. We're going to go to tools, options, make sure we're on the kits tab with the kits tab selected. So we've said kit like a dozen times. What is a kit? Well, Qt is right once compile anywhere and a kit tells Qt how to compile it for that system. For example, here we have the desktop Qt with whatever version GCC 64. And we've got it for a target of the desktop and the device is a local PC. Remember, you can actually do like remote builds and all this other crazy stuff. And then we have our compiler or debugger and all of our environmental stuff. This is actually pretty complex stuff under the hood. Qt takes away a lot of that complexity. We have auto detected and manual. Notice I have a manual in here because I've previously manually built Qt 512.3 on static. And I had to set all this stuff up. It was not super fun. But before we can do anything, we need to actually put the Qt version we just built in here. You notice how it doesn't even see 6.0. So I've got these and you notice I've got some flags here. So let's just go and see what's going on. SDK not configured for Android. I don't care. I'm not going to be working with Android right now. And then WebAssembly, ABI detection failed. Make sure to use magic compiler and building. I really don't care because I'm not using WebAssembly. Don't freak out if you see some warnings. Let's go ahead and go to manual. I'm going to go to add. We need to go to the directory in which we built 6.0 and select Q make. Ta-da, right there. Don't hit okay or cancel, hit apply. Now we successfully installed Qt 6. We need to add a kit now to tell Qt how to use that Qt version. So I'm going to take an art existing kit and I'm going to take the newest one here, desktop 15.515 and I'm going to hit this clone button. All right, now from here I'm going to take my Qt version and I'm going to go down to Qt 6. If you don't see that that's because you skipped this step right here where you actually add in the Qt version. And you can see now it is a clone of desktop. I want to get rid of that. So I'm going to just say desktop Qt 6, GCC 64 bit. Now, spoiler alert, I did actually have to upgrade CMake because my older version of CMake and let me flip to the older version was popping a warning where it was saying, uh-oh, warning CMake version unsupported, please update. So I had to go out to CMake's website and download make, make install and we're good to go. Go ahead and hit apply, make sure no error messages pop up and then I'll hit okay. Congratulations, your kit is now installed. The next step is well to test to make sure this actually works as advertised. So I'm going to go to a new project. I'm going to see a Qt console application, just something simple just to test with. I don't really care what I name it. Make sure you put it in the directory you want it. Build system, this is where we got to stop and say, you want CMake. Now don't worry, Qmake and even QBS still exist and you can use them but they're going to stop developing those. They're going to be using CMake from this point forward. So you really should use CMake and I'm going to actually make some tutorials and I'm going to update all my Udemy courses and it's all going to use CMake. Next, I don't really care about translation file. Now the kit, I'm going to unselect that and we're going to select the right version. In this case, desktop Qt 600 GCC 64 bit. Yours may say something different depending on your operating system compiler and blah, blah, blah. But I just want to make sure that we have Qt six selected. Hit next and finish. Now this is a weird little bug and I'm not sure where it's coming from here. Whatever is generating CMake list.txt is not doing it correctly. You see this fine package Qt five core. I couldn't figure out why nothing was populating until I went in here and saw that and said, oh, well, we're working with Qt six. So let's go ahead and save that. Magically everything just pops to life and it finds everything that it needs. So I'm not quite sure if this is a bug in Qt creator or there's something screwy going on with my installation of CMake. Like I said, I literally downloaded it and built it and installed it. So I'm not sure what's going on there. Anyways, now we can go into source code land and let's just make a very simple test application and I'm going to make extremely simple. So I'm going to say Qt a bug and then from here I want to go you info, hello world. Let's go ahead and give this I want a release and let's give this a bill just to make sure everything builds as expected. All right, go ahead and run this. Hello world, everything's working. Now I did get a CMake warning here that I'll have to go out and figure out later but I just care that this thing actually built and run and we can flip over into debug and do the same thing. So let's give it a good build and we are now running in debug mode. Now out on the actual hard drive I've got two folders, debug and release. So I'm just going to go out here. Here's my untitled. It's actually not very big. I'm going to go here and let's see what we got. LDD and we want untitled. So you can see right off the bat Lib Qt core SO.6 so it is linking to it appropriately. All right, now that we have successfully built the dynamic libraries, we want to do a static build. I'm going to do this just because I know if I don't I'm going to get a lot of messages going. How do I build static? Okay, before we do this you got to understand what you're doing. You're going to link to all of Qt's goodness. Now some parts of Qt will not work as advertised because you're doing this. You may be violating some licensing agreements and things of that nature and I personally believe there are better ways of doing this. A lot of people like to do a static build just so it makes deployment easier but I will usually do a dynamic build and then use some sort of installer or like app image or something like that that wraps executable and all of its dependencies into one container. However, if you're dead set on doing a static build the steps are actually very, very similar. So we're going to pop back to command line and we are in the source folder. So just to kind of give you a view we're actually in this folder here with all the source code and we're going to do a configure command and don't worry the configure command is going to be identical virtually identical I should say to the last one. So I've got slash configure we're going to do release static that right there is key static. If you don't do static you're doing a dynamic we want the open source with a confirm license and our prefix or the path we're going to install to is going to be build dash static. Now notice I have the dash release you may want to change that if you want the debug libraries and all that. I just want to do it release for static. Now in the previous segment I did it release and I showed you can run it and debug or release but really it's still binding to the release libraries. So anyways, without further ado this is going to take a little bit of time so go ahead and get a cup of coffee or something and come back. Once we have done a successful configure for static we want to just verify that Qt will be installed into and wherever your static folder is you don't want to overwrite the one we just did for the dynamic. Also, yes it does say on the screen CMake build parallel mode when I tried this even though I have the correct version of CMake it just died a horrible death it just would not work. All right, so what I'm going to do here is I'm going to say make dash j8 and that'll kick this thing off. Now this is going to take longer than the previous build so whatever you did whether it was a book or a movie go do it again but expect a little bit longer. Okay, assuming we've gotten to this point and you've got 100% successful build and you've got no errors on the screen you have just built Qt for static. Now, unfortunately if you had an error you're going to have to do some creative Googling maybe Stack Overflow, Facebook groups, Google I don't really know what to tell you I've seen all sorts of crazy things with building sometimes the errors are actually in the Qt source themselves sometimes it's with your system it just all depends on the specifics here. So let's go ahead and we are going to clear this out and we're simply going to say make install and this will take just a few minutes but basically it's going to do the exact same thing as previous it's just going to copy all those binaries out to our static build folder. Let's give this just a second if it's takes too long I will actually just pause the video. Okay, seems to be blistering along at breakneck speeds I've got no errors so far really at this point we're just copying files and installing them in their location so it really shouldn't be a big deal. Once you get to this screen you are done. At this point let's go out to our file system and we're going to go out to our build static folder and there it is the statically linked version of Qt. Now that we have built and install Qt for static linking we need to go to tools, options and you guessed it we have to install it as a kit. So same thing we need to go to our Qt version we need manually add this so I'm going to go add and we're going to go up to six oh we're going to go to our static folder and we're going to look for Q make. Notice how right off the bat it's got something going on uh-oh no QML scene installed I don't really care about that because I don't want to use QML scene but point being when you do a static build you may start noticing some little inconsistencies here so static is kind of well a pain it's just a royal pain I'm going to go ahead and hit apply. Now we're going to flip over to our kits and I'm going to take this guy right here and I'm going to clone him so I'm going to say instead of clone of and we'll put the word static here that way I know this is the static version going to leave everything else and then we're going to go down to Qt build static that way we've got the correct version of Qt hit apply make sure no little gremlins pop up on the screen and everything good to go so we're going to hit okay there's really only one thing left to do and that is to test it out so we're going to go projects new going to make a simple console application going to leave it as untitled I don't really care that we're going to say build system C make language translation file going to leave it blank now we're going to unselect that kit and we're going to go down to desktop Qt 600 static next and finish and same thing as last time I did actually reach out to Qt and ask them why is it doing this and they said try the newest version of Qt creators release candidate I'm not there yet so we're just going to flip that over to six and hopefully they'll fix that in the near future from there we can just clear all this stuff out and go right here again just going to make a very simple application and I'm going to say hello Qt six go ahead and give this a good old build now you notice how we are in debug mode but when I did the command line switch for the configuration I had the dash release it'll still build just fine but we're not linking to the debug libraries so I'm going to flip this over to release and I'm going to give this a build again let's just run it and make sure it actually works so hello Qt six let's actually test this out we're going to go to the directory we just built this in here's our release folder there's the binary we just created and I'm going to say LDD and I want the untitled file and sure enough this is now statically linked this will work as expected so let's just try it here hello Qt six okay some takeaways from this video Qt six is awesome I've actually built Qt five from sources before and I got to tell you this by far was the smoothest experience for me maybe it's a little bit of experience having done it before but I think they've done a lot of tooling in the background so some major takeaways here C++17 is now required you need a C++17 compatible compiler before even attempting because it's just mandatory now they've done a lot of tooling in the core Libs and APIs and they've really streamlined a lot of stuff to make Qt six ready for the future to that end they put a whole new graphics architecture in this thing I mean this is insane I really look forward to diving into this and they've done some work in 3D that you're going to see a lot more 3D stuff coming out of Qt desktop styling for Qt Quick got some love and long overdue love I might add I am really super pumped about that interfacing with platform specific functionality they have a little blurb here but this is actually really important you should take some time to dive into the nitty gritty details on this and one of the major changes is the build system they're switching to CMake now don't panic Qmake is still there it will still function they're just not going to continue developing it so as Qt continues to grow and mature they'll be slowly phasing Qmake out so now's the time to really switch over to CMake all the videos I'm going to do from this point forward will be CMake all right compatibility changes and supported platform notes this is the main driver for this video Windows 10 it worked fine out of the box except for that little issue with where you know CMakeList.txt it was looking for Qt 5 instead of Qt 6 that will be fixed in the newer version of Qt Creator coming out soon Mac OS same thing Linux this is the reason I am obviously on a Linux box I am on Linux Mint 19.1 and I would have to completely upgrade to a newer version of a supported platform which is not something I really want to do I really enjoy this installation and I've got everything configured the way I wanted it's taken a long time to tweak it here so it's actually easier for me to build than it is to install an OS and as always they are moving on and looking towards the future so big shout out to everyone watching these videos and Qt if you're watching this love you guys your stuff is great as always and I look forward to really diving into Qt 6 I hope you enjoyed this video you can find the source code out on github.com if you need additional help myself and thousands of other developers are hanging out in the Voidrom's Facebook group this is a large group with lots of developers and we talk about everything technology related not just the technology that you just watched and if you want official training I do develop courses out on udemy.com this is official classroom style training if you go out there and the course you're looking for is just simply not there drop me a note I'm either working on it or I will actually develop it I will put a link down below for all three of those and as always help me help you smash that like and subscribe button the more popular these videos become the more I'll create and publish out on YouTube thank you for watching