<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: DracoRX</title>
    <description>The latest articles on Forem by DracoRX (@dracorx).</description>
    <link>https://forem.com/dracorx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1245287%2Fcb28952c-fd94-4513-ad70-61f9f926019c.jpg</url>
      <title>Forem: DracoRX</title>
      <link>https://forem.com/dracorx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dracorx"/>
    <language>en</language>
    <item>
      <title>Guide : How to Setup C++ on MacOS with Sublime Text and gcc (without homebrew)</title>
      <dc:creator>DracoRX</dc:creator>
      <pubDate>Sun, 31 Dec 2023 07:50:33 +0000</pubDate>
      <link>https://forem.com/dracorx/guide-how-to-setup-c-on-macos-with-sublime-text-and-gcc-without-homebrew-4nf6</link>
      <guid>https://forem.com/dracorx/guide-how-to-setup-c-on-macos-with-sublime-text-and-gcc-without-homebrew-4nf6</guid>
      <description>&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;Install &lt;a href="https://www.macports.org/install.php" rel="noopener noreferrer"&gt;MacPorts &lt;/a&gt;for your respective version of MacOS.&lt;br&gt;
Installation process is as simple as installing the .pkg file and opening it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ports.macports.org/search/" rel="noopener noreferrer"&gt;Search for the version of gcc you wish to install. &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftw0dpm4zotkig7lqk236.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftw0dpm4zotkig7lqk236.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do as it says and copy the command given and paste it in the terminal. The installation process will take a few minutes, but it's much faster than installing from homebrew.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3
&lt;/h2&gt;

&lt;p&gt;Install &lt;a href="https://www.sublimetext.com/" rel="noopener noreferrer"&gt;Sublime Text.&lt;/a&gt;&lt;br&gt;
Create a new file with &lt;strong&gt;cmd + N&lt;/strong&gt; and save it as test.cpp (or anything you want).&lt;/p&gt;

&lt;p&gt;Go to View -&amp;gt; Layout -&amp;gt; Colums: 3&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv0dppg1ztgkqco3qxy9i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv0dppg1ztgkqco3qxy9i.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go to View -&amp;gt; Groups -&amp;gt; Max Columns: 2&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzhtyahys8gtjpxtzdmcu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzhtyahys8gtjpxtzdmcu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your window should now look something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkauqipkq8vui1rny431x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkauqipkq8vui1rny431x.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now save test.cpp, input.txt and output.txt in the respective sections as shown in the image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9b6zgfinah2v6zfutlsb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9b6zgfinah2v6zfutlsb.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Paste this code as your main function. This will take you inputs from input.txt and print the outputs in output.txt&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);
    #endif

    //start your code from here

    return 0;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 4
&lt;/h2&gt;

&lt;p&gt;Now for the last step we will create a build system.&lt;/p&gt;

&lt;p&gt;Go to Tools -&amp;gt; Build System -&amp;gt; New Build System&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0sthdipz4b1ul8ywo27.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0sthdipz4b1ul8ywo27.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now open finder and find the path where gcc was installed. Usually it is installed in /opt/local/bin. (use &lt;strong&gt;cmd + G&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;Now search for the unix executable file. It will look like g++-mp-(version you installed)&lt;/p&gt;

&lt;p&gt;In the case of this guide it is g++-mp-13&lt;/p&gt;

&lt;p&gt;Now copy the file path. In the case of this guide : /opt/local/bin/g++-mp-13&lt;/p&gt;

&lt;p&gt;Go back to Sublime Text. And copy and paste the given code. Replace "/opt/local/bin/g++-mp-13" if you have a different file path.&lt;/p&gt;

&lt;p&gt;Now save with &lt;strong&gt;cmd + S&lt;/strong&gt;. Name the file to whatever you like (ex - C++14) but make sure the file extension is &lt;code&gt;.sublime-build.&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

{
    "shell_cmd": "/opt/local/bin/g++-mp-13 \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c++",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "/opt/local/bin/g++-mp-13 \"${file}\" -o \"${file_path}/${file_base_name}\" &amp;amp;&amp;amp; \"${file_path}/${file_base_name}\""
        }
    ]
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now go back to you C++ code and use &lt;strong&gt;cmd + shift + B&lt;/strong&gt; to build and run the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  bits/stdc++.h
&lt;/h2&gt;

&lt;p&gt;If you wish to use &lt;strong&gt;bits/stdc++.h&lt;/strong&gt; follow these steps.&lt;br&gt;
Go to finder and use &lt;strong&gt;cmd + G&lt;/strong&gt; and paste &lt;strong&gt;/Library/Developer/CommandLineTools/usr/include&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inside the folder create "bits" folder and inside that folder create a stdc++.h file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1p3p39mflu2are7ejkb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1p3p39mflu2are7ejkb.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inside the file paste&lt;a href="https://drive.google.com/drive/folders/1jwe6XPP4riWKvzUubH2QyhHqRr7_ywdD" rel="noopener noreferrer"&gt;these lines &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(Credits to &lt;a href="https://www.youtube.com/watch?v=Fql_b-xZYwQ" rel="noopener noreferrer"&gt;take U forward&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Now save the file. Now you can use &lt;strong&gt;bits/stdc++.h&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Thanks For Reading
&lt;/h1&gt;

&lt;p&gt;This is my first article. Please give feedback. I appreciate positive and negative feedback.&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>macos</category>
      <category>programming</category>
      <category>datastructures</category>
    </item>
  </channel>
</rss>
