3. Development environment (C++): Linux + CLion¶
This is how to develop on a Linux desktop using CLion by JetBrains. In this document, we use CLion 2017.1.2.
CLion also supports Microsoft Visual Studio keymapping. You can change Visual Studio’s keymapping in File -> Settings -> Keyamp -> Keymaps.
3.1. Starting a new project¶
Enter the following commands in a command shell to begin a new project called my_project .
$ funapi_initiator my_project
Your new project is in a directory with ‘-source’ as a suffix. For example, the project above will be named my_project-source. The game development team can put this directory in an SVN or GIT repository to share it.
3.2. Creating a CLion solution file¶
Enter the following:
$ my_project-source/setup_build_environment --type=clion
A newly created source directory now opens in CLion.
$ clion.sh ~/my_project-source
The clion.sh path may differ depending on where CLion is installed.
3.3. Configuring debugging in CLion¶
- Click on the File menu at the top left of the IDE, and then Reload CMake Project to proceed a project synchronization. You will see messages reading Indexing ..., Building Symbols ..., or Loading Symbols ... during synchronization. This may take from seconds to minutes depending on your Linux box.
- Once the synchronization gets completed, a dropdown list entitled Build All is displayed at the upper right of the IDE. You can use this menu to modify build configuration or choose debug/release configuration. Build All is for a debug build, while Build All (Release) is for a release build.
You now need to configure program arguments and LD_LIBRARY_PATH. First, click on Build All in CLion to build. Open up a terminal window and move to a build output directory named my_project-build/Debug. Type in the following command. Output may differ depending on the project location.
$ ./my_project-build/Debug/my_project-local --args --main_program_name=my_project_server.default --app_flavor=default --framework_manifest_path=/usr/share/funapi/manifests:/home/ubuntu/my_project-build/Debug/manifests/default --framework_manifest_override_file=/etc/my_project/MANIFEST.override.json --main_enabled_components=my_projectServer --resource_root=/home/ubuntu/my_project-build/Debug/resources --log_root_dir=/home/ubuntu/my_project-build/Debug/logs --crashdump_root_dir=/home/ubuntu/my_project-build/Debug/dumps --max_log_size=10 --alsologtostderr --stop_logging_if_full_disk
This is only for the debug configuration. For release configuration, enter hello-build/RelWithDebInfo instead of hello-build/Debug.
Similarly, if you are using Flavors: Identifying servers according to their role, enter --args in the local script for the flavor. If you have a flavor called game, you would enter the following:
$ ./my_project-build/Debug/my_project.game-local --args --main_program_name=my_project_server.game --app_flavor=game --framework_manifest_path=/usr/share/funapi/manifests:/home/ubuntu/my_project-build/Debug/manifests/game --framework_manifest_override_file=/etc/my_project/MANIFEST.game.override.json --main_enabled_components=MyProjectServer --resource_root=/home/ubuntu/my_project-build/Debug/resources --log_root_dir=/home/ubuntu/my_project-build/Debug/logs --crashdump_root_dir=/home/ubuntu/my_project-build/Debug/dumps --max_log_size=10 --alsologtostderr --stop_logging_if_full_disk
Go to Run -> Edit Configuration in the CLion menu and paste the output obtained above into the Program arguments for my_project.
LD_LIBRARY_PATH must be in the form like a following. Again, the exact path may differ depending on the project location.
Click on the ... at the right of Environment variables, and set the LD_LIBRARY_PATH variable.
- After finishing the steps, right-click on External Libraries and click on Reload CMake Project to have CLion learn required libraries.
3.4. Debugging in CLion¶
You can set a debug breakpoint and run debug to debug your chosen build configuration. If debugging does not work, please double-check if LD_LIBRARY_PATH is correctly configured.
3.5. Game packaging in CLion¶
If you choose Package instead of Build All, your game server will appear in a package file under the my_project-build/Debug directory. For more on packaging, please see Server management part 3: Server packaging.
If you choose Package (Release), a package for the release build is generated under my_project-build/ReleaseWithDebInfo.