From BlenderWiki

Jump to: navigation, search

Optimized IDE Setup on Linux

Some of the steps in this guide are not immediately obvious even for experienced linux users/developers so I have written up this document for others who are interested in developing blender on linux.


Qtc blender 25.png


Who Is This For?

Linux developers who want to setup an efficient build environment.

There are a number of aspects that help to achieve this:

  • CMake (significantly faster than Scons)
  • QtCreator has a fast C/C++ source code indexer (much faster than eclipse/netbeans/kdevelop)
  • Avoid executing the install target (no copying files on rebuild), instead reference the files in-place to run blender.

Starting out

This document assumes you have built blender using the Linux/CMake Quickstart.

  • blender source in ~/blender-svn/blender
  • build blender with CMake in ~/blender-svn/build

This was tested on ubuntu 10.04 but should also work on 9.10 and other linux distributions.

Installing QtCreator

QtCreator is an IDE which can be used for general C/C++ development, not just QT Applications, it has an editor, debugger, auto-completion as well as svn and cmake integration.

Download and install from QT's site: http://qt.nokia.com/downloads (tested with version 2.1, 2.2, 2.3, 2.4)

Configure QtCreator

Launch QtCreator.

Before loading a blender project make some minor changes to QtCreators defaults.

Open the Options dialog Tools -> Options

Projects

  • Always build Project before Running (disable)


For instructions on configuring QtCreator for blenders style

see: http://wiki.blender.org/index.php/Dev:Doc/CodeStyle/Configuration#QtCreator

Making a new QtCreator Project

Create the Project

Note, for now I recommend use the custom project file generator included with blender until QtCreator's has support for reading CMakes defines & includes!

Using Blenders Custom Project File Generator

From your cmake dir run blenders project file generator. You may want to make some short cut to this - a shell script, bash alias or QtCreator external command all work fine.

cd ~/blender-svn/build
python3.2 ../blender/build_files/cmake/cmake_qtcreator_project.py

From QtCreator go to File -> Open and select ~/blender-svn/build/blender.creator

Configuring the Project

Now you should see the blender project open, start by pressing the build button, this should be very quick since blender has been built before.

To run blender you'll need to point to the blender executable: Projects (side toolbar) -> Run Settings (Tab), then see the "Executable" field, browse for the executable.

Using QtCreators CMake Project Support (deprecated for now)

  • File -> Open File or Project, Select ~/blender-svn/blender/CMakeLists.txt

This invokes the CMake Wizard

  • Build Location change the build directory to ~/blender-svn/build and press Next
  • Run CMake, Press the "Run CMake" button, then finish.
    note: this will use the configuration selected when first building blender from the command line.
Configuring the Project

Now you should see the blender project open, start by pressing the build button, this should be very quick since blender has been built before.

To run blender you need to select the binary, on the left hand side there is a "Projects" section, Select Run Settings, Change the run configuration from makesdna to blender and press "Make blender Active".

To re-open the project after re-starting QtCreator, select this project from File -> Recent Projects

Optimize Rebuilds

Now you can build blender and run blender there are changes you can make which greatly increase the speed of build times.

There are various ways to configure cmake but I use this.

# ccmake or cmake-gui both work.
ccmake ~/blender-svn/build

You may also want to set CMAKE_BUILD_TYPE to Debug option at this point for debugging.

For really fast rebuilds you can disable Every option with the WITH_ prefix, except for WITH_PYTHON which is needed for the UI, this speeds up linking and gives a smaller binary.

Press C to configure then Q to quit

Remove the files created by make install since they will become stale. However blender still needs to be able to find its scripts or you will have a very minimalist looking interface. This can be solved by linking the subversion directory to your blender binary path so copying isn't needed and scripts are always up to date.

rm -rf ~/blender-svn/build/bin/*.*
ln -s ~/blender-svn/blender/release ~/blender-svn/build/bin/

For convenient access to be run blender from the source directory create this symlink...

 ln -s ~/blender-svn/build/bin/blender ~/blender-svn/blender/blender.bin

Partial Rebuilds

This is better suited for the command line, but its worth noting that you can tell make only to rebuild a part of blender with cmake.

# prints a list of build targets.
make help
# rebuilds only python files and creates the blender executable.
make blender/fast bf_python

A script is included so this is more convenient.

./build_files/build/example_scripts/make_quicky.py

This script matches partial names so "py" covers "bf_python" and "bf_python_ext"

If you build often you may want to assign an alias to execute make_quicky.py.

Additional Info

  • Blender can be updated from subversion within QtCreator
    Tools -> Subversion -> Update Project "Blender"
  • QtCreator stores its build directory in ~/blender-svn/blender/CMakeLists.txt.user, if you have some configuration problem and wish to start over be sure to remove this file first.

QtCreator Videos

Trouble Shooting

Ubuntu / Ptrace Error

On ubuntu there is a reported error running a debug binary within QtCreator, solution is:

Set 'ptrace_scope' to 0 in /etc/sysctl.d/10-ptrace.conf and reboot

See also

Comparison QtCreator/KDevelop4 by Xat