OBS Studio and CLion

OBS Studio and CLion

ddd.png
Since CLion does not seem to be capable of setting up a development environment automatically for OBS Studio (It usually will be unable to compile and run and will hide builds in a deep folder structure) here's how I made CLion play nice with OBS Studio's source code.

CLion is a cross platform C/C++ IDE by jetbrains with great features like code analysis and an integrated debugger. While it's not free you can test if for 30 days or get a free license as a student or apply for a license if you work on a larger open source project.

Since I use it only on linux this guide was only tested there it should technically work on macOS, but I can't confirm that.

1. Getting the source code
Nothing special here, just follow the guide up on github, which boils down to:
  • Install dependencies (Depends on your distribution)
  • clone the repository with $ git clone https://github.com/obsproject/obs-studio.git --recursive
  • Make a build directory $ cd obs-studio && mkdir build-debug
2. Setting up CLion
Now you can open the repository folder in CLion. It'll go over it's usual setup routine, but it won't work or otherwise you wouldn't be reading this. You can let it finish though. After that you'll have to configure CMake to build a portable version of obs, because the normal build won't find the obs data for some reason.

To do this open the settings dialog (File > Settings or Ctrl + Alt + S) and navigate to Build, Execution, Deployment > CMake. Here you can configure different profiles (eg. if you want a separate release and debug profile), but for this we'll just use the existing debug profile and set the following two options in CMake options:
  • -DUNIX_STRUCTURE=0
  • -DCMAKE_INSTALL_PREFIX="${HOME}/git/obs-studio/build-debug"
The path is up to you, if you do want a release profile make sure to set the path to a different one than for debug for obvious reasons. You can also set build options to -j 4 where '4' can be replaced with any number, usually the amount of CPU cores to speed up building.

After you click apply CLion will reload the CMake project and you should be able to build and run obs-studio. For that select Edit configurations... in the top right drop-down menu (Note that if you have two profiles you'll have to repeat this step with both and select the correct path).
Now select obs on the left:
2018-10-01-180935_1350x734_scrot.png
Then under Before Launch section click the plus and then Run External Tool.
New Project.png
In the next dialog click the plus in the top left corner, and then set name and program to make, arguments to install and the working directory to .../obs-studio/cmake-build-debug where '...' is the parent folder of the obs-studio repository (Once again this is for the debug profile, for the release profile there's a separate folder). Now you're ready to build obs studio.

First make sure obs is selected in the top right drop down menu. Then click the green play button in the top right corner of the main window or Shift+ F9 to run the selected target.
Don't worry obs won't run correctly, because it uses the wrong binary, which won't be able to find the obs-data (and even if it does it'll usually report an error about the GPU not being supported).

After the compilation is done, you can dismiss the error dialogs from obs and click Edit Configurations... in the top right drop-down again. Make sure 'obs' is still be selected on the left
and then set Exectuable with 'Select other' to .../build-debug/bin/64bit/obs.

This should now tell CLion to first build and install the binaries into the 'build-debug' folder and then execute the new binary.

So that's it, hope it helps if you ran into the same issues I had.
Author
univrsal
Views
5,006
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from univrsal

Top