Setting up a QtCreator dev environment (Linux)

Setting up a QtCreator dev environment (Linux)

Postby Suitecake » 31 Mar 2014, 22:28

Hi all. I'm using QtCreator to compile and dig through the code, so I figured I'd write a quick tutorial on how to get Valyria Tear compiled and running within QtCreator.

This was all on Crunchbang (Debian) using QtCreator 3.0.1.
(Verified to work on Linux Mint 17, August 2014)

### OPENING VALYRIA TEAR IN QtCreator ###

-- Install QtCreator
-- Clone the Valyria Tear repo
I've got mine at ~/src/ValyriaTear, and will be giving directories in terms of that set-up. Adjust if you install elsewhere.
-- Open QtCreator
-- Click File --> Open File or Project
_What?_ Yep! QtCreator can open a CMakeLists.txt as a project. You don't need any additional, IDE-specific project file to use QtCreator with Valyria Tear. Everything you need is in the repo already. Cool eh?
-- Open ~/src/ValyriaTear/CMakeLists.txt
This will open the CMake Wizard, prompting you to select a build location. It can be left at the default (should be ~/src/ValyriaTear-build). We'll configure this later.
NOTE: If Qt Creator opens CMakeLists.txt as a text file and doesn't start the CMake Wizard, you may have to install a separate CMake plugin for QtCreator (the build available in the Ubuntu repositories itemizes it out as 'qtcreator-plugin-cmake').
-- On the Build Location screen, click Next (accept the default)
-- On the Run CMake screen, click Run CMake
Don't worry about any arguments, we'll configure these later. If everything works properly (ie, you have all the dependencies), the Finish button should become enabled.
-- Click 'Finish.'
QtCreator will now show your 'new project' (derived from the existing CMakeLists.txt). You can go ahead and build the project to make sure it all works, but the resulting executable won't work yet. We still have some configuring to do!

### BUILD CONFIGURATIONS ###

Currently, the Valyria Tear build process assumes that either the resulting executable will be built in the same directory as the data folders (dat/, img/, mus/ and snd/) or that the Valyria Tear binary has been installed, so that the data folders have been installed. We'll configure Qt Creator to allow for both 'Debug' and 'Release' build configurations, in separate build folders so that these configurations can be switched between without rebuilding the project.

-- Click 'Projects' on the left hand toolbar.
You should see 'Build Settings', with the default build directory specified from earlier.
-- Click Add --> Clone Selected.
-- Name the new configuration 'Release.'
-- Next to the build directory, select 'Change'.
-- Change the build directory to ~/src/ValyriaTear-rel
-- Run CMake with no arguments.
-- Click Finish.

Now we need to copy the data folders into the release build folder on each build.

-- Click 'Add Build Step' and select 'Custom Process Step'
-- Set command as rm
-- Set arguments as -rf ./dat ./img ./snd ./mus
-- Leave working directory as default (should be %{buildDir})

The resulting command should be rm -rf ./dat ./img ./snd ./mus. This will delete the data folders from the build directory on each build (if they exist).

-- Click 'Add Build Step' and select 'Custom Process Step'
-- Set command as cp
-- Set arguments as -r ~/src/ValyriaTear/dat .
-- Leave working directory as default (should be %{buildDir})
-- Repeat the above steps, replacing ~/src/ValyriaTear/dat with ~/src/ValyriaTear/img, ~/src/ValyriaTear/snd and ~/src/ValyriaTear/mus

We also need to delete these folders on clean.

-- Click 'Add Clean Step' and select 'Custom Process Step'
-- Set command and arguments to the same values as the first process step for the build (rm -rf ./dat ./img ./snd ./mus)

Your build is now all set up! Now we need to adjust the Run configuration for Release.

-- Click 'Run' (under the currently selected kit; for me, 'Desktop')
This should display the Run Settings screen.
-- Next to 'Run configuration:', click Rename
-- Rename to Release
-- Change the working directory from ~/src/ValyriaTear-rel/src to ~/src/ValyriaTear-rel/

And that's it! You now should have a working Release build and run configuration. To test it out, clean and build your project. Once it is built, run the project. Valyria Tear should start running.

### SETTING UP A DEBUG CONFIGURATION ###

Setting up a debug configuration will be very simple in comparison, since we'll be able to clone the Release configuration and simply make a few adjustments.

-- Go to the Projects tab again.
-- Go to the Build Settings page again (if not on it).
-- Next to 'Edit build configuration', make sure 'Release' is selected and click 'Add'
-- Choose 'Clone selected'
-- Enter the name 'Debug'
-- Next to build directory, click Change
-- Change the build directory from ~/src/ValyriaTear-rel to ~/src/ValyriaTear-dbg
-- On the Run CMake screen, enter the following arguments: -DCMAKE_BUILD_TYPE=Debug -DDEBUG_FEATURES=on
This will get you the debug features, as well as the debug symbols
-- Click Run CMake
-- Click Finish
-- Go to the Run tab
-- Next to Run configuration, click Add
-- Select valyriatear
-- Rename to 'Debug'
-- Change Working directory from ~/src/ValyriaTear-dbg/src to ~/src/ValyriaTear-dbg

And that's it! Select the debug configuration on the configuration selector (above the Run buttons on the left hand toolbar), and build your project. Press F5 to begin debugging.
Last edited by Suitecake on 24 Aug 2014, 20:41, edited 2 times in total.
Suitecake
 
Posts: 17
Joined: 07 Oct 2013, 20:50

Re: Setting up a QtCreator dev environment (Linux)

Postby Bertram » 01 Apr 2014, 09:33

Cool tutorial. Thanks! :) (I've stickied this.)
User avatar
Bertram
VT Moderator
 
Posts: 1635
Joined: 09 Nov 2012, 12:26

Re: Setting up a QtCreator dev environment (Linux)

Postby Suitecake » 01 Apr 2014, 15:51

Thanks! I hope it's useful to others (and that no typos crept in)
Suitecake
 
Posts: 17
Joined: 07 Oct 2013, 20:50

Re: Setting up a QtCreator dev environment (Linux)

Postby Suitecake » 28 Dec 2014, 23:58

I've switched over to vs2013 as my primary IDE. No promises that this walkthrough is still accurate.
Suitecake
 
Posts: 17
Joined: 07 Oct 2013, 20:50

Who is online

Users browsing this forum: No registered users and 1 guest