<?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>DEV Community: Pradyumna Sahu</title>
    <description>The latest articles on DEV Community by Pradyumna Sahu (@hacker_thronx).</description>
    <link>https://dev.to/hacker_thronx</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%2F1217444%2F51f8bd34-1288-4ad9-9635-883f48090a3a.jpg</url>
      <title>DEV Community: Pradyumna Sahu</title>
      <link>https://dev.to/hacker_thronx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hacker_thronx"/>
    <language>en</language>
    <item>
      <title>SDL2 on macOS Sonoma installation with VSCode.</title>
      <dc:creator>Pradyumna Sahu</dc:creator>
      <pubDate>Fri, 24 Nov 2023 17:18:07 +0000</pubDate>
      <link>https://dev.to/hacker_thronx/sdl2-on-macos-sonoma-installation-with-vscode-29pe</link>
      <guid>https://dev.to/hacker_thronx/sdl2-on-macos-sonoma-installation-with-vscode-29pe</guid>
      <description>&lt;p&gt;How to install SDL2 on macOS sonoma with visual studio code is here. No Xcode installation is required. only a programing IDE is required. Here we gonna use Visual Studio code community version from Microsoft. It is a popular IDE choice among developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install Homebrew.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Homebrew is a great package manager for unix operating systems. It is reliable. (don't worry, it's safe until used properly.) &lt;a href="https://brew.sh"&gt;click here&lt;/a&gt; to go directly to home-brew's official download site. or simply open terminal and copy-paste this command - &lt;code&gt;/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"&lt;/code&gt;.&lt;br&gt;
now follow the on-screen commands for a successful installation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install SDL2&lt;/strong&gt;&lt;br&gt;
It's the time for our package. type &lt;code&gt;cls&lt;/code&gt; int terminal and hit return. Now type &lt;code&gt;brew install sdl2&lt;/code&gt; and relax after hitting return. After successful installation, type &lt;code&gt;cls&lt;/code&gt; again. Now type &lt;code&gt;sdl2-config --version&lt;/code&gt; and check what version it's showing for the latest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time to code&lt;/strong&gt;&lt;br&gt;
make a new folder and a new file named &lt;code&gt;main.cpp&lt;/code&gt;. g++ compiler will be used to compile the code now.&lt;/p&gt;

&lt;p&gt;lets open a blank window now. copy paste the code in that main.cpp file from following code -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;SDL2/SDL.h&amp;gt;

const int WIDTH = 1000, HEIGHT = 800;

int main( int argc, char *argv[] )
{
    SDL_Init( SDL_INIT_EVERYTHING );

    SDL_Window *window = SDL_CreateWindow( "this is my", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI );

    if ( NULL == window ){
        std::cout &amp;lt;&amp;lt; "Could not create window: " &amp;lt;&amp;lt; SDL_GetError( ) &amp;lt;&amp;lt; std::endl;
        return 1;
    }
    SDL_Event windowEvent;
    bool running = true;
    while (running)
    {
        if ( SDL_PollEvent( &amp;amp;windowEvent ) )
        {
            if ( SDL_QUIT == windowEvent.type ){
               running = false;
               break; 
            }
        }
    }

    SDL_DestroyWindow( window );
    SDL_Quit( );

    return EXIT_SUCCESS;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Compile and let the magic happen&lt;/strong&gt;&lt;br&gt;
open up terminal and type the following code - &lt;code&gt;sdl2-config&lt;/code&gt; —a program that prints out the right flags. This should happen as part of the build process. the command prints an argument for linking the sdl2 library. copy that line.&lt;/p&gt;

&lt;p&gt;now type this command for compilation - &lt;br&gt;
&lt;code&gt;g++ main.cpp -o main {paste the copied argument here}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;for my case it was like this. - &lt;br&gt;
&lt;code&gt;g++  main.cpp -o main -L/usr/local/lib -lSDL2&lt;/code&gt;&lt;br&gt;
this should make the work done.👽&lt;/p&gt;

&lt;p&gt;now type ./main and see the blackness of black window🪟.&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>programming</category>
      <category>sdl2</category>
      <category>vscode</category>
    </item>
  </channel>
</rss>
