{"id":1132,"date":"2022-07-16T23:51:20","date_gmt":"2022-07-16T14:51:20","guid":{"rendered":"https:\/\/colory-games.net\/site\/?p=1132"},"modified":"2023-11-04T20:45:43","modified_gmt":"2023-11-04T11:45:43","slug":"ue_start_cpp-en","status":"publish","type":"post","link":"https:\/\/colory-games.net\/site\/en\/ue_start_cpp-en\/","title":{"rendered":"[UE5] How to Introduce C++"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><p>*<strong>The content of this article is applicable to UE4.<\/strong><\/p>\n<p>Do you want to use C++ in Unreal Engine (create a C++ class)?<br>\nDo you want to run a C++ sample you found on the internet?<\/p>\n<p>To meet these requests, you need to configure Unreal Engine to use C++.<\/p>\n<p>This article explains <strong>How to install C++ in Unreal Engine<\/strong> and <strong>How to add C++ header files and source files (C++ classes)<\/strong>.<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#How_to_Introduce_C\">How to Introduce C++<\/a><ul><li><a href=\"#1_Check_the_Installation_Status_of_Visual_Studio_2019\">1. Check the Installation Status of Visual Studio 2019<\/a><\/li><li><a href=\"#2_Install_Visual_Studio_2019\">2. Install Visual Studio 2019<\/a><\/li><li><a href=\"#3_Generate_Visual_Studio_Project_Files\">3. Generate Visual Studio Project Files<\/a><\/li><li><a href=\"#4_Add_C_header_files_and_source_files_C_classes\">4. Add C++ header files and source files (C++ classes)<\/a><\/li><li><a href=\"#5_Build_Compile_Source_Code\">5. Build (Compile) Source Code<\/a><\/li><\/ul><\/li><li><a href=\"#When_to_Perform_the_Same_Procedure_Again\">When to Perform the Same Procedure Again<\/a><\/li><\/ul><\/div>\n<h1><span id=\"How_to_Introduce_C\">How to Introduce C++<\/span><\/h1>\n<p>Here are the steps to introduce C++ to Unreal Engine.<br>\nWe will explain each step.<\/p>\n<ol>\n<li>Check the installation status of Visual Studio 2019<\/li>\n<li>Install Visual Studio 2019<\/li>\n<li>Generate Visual Studio project files<\/li>\n<li>Add C++ header files and source files (C++ classes)<\/li>\n<li>Build (compile) source code<\/li>\n<\/ol>\n<h2><span id=\"1_Check_the_Installation_Status_of_Visual_Studio_2019\">1. Check the Installation Status of Visual Studio 2019<\/span><\/h2>\n<p>In order to use C++ with the Unreal Engine (&quot;UE&quot;), a C++ development environment must be installed.<br>\nSince Visual Studio 2019 is often used as the development environment, this article will explain how to install Visual Studio 2019.<\/p>\n<p>You can <strong>check<\/strong> whether Visual Studio 2019 is installed by using one of the following methods (1), (2).<\/p>\n<h3>Method (1) Check by Creating a New Project<\/h3>\n<p>Launch the UE editor (UnrealEditor.exe).<\/p>\n<p>On the project selection screen, select &quot;Games&quot; tab &#8211; &quot;Blank&quot;, and select &quot;C++&quot; in Project Defaults (See the figure below).<br>\nIf the message <strong>&quot;No Compiler was found&#8230;&quot; is displayed, it means that it is not yet installed<\/strong>.<br>\nClick the &quot;Install Visual Studio 2019&quot; button and proceed to STEP2.<br>\nIf the message is not displayed, Visual Studio 2019 has already been installed, and you can proceed to STEP3.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/confirm_install_1.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/confirm_install_1.png?ssl=1\" alt=\"VS2019 Check Method 1\" data-recalc-dims=\"1\"><\/a><\/p>\n<h3>Method (2) Check by Opening an Existing Project<\/h3>\n<p>Start a project that has already been created.<\/p>\n<p>Select &quot;Tools&quot; tab &#8211; &quot;New C++ Class&#8230;&quot;. (See the figure below).<br>\nIf the message <strong>&quot;No Compiler was found&#8230;&quot; is displayed, it means that it is not yet installed<\/strong>.<br>\nClick the &quot;Install Visual Studio 2019&quot; button and proceed to STEP2.<br>\nIf the message is not displayed, Visual Studio 2019 has already been installed, and you can proceed to STEP3.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/\/confirm_install_2.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/confirm_install_2.png?ssl=1\" alt=\"VS2019 Check Method 2\" data-recalc-dims=\"1\"><\/a><\/p>\n<h2><span id=\"2_Install_Visual_Studio_2019\">2. Install Visual Studio 2019<\/span><\/h2>\n<p>You need to do this procedure if Visual Studio 2019 has not yet been installed.<\/p>\n<p>On the screen that appears immediately after pressing the &quot;Install Visual Studio 2019&quot; button in STEP 1, we will <strong>download Visual Studio Installer<\/strong>.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_1.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_1.png?ssl=1\" alt=\"Download Installer\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>Confirm the contents, and then go next step.<br>\nThere are several editions for Visual Studio 2019.<br>\nWe will install Visual Studio Community 2019, which is basically free for personal use.<br>\nFor commercial use, please check Microsoft&#8217;s license terms.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_2.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_2.png?ssl=1\" alt=\"Install VS2019\" data-recalc-dims=\"1\"><\/a><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_3.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_3.png?ssl=1\" alt=\"Install VS2019\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>Finally, the installation is complete when Visual Studio 2019 launches correctly.<br>\nThen, you need to reboot the PC.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_4.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/install_4.png?ssl=1\" alt=\"Install VS2019\" data-recalc-dims=\"1\"><\/a><\/p>\n<h2><span id=\"3_Generate_Visual_Studio_Project_Files\">3. Generate Visual Studio Project Files<\/span><\/h2>\n<p>Generate a Visual Studio project file.<br>\nThe procedure depends on whether you want to create <strong>a new Unreal Engine project at the same time<\/strong> or <strong>generate a project file for an existing Unreal Engine project<\/strong>.<\/p>\n<h3>Case 1: A new Unreal Engine Project<\/h3>\n<p>Launch UnrealEditor.exe.<\/p>\n<p>On the project selection screen, select &quot;Games&quot; tab &#8211; &quot;Blank&quot;, select &quot;C++&quot; in Project Defaults, and press the &quot;Create&quot; button (See figure).<\/p>\n<blockquote>\n<p>If you want to create a project without &quot;C++&quot; selection, generate a Visual Studio project file by the method described in Case 2.<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_1.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_1.png?ssl=1\" alt=\"Generate Project File\" data-recalc-dims=\"1\"><\/a><\/p>\n<blockquote>\n<p>The following error message may appear when you create a project. In this case, please install .NET Core runtime from the link in the error text.<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_error.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_error.png?ssl=1\" alt=\"Error during Project Creation\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>After the creation process is completed, Visual Studio project file (.sln file) will be generated in the UE project folder.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_2.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_2.png?ssl=1\" alt=\"Generate Project File\" data-recalc-dims=\"1\"><\/a><\/p>\n<h3>Case 2: An existing Unreal Engine Project<\/h3>\n<p>Launch an existing Unreal Engine project.<\/p>\n<p>Visual Studio project file will be generated at the STEP4.<br>\nYou can proceed to STEP4.<\/p>\n<blockquote>\n<p>The following error message may appear during STEP4. In this case, you need to install .NET Core runtime from the link in the error message.<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_error.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/generate_vsfile_error.png?ssl=1\" alt=\"Error during Project Creation\" data-recalc-dims=\"1\"><\/a><\/p>\n<h2><span id=\"4_Add_C_header_files_and_source_files_C_classes\">4. Add C++ header files and source files (C++ classes)<\/span><\/h2>\n<p>Select &quot;Tools&quot; tab &#8211; &quot;New C++ Class&#8230;&quot; and select the class you wish to add to the displayed screen.<br>\nThen, click the &quot;Next&quot; button (See the figure below).<br>\nIn this example, Actor is selected.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/add_cpp_class_1.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/add_cpp_class_1.png?ssl=1\" alt=\"Add Class\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>Next, enter a file name (class name) and save location (See \u2460 and \u2461 in the figure), and click the &quot;Create Class&quot; button (See \u2462 in the figure).<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/add_cpp_class_2.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/add_cpp_class_2.png?ssl=1\" alt=\"Add Class\" data-recalc-dims=\"1\"><\/a><\/p>\n<p>Note that <strong>C++ files cannot be deleted, moved, or renamed in this procedure<\/strong>.<br>\nIf you are familiar with C++ development, please refer to the following article for more details.<\/p>\n<ul>\n<li><a href=\"https:\/\/colory-games.net\/site\/ue-add-cpp-file\/\">[UE5] How to Add\/Delete C++ Files (Classes)<\/a><\/li>\n<\/ul>\n<h2><span id=\"5_Build_Compile_Source_Code\">5. Build (Compile) Source Code<\/span><\/h2>\n<p><strong>Close UE editor.<\/strong><\/p>\n<blockquote>\n<p>If not closed, an error will be raised at compile time.<\/p>\n<\/blockquote>\n<p>Open the Visual Studio project file (.sln file) in the UE project folder and build it (See \u2460 and \u2461 in the figure).<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/compile_1.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/compile_1.png?ssl=1\" alt=\"Compile\" data-recalc-dims=\"1\"><\/a><\/p>\n<p><strong>If it ends normally, the compilation havesuccessfully completed<\/strong>.<br>\nFrom now, you can freely create C++ classes in this environment.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/compile_2.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/colory-games.net\/site\/wp-content\/uploads\/tech-blog\/beisaku\/2022\/07\/20220716\/compile_2.png?ssl=1\" alt=\"Compile\" data-recalc-dims=\"1\"><\/a><\/p>\n<h1><span id=\"When_to_Perform_the_Same_Procedure_Again\">When to Perform the Same Procedure Again<\/span><\/h1>\n<p>For each of the steps (STEP 1-5), we <strong>need to be re-executed<\/strong> in the development in C++.<\/p>\n<table>\n<thead>\n<tr>\n<th>STEP<\/th>\n<th>Re-execution<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1-2<\/td>\n<td>Only once after you buy the PC<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>Only once after you create an Unreal Engine project<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>Execute each time when C++ file is changed (added, deleted, moved, renamed)<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>Each time when the source code (C++ file) is edited<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article explains how to introduce C++ in the Unreal Engine and how to add C++ header and source files (C++ classes).  <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"templates\/single-home-techblog.php","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[179,154,94,71],"tags":[181,122],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts\/1132"}],"collection":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/comments?post=1132"}],"version-history":[{"count":2,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts\/1132\/revisions"}],"predecessor-version":[{"id":1145,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/posts\/1132\/revisions\/1145"}],"wp:attachment":[{"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/media?parent=1132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/categories?post=1132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/colory-games.net\/site\/wp-json\/wp\/v2\/tags?post=1132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}