Qt Creator Dreamcast Development Environment: Difference between revisions
GyroVorbis (talk | contribs) No edit summary |
|||
(18 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
This is a | '''NOTE: This page is a work in progress! It will get you set up for compiling and 90% ready for debugging, but the final bit and screenshots are incoming still.''' | ||
This is a guide to set up the Qt Creator IDE for compilation and source-level debugging on the Sega Dreamcast using the KallistiOS development environment, the CMake build system, and the GDB debugger. | |||
=== Prerequisites | == Motivation == | ||
Choosing Qt Creator as your IDE for Dreamcast development has several strengths, such as being massively cross-platform, supporting a multitude of devices and toolchains (Windows, Mac, Linux, iOS, Android, WebAssembly, etc), and being extremely easy to add additional toolchains to. I ([[User:GyroVorbis|Falco Girgs]]) build all of my projects with standard CMake using the CMake toolchain file provided within KOS, and I can swap between targeting a variety of platforms by simply changing an option in a drop-down menu. Not only that, but any active breakpoints or watch variables that I've set up on PC will seamlessly transition over to my Dreamcast and vice versa when changing between targets! | |||
However, the downside is that as of the writing of this tutorial (Qt Creator version 10.0.1), there are a few places where we are forced to do things that are slightly less than ideal or a bit hacky to maneuver around limitations in the configurability of the IDE. In my personal opinion, these are not actually a big deal, and your resulting environment is almost as easy to use as debugging locally; however, there are tutorials for other IDEs if having to click two buttons instead of one to start a remote debugging session or any of the little nuances here rub you the wrong way: | |||
* [https://dreamcast.wiki/Visual_Studio_Code Visual Studio Code] | |||
* [https://dreamcast.wiki/CLion_Debugging CLion] | |||
== Prerequisites == | |||
To start with, this tutorial makes the following assumptions: | To start with, this tutorial makes the following assumptions: | ||
# You have already installed and [https://dreamcast.wiki/Getting_Started_with_Dreamcast_development set up your KallistiOS development environment]. | # You have already installed and [https://dreamcast.wiki/Getting_Started_with_Dreamcast_development set up your KallistiOS development environment]. | ||
Line 9: | Line 16: | ||
== Setting up GDB == | == Setting up GDB == | ||
Before we can begin configuring Qt Creator, we must | Before we can begin configuring Qt Creator, we must check to see if <code style="inline>gdb</code>. is installed. You can verify this by checking to see whether you have the executable. It is typically located at <code style="inline">/opt/toolchains/dc/sh-elf/bin/sh-elf-gdb</code>. | ||
Alternatively, if you're currently within a DC environment, simply check to see if you can run <code style="inline">sh-elf-gdb</code>. | |||
If everything goes well, it should start up and leave you at a command prompt. If you do not have GDB installed, see [[Getting Started with Dreamcast development]] for instructions on setting up your toolchain. As of May 2024, the toolchain builder script now installs GDB by default. | |||
If everything goes well, it should start up and leave you at a command prompt. | |||
=== Verifying Python Support === | === Verifying Python Support === | ||
Line 41: | Line 27: | ||
== Configuring Qt Creator == | == Configuring Qt Creator == | ||
Now that we have GDB downloaded and installed, it's time to tell Qt Creator how to use our shiny new Dreamcast toolchain. | Now that we have GDB downloaded and installed, it's time to tell Qt Creator how to use our shiny new Dreamcast toolchain. | ||
=== | === Adding the Toolchain === | ||
First, select the "Preferences" option from the "Edit" file menu. A dialog window should open. Select first entry, "Kits" from the top of the navigator pane on the left. | First, select the "Preferences" option from the "Edit" file menu. A dialog window should open. Select first entry, "Kits" from the top of the navigator pane on the left. | ||
==== Configuring GDB ==== | ==== Configuring GDB ==== | ||
Line 73: | Line 59: | ||
As with previously, if everything went well, you should see the "ABI" and "Target Triple" fields automatically populated with the same values as with the C compiler. | As with previously, if everything went well, you should see the "ABI" and "Target Triple" fields automatically populated with the same values as with the C compiler. | ||
==== Configuring the Kit ==== | |||
Finally, select the "Kits" tab from the main tab view. Qt Creator has automatically set up a kit for every platform you've installed a toolchain for (which could be none or many). We now need to add a custom Kit for the Sega Dreamcast. | |||
Click the "Add" button in the top-right of the main view to add an entry to the list of its. Configure it with the following fields: | |||
* '''Name''': Dreamcast GCC-<VERSION> | |||
* '''Compiler''': | |||
** '''C''': Dreamcast GCC | |||
** '''C++''': Dreamcast G++ | |||
* '''Debugger''': Dreamcast GDB | |||
* '''Qt Version''': None | |||
* '''CMake Generator''': Unix Makefiles | |||
Click on the "change" button to the right of the '''Environment''' field, and add the following: | |||
KOS_BASE=/opt/toolchains/dc/kos | |||
KOS_CC_BASE=/opt/toolchains/dc/sh-elf | |||
KOS_PORTS=/opt/toolchains/dc/kos-ports | |||
KOS_SUBARCH=dreamcast | |||
Click on the "change" button to the right of the '''CMake Configuration''' field. Append the following to the bottom of the textbox: | |||
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=/opt/toolchains/dc/kos/utils/cmake/dreamcast.toolchain.cmake | |||
Finally, if you want your setup to be badass looking like mine, you can optionally click on the tiny box to the right of the '''Name''' field and specify an icon for your kit. Here is the Dreamcast logo I have used: [[File:Dreamcast icon.png|50px|Icon Used for our custom Dreamcast Qt Creator Kit]] | |||
Click Apply and then OK to exit the dialog box. Congratulations! You can now build CMake projects for the Sega Dreamcast! |
Latest revision as of 16:09, 7 May 2024
NOTE: This page is a work in progress! It will get you set up for compiling and 90% ready for debugging, but the final bit and screenshots are incoming still.
This is a guide to set up the Qt Creator IDE for compilation and source-level debugging on the Sega Dreamcast using the KallistiOS development environment, the CMake build system, and the GDB debugger.
Motivation
Choosing Qt Creator as your IDE for Dreamcast development has several strengths, such as being massively cross-platform, supporting a multitude of devices and toolchains (Windows, Mac, Linux, iOS, Android, WebAssembly, etc), and being extremely easy to add additional toolchains to. I (Falco Girgs) build all of my projects with standard CMake using the CMake toolchain file provided within KOS, and I can swap between targeting a variety of platforms by simply changing an option in a drop-down menu. Not only that, but any active breakpoints or watch variables that I've set up on PC will seamlessly transition over to my Dreamcast and vice versa when changing between targets!
However, the downside is that as of the writing of this tutorial (Qt Creator version 10.0.1), there are a few places where we are forced to do things that are slightly less than ideal or a bit hacky to maneuver around limitations in the configurability of the IDE. In my personal opinion, these are not actually a big deal, and your resulting environment is almost as easy to use as debugging locally; however, there are tutorials for other IDEs if having to click two buttons instead of one to start a remote debugging session or any of the little nuances here rub you the wrong way:
Prerequisites
To start with, this tutorial makes the following assumptions:
- You have already installed and set up your KallistiOS development environment.
- You have already downloaded and installed Qt Creator (version 10.0.1 was used for this tutorial).
Setting up GDB
Before we can begin configuring Qt Creator, we must check to see if gdb
. is installed. You can verify this by checking to see whether you have the executable. It is typically located at /opt/toolchains/dc/sh-elf/bin/sh-elf-gdb
.
Alternatively, if you're currently within a DC environment, simply check to see if you can run sh-elf-gdb
.
If everything goes well, it should start up and leave you at a command prompt. If you do not have GDB installed, see Getting Started with Dreamcast development for instructions on setting up your toolchain. As of May 2024, the toolchain builder script now installs GDB by default.
Verifying Python Support
Note that Qt Creator requires that GDB be built with support for Python scripting extensions. This should be automatically detected and handled by the Makefiles which are checking to see whether Python is installed or not based on your path. You can verify that it was properly built with Python support by running the following command:
gdb --batch -ex 'python import sys; print(sys.version)'
Configuring Qt Creator
Now that we have GDB downloaded and installed, it's time to tell Qt Creator how to use our shiny new Dreamcast toolchain.
Adding the Toolchain
First, select the "Preferences" option from the "Edit" file menu. A dialog window should open. Select first entry, "Kits" from the top of the navigator pane on the left.
Configuring GDB
Next select the right-most "Debuggers" tab from the main view. Depending upon what you installed with Qt Creator, you may or may not see some automatically detected debuggers that it has preconfigured for you.
Next click "Add" to add a new Debugger entry. Then fill out the following fields:
- Name: Dreamcast GDB
- Path: Browse to where your sh-elf-gdb binary wound up being installed. This is /opt/toolchains/dc/sh-elf/bin/sh-elf-gdb by default.
If everything is correct, you should see the following entries populated automatically:
- Type: GDB
- ABIs: sh-baremetal-generic-elf-32bit
- Version: The correct version number corresponding to the toolchain you chose
Configuring Compilers
Next, select the "Compilers" tab on the main tab widget. Again, depending on your Qt installation, you may or may not have a bunch of automatically detected compilers in your list.
C Compiler
First, we add the C compiler from our toolchain. Click the "Add" button in the top-right and select "GCC" from the dropdown. This should create a new entry in the compiler list. Configure it with the following settings:
- Name: Dreamcast GCC
- Path: Browse to where your sh-elf-gcc binary wound up being installed. This is /opt/toolchains/dc/sh-elf/bin/sh-elf-gcc by default.
If everything is good, Qt Creator should auto populate the last two fields:
- ABI: sh-baremetal-generic-elf-32bit
- Target Triple: sh-elf
C++ Compiler
Next, we add the C++ compiler from our toolchain. Click the "Add" button again, select "GCC" again, and this time configure it as such:
- Name: Dreamcast G++
- Path: Browse to where your sh-elf-g++ binary wound up being installed. This is /opt/toolchains/dc/sh-elf/bin/sh-elf-g++ by default.
As with previously, if everything went well, you should see the "ABI" and "Target Triple" fields automatically populated with the same values as with the C compiler.
Configuring the Kit
Finally, select the "Kits" tab from the main tab view. Qt Creator has automatically set up a kit for every platform you've installed a toolchain for (which could be none or many). We now need to add a custom Kit for the Sega Dreamcast.
Click the "Add" button in the top-right of the main view to add an entry to the list of its. Configure it with the following fields:
- Name: Dreamcast GCC-<VERSION>
- Compiler:
- C: Dreamcast GCC
- C++: Dreamcast G++
- Debugger: Dreamcast GDB
- Qt Version: None
- CMake Generator: Unix Makefiles
Click on the "change" button to the right of the Environment field, and add the following:
KOS_BASE=/opt/toolchains/dc/kos KOS_CC_BASE=/opt/toolchains/dc/sh-elf KOS_PORTS=/opt/toolchains/dc/kos-ports KOS_SUBARCH=dreamcast
Click on the "change" button to the right of the CMake Configuration field. Append the following to the bottom of the textbox:
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=/opt/toolchains/dc/kos/utils/cmake/dreamcast.toolchain.cmake
Finally, if you want your setup to be badass looking like mine, you can optionally click on the tiny box to the right of the Name field and specify an icon for your kit. Here is the Dreamcast logo I have used:
Click Apply and then OK to exit the dialog box. Congratulations! You can now build CMake projects for the Sega Dreamcast!