<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="utf-8"> <meta property="og:title" content="Build a Discord Bot Using Meson - D++ - The lightweight C++ Discord API Library"> <meta property="og:description" content="A lightweight C++ Discord API library supporting the entire Discord API, including Slash Commands, Voice/Audio, Sharding, Clustering and more!"> <meta name="description" content="Build a Discord Bot Using Meson - D++ - A lightweight C++ Discord API library supporting the entire Discord API, including Slash Commands, Voice/Audio, Sharding, Clustering and more!"> <meta property="og:image" content="https://dpp.dev/DPP-Logo.png"> <meta property="og:url" content="https://dpp.dev/"> <meta property="og:type" content="website"> <meta property="twitter:title" content="Build a Discord Bot Using Meson - D++ - The lightweight C++ Discord API Library"> <title>Build a Discord Bot Using Meson - D++ - The lightweight C++ Discord API Library</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="navtreedata.js"></script> <script type="text/javascript" src="navtree.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> <link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/> <link href="style.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <script> setTimeout(function() { $("#main-menu").html($("#main-menu").html() + "<li><select name='vsv' onchange='window.location.href=this.options[this.selectedIndex].value'><option value='/'>master</option><option value='/10.1.0/'>10.1.0</option><option value='/10.0.35/'>10.0.35</option><option value='/10.0.34/'>10.0.34</option><option value='/10.0.33/'>10.0.33</option><option value='/10.0.32/'>10.0.32</option><option value='/10.0.31/'>10.0.31</option><option value='/10.0.30/'>10.0.30</option><option value='/10.0.29/'>10.0.29</option><option value='/10.0.28/'>10.0.28</option><option value='/10.0.27/'>10.0.27</option><option value='/10.0.26/'>10.0.26</option><option value='/10.0.25/'>10.0.25</option><option value='/10.0.24/'>10.0.24</option><option value='/10.0.23/'>10.0.23</option><option value='/10.0.22/'>10.0.22</option><option value='/10.0.21/'>10.0.21</option><option value='/10.0.20/'>10.0.20</option><option value='/10.0.19/'>10.0.19</option><option value='/10.0.18/'>10.0.18</option><option value='/10.0.17/'>10.0.17</option><option value='/10.0.16/'>10.0.16</option><option value='/10.0.15/'>10.0.15</option><option value='/10.0.14/'>10.0.14</option><option value='/10.0.13/'>10.0.13</option><option value='/10.0.12/'>10.0.12</option><option value='/10.0.11/'>10.0.11</option><option value='/10.0.10/'>10.0.10</option><option value='/10.0.9/'>10.0.9</option><option value='/10.0.8/'>10.0.8</option><option value='/10.0.7/'>10.0.7</option><option value='/10.0.6/'>10.0.6</option><option value='/10.0.5/'>10.0.5</option><option value='/10.0.4/'>10.0.4</option><option value='/10.0.3/'>10.0.3</option><option value='/10.0.2/'>10.0.2</option><option value='/10.0.1/'>10.0.1</option><option value='/10.0.0/'>10.0.0</option><option value='/9.0.19/'>9.0.19</option><option value='/9.0.18/'>9.0.18</option><option value='/9.0.17/'>9.0.17</option><option value='/9.0.16/'>9.0.16</option><option value='/9.0.15/'>9.0.15</option><option value='/9.0.14/'>9.0.14</option><option value='/9.0.13/'>9.0.13</option><option value='/9.0.12/'>9.0.12</option><option value='/9.0.11/'>9.0.11</option><option value='/9.0.10/'>9.0.10</option><option value='/9.0.9/'>9.0.9</option><option value='/9.0.8/'>9.0.8</option><option value='/9.0.7/'>9.0.7</option><option value='/9.0.6/'>9.0.6</option><option value='/9.0.5/'>9.0.5</option><option value='/9.0.4/'>9.0.4</option><option value='/9.0.3/'>9.0.3</option><option value='/9.0.2/'>9.0.2</option><option value='/9.0.1/'>9.0.1</option><option value='/9.0.0/'>9.0.0</option><option value='/1.0.2/'>1.0.2</option><option value='/1.0.1/'>1.0.1</option><option value='/1.0.0/'>1.0.0</option></select></li>"); }, 500); </script> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td id="projectlogo"><img alt="Logo" src="DPP-Logo.png"/></td> <td style="padding-left: 0.5em;"> <div id="projectname">D++ (DPP) </div> <div id="projectbrief">C++ Discord API Bot Library</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <label for="MSearchField" style="display: none">Search</label> <!-- Generated by Doxygen 1.9.3 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ var searchBox = new SearchBox("searchBox", "search",'Search','.html'); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */ </script> <div id="main-nav"></div> </div><!-- top --> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> <div id="nav-sync" class="sync"></div> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(document).ready(function(){initNavTree('buildmeson.html',''); initResizable(); }); /* @license-end */ </script> <div id="doc-content"> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div><div class="header"> <div class="headertitle"><div class="title">Build a Discord Bot Using Meson </div></div> </div><!--header--> <div class="contents"> <div class="textblock"><h2><a class="anchor" id="autotoc_md174"></a> 1. Toolchain</h2> <p >Before compiling, you will need to install <code>meson</code> on your system. To be sure that <code>meson</code> is installed, you can type the following command:</p> <div class="fragment"><div class="line">meson --version</div> <div class="line">0.63.2</div> </div><!-- fragment --><h2><a class="anchor" id="autotoc_md175"></a> 2. Create a Meson project</h2> <p >First, you'll need to go ahead and create an empty directory, we'll call it <code>meson-project</code>.</p> <p >Then, run this command:</p> <div class="fragment"><div class="line">meson init -l cpp</div> </div><!-- fragment --><h2><a class="anchor" id="autotoc_md176"></a> 3. Configuring Your Meson Project</h2> <p >Add the following line after the <code>project()</code> line in your <code>meson.build</code> file.</p> <div class="fragment"><div class="line">dpp = dependency('dpp')</div> </div><!-- fragment --><p >Add the following line in the executable section of your <code>meson.build</code> file.</p> <div class="fragment"><div class="line">dependencies: [dpp]</div> </div><!-- fragment --><p >Change the <code>cpp_std</code> value in the <code>project()</code> to <code>c++20</code>. Your <code>meson.build</code> should look like this:</p> <p >your meson.build should look like this. </p><div class="fragment"><div class="line">project('discord-bot', 'cpp',</div> <div class="line"> version : '0.1',</div> <div class="line"> default_options : ['warning_level=3',</div> <div class="line"> 'cpp_std=c++20'])</div> <div class="line"> </div> <div class="line">dpp = dependency('dpp')</div> <div class="line"> </div> <div class="line">exe = executable('discord', 'discord_bot.cpp',</div> <div class="line"> install : true, dependencies: [dpp])</div> <div class="line"> </div> <div class="line">test('basic', exe)</div> </div><!-- fragment --><p >Meson automatically generates a cpp for your project. And a test suite.</p> <h2><a class="anchor" id="autotoc_md177"></a> 4. Building</h2> <p >To build a Meson project, run the following:</p> <div class="fragment"><div class="line">meson setup builddir</div> <div class="line">meson compile -C builddir</div> </div><!-- fragment --><p >Now, your Meson project should be all setup!</p> <p ><b>Have fun!</b> </p> </div></div><!-- contents --><script src="https://giscus.app/client.js" data-repo="brainboxdotcc/dpp-comments" data-repo-id="R_kgDOHOY4xg" data-category="General" data-category-id="DIC_kwDOHOY4xs4CRYtj" data-mapping="pathname" data-strict="1" data-reactions-enabled="1" data-emit-metadata="1" data-input-position="top" data-theme="preferred_color_scheme" data-lang="en" data-loading="lazy" crossorigin="anonymous" async></script> </div><!-- PageDoc --> </div><!-- doc-content --> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="creating-a-discord-bot.html">Creating a Discord Bot</a></li> </ul> </div> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-QTH6YHBNG5"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/base16/dracula.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.8.0/highlightjs-line-numbers.min.js"></script> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@100&display=swap" rel="stylesheet"> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-QTH6YHBNG5'); $(function() { $(".fragment").each(function(i,node) { var $node = $(node); $node.children(":not(.line)").remove(); $node.html("<pre><code class='stan'>" + $node.text().trim().replaceAll("<", "<").replaceAll(">", ">") + "</code></pre>"); hljs.configure({ languages: ['cpp','diff','cmake','bash','sh','text'], ignoreUnescapedHTML: true }); hljs.highlightAll(node); hljs.initLineNumbersOnLoad(node); }); $(".fragment").parent().parent().parent().parent().removeClass('doxtable'); }); </script> <style> .hljs-ln-code, code, code a, pre.fragment, div.fragment, div.fragment .line, div.fragment span, div.fragment .line a, div.fragment .line span { font-family: 'JetBrains Mono', monospace !important; font-size: 0.8rem !important; } .fragment { padding: 0 !important; margin-top: 0 !important; margin-bottom: 0 !important; background: none !important; border: 0 !important; } .hljs-ln-n::before { content: attr(data-line-number); padding-right: 1rem !important; } table.markdownTable code td, table.markdownTable code th, table.fieldtable code td, table.fieldtable code th, table.doxtable code td, table.doxtable code th { border: 0 !important; padding: 0 !important; } </style> <div style="z-index: -9999; position: absolute; right: 0; top: 0; font-size: 0.0001rem;color:transparent;background:none"> <!-- For crawlability of past versions --> <a href='/https/raw.githubusercontent.com/10.1.0/'>D++ Library version 10.1.0</a><a href='/https/raw.githubusercontent.com/10.0.35/'>D++ Library version 10.0.35</a><a href='/https/raw.githubusercontent.com/10.0.34/'>D++ Library version 10.0.34</a><a href='/https/raw.githubusercontent.com/10.0.33/'>D++ Library version 10.0.33</a><a href='/https/raw.githubusercontent.com/10.0.32/'>D++ Library version 10.0.32</a><a href='/https/raw.githubusercontent.com/10.0.31/'>D++ Library version 10.0.31</a><a href='/https/raw.githubusercontent.com/10.0.30/'>D++ Library version 10.0.30</a><a href='/https/raw.githubusercontent.com/10.0.29/'>D++ Library version 10.0.29</a><a href='/https/raw.githubusercontent.com/10.0.28/'>D++ Library version 10.0.28</a><a href='/https/raw.githubusercontent.com/10.0.27/'>D++ Library version 10.0.27</a><a href='/https/raw.githubusercontent.com/10.0.26/'>D++ Library version 10.0.26</a><a href='/https/raw.githubusercontent.com/10.0.25/'>D++ Library version 10.0.25</a><a href='/https/raw.githubusercontent.com/10.0.24/'>D++ Library version 10.0.24</a><a href='/https/raw.githubusercontent.com/10.0.23/'>D++ Library version 10.0.23</a><a href='/https/raw.githubusercontent.com/10.0.22/'>D++ Library version 10.0.22</a><a href='/https/raw.githubusercontent.com/10.0.21/'>D++ Library version 10.0.21</a><a href='/https/raw.githubusercontent.com/10.0.20/'>D++ Library version 10.0.20</a><a href='/https/raw.githubusercontent.com/10.0.19/'>D++ Library version 10.0.19</a><a href='/https/raw.githubusercontent.com/10.0.18/'>D++ Library version 10.0.18</a><a href='/https/raw.githubusercontent.com/10.0.17/'>D++ Library version 10.0.17</a><a href='/https/raw.githubusercontent.com/10.0.16/'>D++ Library version 10.0.16</a><a href='/https/raw.githubusercontent.com/10.0.15/'>D++ Library version 10.0.15</a><a href='/https/raw.githubusercontent.com/10.0.14/'>D++ Library version 10.0.14</a><a href='/https/raw.githubusercontent.com/10.0.13/'>D++ Library version 10.0.13</a><a href='/https/raw.githubusercontent.com/10.0.12/'>D++ Library version 10.0.12</a><a href='/https/raw.githubusercontent.com/10.0.11/'>D++ Library version 10.0.11</a><a href='/https/raw.githubusercontent.com/10.0.10/'>D++ Library version 10.0.10</a><a href='/https/raw.githubusercontent.com/10.0.9/'>D++ Library version 10.0.9</a><a href='/https/raw.githubusercontent.com/10.0.8/'>D++ Library version 10.0.8</a><a href='/https/raw.githubusercontent.com/10.0.7/'>D++ Library version 10.0.7</a><a href='/https/raw.githubusercontent.com/10.0.6/'>D++ Library version 10.0.6</a><a href='/https/raw.githubusercontent.com/10.0.5/'>D++ Library version 10.0.5</a><a href='/https/raw.githubusercontent.com/10.0.4/'>D++ Library version 10.0.4</a><a href='/https/raw.githubusercontent.com/10.0.3/'>D++ Library version 10.0.3</a><a href='/https/raw.githubusercontent.com/10.0.2/'>D++ Library version 10.0.2</a><a href='/https/raw.githubusercontent.com/10.0.1/'>D++ Library version 10.0.1</a><a href='/https/raw.githubusercontent.com/10.0.0/'>D++ Library version 10.0.0</a><a href='/https/raw.githubusercontent.com/9.0.19/'>D++ Library version 9.0.19</a><a href='/https/raw.githubusercontent.com/9.0.18/'>D++ Library version 9.0.18</a><a href='/https/raw.githubusercontent.com/9.0.17/'>D++ Library version 9.0.17</a><a href='/https/raw.githubusercontent.com/9.0.16/'>D++ Library version 9.0.16</a><a href='/https/raw.githubusercontent.com/9.0.15/'>D++ Library version 9.0.15</a><a href='/https/raw.githubusercontent.com/9.0.14/'>D++ Library version 9.0.14</a><a href='/https/raw.githubusercontent.com/9.0.13/'>D++ Library version 9.0.13</a><a href='/https/raw.githubusercontent.com/9.0.12/'>D++ Library version 9.0.12</a><a href='/https/raw.githubusercontent.com/9.0.11/'>D++ Library version 9.0.11</a><a href='/https/raw.githubusercontent.com/9.0.10/'>D++ Library version 9.0.10</a><a href='/https/raw.githubusercontent.com/9.0.9/'>D++ Library version 9.0.9</a><a href='/https/raw.githubusercontent.com/9.0.8/'>D++ Library version 9.0.8</a><a href='/https/raw.githubusercontent.com/9.0.7/'>D++ Library version 9.0.7</a><a href='/https/raw.githubusercontent.com/9.0.6/'>D++ Library version 9.0.6</a><a href='/https/raw.githubusercontent.com/9.0.5/'>D++ Library version 9.0.5</a><a href='/https/raw.githubusercontent.com/9.0.4/'>D++ Library version 9.0.4</a><a href='/https/raw.githubusercontent.com/9.0.3/'>D++ Library version 9.0.3</a><a href='/https/raw.githubusercontent.com/9.0.2/'>D++ Library version 9.0.2</a><a href='/https/raw.githubusercontent.com/9.0.1/'>D++ Library version 9.0.1</a><a href='/https/raw.githubusercontent.com/9.0.0/'>D++ Library version 9.0.0</a><a href='/https/raw.githubusercontent.com/1.0.2/'>D++ Library version 1.0.2</a><a href='/https/raw.githubusercontent.com/1.0.1/'>D++ Library version 1.0.1</a><a href='/https/raw.githubusercontent.com/1.0.0/'>D++ Library version 1.0.0</a> </div> </body> </html>