<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SDL | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/category/sdl/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Mon, 26 May 2025 15:50:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>SDL | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Setting up SDL3 on Linux</title>
		<link>https://learncgames.com/setting-up-sdl3-on-linux/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setting-up-sdl3-on-linux</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 26 May 2025 15:02:41 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[SDL3 on Linux]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3420</guid>

					<description><![CDATA[<p>I knew it wasn&#8217;t going to be easy, but it turned out to be quite a bit more difficult than I thought. The problem is, unlike SDL2, there are no dev versions of SDL3 etc. yet, so you have to build it from scratch. I&#8217;ll be honest, I&#8217;m not sure I could have done it [&#8230;]</p>
The post <a href="https://learncgames.com/setting-up-sdl3-on-linux/">Setting up SDL3 on Linux</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:17,&quot;href&quot;:&quot;https:\/\/github.com\/Ravbug\/sdl3-sample&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260112022859\/https:\/\/github.com\/Ravbug\/sdl3-sample&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:35:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 18:04:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:36:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-15 23:18:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 00:34:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 04:11:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 10:07:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 10:09:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 12:37:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 17:22:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 18:51:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 20:26:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 21:57:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-19 06:22:42&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 08:22:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-25 10:53:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-28 10:54:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 11:05:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 11:05:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 11:57:00&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 12:21:08&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 12:50:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 13:16:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-18 19:14:35&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 20:49:12&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 20:49:12&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:18,&quot;href&quot;:&quot;https:\/\/github.com\/Ravbug\/sdl3-sample\/wiki\/Setting-up-your-computer&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250505154154\/https:\/\/github.com\/Ravbug\/sdl3-sample\/wiki\/Setting-up-your-computer&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:35:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 18:04:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:36:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-15 23:18:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 00:35:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-22 04:11:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-25 10:07:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 10:09:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 12:37:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 17:22:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-09 18:51:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-12 20:26:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-15 21:57:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-19 06:22:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 08:22:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-25 10:53:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-28 10:54:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-31 11:05:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 15:25:51&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 15:37:45&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 19:09:51&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 20:24:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 20:58:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-19 01:38:24&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 01:38:24&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img fetchpriority="high" decoding="async" class="alignleft size-full wp-image-3421" src="https://learncgames.com/wp-content/uploads/2025/05/sdl3-1.png" alt="SDL3 program running on Raspberry Pi." width="550" height="514" srcset="https://learncgames.com/wp-content/uploads/2025/05/sdl3-1.png 550w, https://learncgames.com/wp-content/uploads/2025/05/sdl3-1-300x280.png 300w" sizes="(max-width: 550px) 100vw, 550px" /></p>
<p>I knew it wasn&#8217;t going to be easy, but it turned out to be quite a bit more difficult than I thought.</p>
<p>The problem is, unlike SDL2, there are no dev versions of SDL3 etc. yet, so you have to build it from scratch.</p>
<p>I&#8217;ll be honest, I&#8217;m not sure I could have done it without this <a title="Link to Ravbug's Setting up SDL3 sample on GitHub" href="https://github.com/Ravbug/sdl3-sample" target="_blank" rel="noopener">GitHub repository</a>. User <em>Ravbug</em> who is very busy person (<em>752 contributions on GitHub in the last year- I tip my hat to him or her!</em>) who provided that repository.</p>
<p>It sets up SDL3, SDL_image, sdl_mixer and SDL_ttf.</p>
<p>Follow his link to the <a title="Ravbug's instructions" href="https://github.com/Ravbug/sdl3-sample/wiki/Setting-up-your-computer" target="_blank" rel="noopener">Wiki page</a> Scroll down to the bottom for the Linux instructions. I can confirm that it works on Raspberry Pi as well.  You&#8217;ll need to install cmake first with</p>
<pre>sudo apt install cmake</pre>
<p>Then run his cmake to build everything and go for a coffee.<br />
Now go into the build folder under sdl3-sample and do</p>
<pre>make</pre>
<p>That only takes a second or so.</p>
<p>After you&#8217;ve done that you&#8217;ll end up with a load of files including an executable sdl-min that you can run. That&#8217;s what generated the Tiger&#8217;s head &#8211; it plays The Sting film&#8217;s theme (The Entertainer) music as well demonstrating that it&#8217;s using SDL_mixer as well as SDL3 and SDL_ttf (<em>I&#8217;m guessing</em>) and of course SDL_image.</p>
<h3>But that is just the start</h3>
<p>To use SDL3 etc in your C program, you need a bit more configuration than with SDL2. I&#8217;m in uncharted waters here but used an AI- Claude 4 to help me get through and it did.</p>
<p>The problem is you have to tell VS Code where the header files are located, the .so files and also the executable needs to know at runtime.</p>
<p>I set up Ravbug&#8217;s sdl3_sample in my home folder so all paths start <strong>/home/david/sdl3-sample. </strong></p>
<p>This is my tasks.json</p>
<p>&nbsp;</p>
<pre><code class="language-json" data-line="">{
    &quot;version&quot;: &quot;2.0.0&quot;,
    &quot;tasks&quot;: [
        {
            &quot;type&quot;: &quot;shell&quot;,
            &quot;label&quot;: &quot;clang-14.0 build active file&quot;,
            &quot;command&quot;: &quot;/usr/bin/clang-14&quot;,
            &quot;args&quot;: [
                &quot;-I/home/david/sdl3-sample/SDL/include&quot;,
                &quot;-I/home/david/sdl3-sample/SDL_image/include&quot;, 
                &quot;-I/home/david/sdl3-sample/SDL_mixer/include&quot;,
                &quot;-I/home/david/sdl3-sample/SDL_ttf/include&quot;,
                &quot;-g&quot;,
                &quot;${file}&quot;,&quot;${workspaceFolder}/hr_time.c&quot;,
                &quot;-L/home/david/sdl3-sample/build&quot;,	
                &quot;-Wl,-rpath,/home/david/sdl3-sample/build&quot;,				
                &quot;-o&quot;,
                &quot;${fileDirname}/${fileBasenameNoExtension}&quot;,
                &quot;-lSDL3&quot;,
                &quot;-lSDL3_image&quot;, 
                &quot;-lSDL3_ttf&quot;   

            ],
            &quot;options&quot;: {
                &quot;cwd&quot;: &quot;/usr/bin&quot;
            },
            &quot;group&quot;: {
                &quot;kind&quot;: &quot;build&quot;,
                &quot;isDefault&quot;: true
            }
        }
    ]
}</code></pre>
<p>The lines that are SDL3 specific include the -I&#8217;s to provide the include path. -L the path to the .so files and the -rpath line is the path to the runtime files which gets linked into the executable.</p>
<p>If you add these three lines into c_cpp_properties.json then you&#8217;ll also avoid the dreaded red squiggles.</p>
<pre><code class="language-json" data-line="">            &quot;includePath&quot;: [
                &quot;${workspaceFolder}/**&quot;,
                &quot;/home/david/sdl3-sample/SDL/include&quot;,
                &quot;/home/david/sdl3-sample/SDL_image/include&quot;,
                &quot;/home/david/sdl3-sample/SDL_ttf/include&quot;
            ],</code></pre>
<pre><code class="language-json" data-line="">
</code></pre>
<p>And your C&#8217;s #includes need the files prefixed like this :</p>
<pre>#include &lt;SDL3/SDL.h&gt;
#include &lt;SDL3_image/SDL_image.h&gt;
#include &lt;SDL3_ttf/SDL_ttf.h&gt;</pre>
<p>And here it is running on my Pi.</p>
<p><img decoding="async" class="alignleft wp-image-3422 size-large" src="https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-1024x780.png" alt="Missile Command running on a Raspberry Pi 5 with SDL3" width="1024" height="780" srcset="https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-1024x780.png 1024w, https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-300x229.png 300w, https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi-768x585.png 768w, https://learncgames.com/wp-content/uploads/2025/05/missilecommand_pi.png 1108w" sizes="(max-width: 1024px) 100vw, 1024px" /></p>The post <a href="https://learncgames.com/setting-up-sdl3-on-linux/">Setting up SDL3 on Linux</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3420</post-id>	</item>
		<item>
		<title>Converting from SDL2 to SDL3 on Windows</title>
		<link>https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=converting-from-sdl2-to-sdl3-on-windows</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 24 May 2025 14:21:56 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Techniques]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[SDL2]]></category>
		<category><![CDATA[SDL3]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3414</guid>

					<description><![CDATA[<p>These notes were made when converting an existing C game that used SDL2 to SDL3 on Windows. The game was originally developed for Linux Format and I had got it running on Windows with SDL2. Windows include paths have been made consistent with Linux. The include files path for SDL3 need to be SDL3\&#8230; when [&#8230;]</p>
The post <a href="https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/">Converting from SDL2 to SDL3 on Windows</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" class="alignleft wp-image-3418" src="https://learncgames.com/wp-content/uploads/2025/05/SDL3-300x232.png" alt="Missile Command running with SDL3" width="600" height="463" srcset="https://learncgames.com/wp-content/uploads/2025/05/SDL3-300x232.png 300w, https://learncgames.com/wp-content/uploads/2025/05/SDL3-1024x790.png 1024w, https://learncgames.com/wp-content/uploads/2025/05/SDL3-768x593.png 768w, https://learncgames.com/wp-content/uploads/2025/05/SDL3.png 1026w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p>These notes were made when converting an existing C game that used SDL2 to SDL3 on Windows. The game was originally developed for Linux Format and I had got it running on Windows with SDL2.</p>
<p>Windows include paths have been made consistent with Linux. The include files path for SDL3 need to be SDL3\&#8230; when setting them up. For SDL2, I had them in a folder c:\SDL2\include but noted that in SDL2.h include files were like this:</p>
<pre>#include "SDL_main.h"
#include "SDL_stdinc.h"</pre>
<p>While in SDL3&#8217;s SDL.h they are</p>
<pre>#include &lt;SDL3/SDL_stdinc.h&gt;
#include &lt;SDL3/SDL_assert.h&gt;</pre>
<p>So I put them c:\SDL3\SDL3</p>
<p>When you include them in your software they are like this:</p>
<pre>#include &lt;SDL3/SDL.h&gt;
#include &lt;SDL3/SDL_image.h&gt;</pre>
<p>Which is how they are in Linux.</p>
<p>The rest of these notes are taken from the differences between the SDL2 and SDL3 versions of the game. They are not complete but intended to give you an idea of some of the changes you may need to do.</p>
<h3>SDL_TTF</h3>
<p>TTF_RenderUTF8_Blended( is now TTF_RenderText_Blended with an extra text length parameter.</p>
<h3>SDL_Rects are mostly replaced by SDL_FRect</h3>
<p>This is a big change. Everywhere I was passing in an SDL_Rect became an SDL_Frect which is four floats rather than four ints.</p>
<p>SDL_RenderCopy is now SDL_RenderTexture and the last two params are now SDL_FRects.</p>
<p>To fix this I used a load of (float) casts.</p>
<p><strong>SDL_RenderDrawLine</strong> becomes <strong>SDL_RenderLine</strong> and has an SDL_FRect parameter instaed of SDL_Rect.</p>
<p>Same for <strong>SDL_RenderDrawPoint</strong> which becomes <strong>SDL_RenderPoint</strong>.</p>
<p><strong>SDL_GetMouseState</strong> keeps the same name but returns float * for both parameters now.</p>
<h3>Setup changes slightly</h3>
<p>There&#8217;s no <strong>SDL_SetMainReady()</strong> and SDL2main.lib is gone.</p>
<p>Also gone is <strong>SDL_INIT_EVERYTHING</strong> in <strong>SDL_Init()</strong>&#8211; you have to or the specific subunits. E.g. SDL_INIT_VIDEO | SDL_INIT_EVENTS</p>
<p>Also there&#8217;s no <strong>SDL_RENDERER_PRESENTVSYNC </strong>for SDL_CreateRenderer. Vsync is disabled by default as I found when my game ran about 30x faster and finished in a few seconds! Instead you need to call SDL_SetRenderVSync(renderer, 1) where 1 is syncing with each retrace, or 2 with every 2nd retrace.</p>
<p>Several of the events have been renamed, so SDL_KEYDOWN becomes SDL_EVENT_KEY_DOWN, SDL_MOUSEBUTTONDOWN becomes  SDL_EVENT_MOUSE_BUTTON_DOWN and similar for other events.  Also event.key.keysym.sym becomes event.key.key.</p>
<p>Finally SDL_FreeSurface( becomes SDL_DestroySurface.</p>
<p>I&#8217;m sure there are more but changing these was sufficent to get my game compiling and running correctly with SDL3.</p>The post <a href="https://learncgames.com/converting-from-sdl2-to-sdl3-on-windows/">Converting from SDL2 to SDL3 on Windows</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3414</post-id>	</item>
		<item>
		<title>Rust on Windows &#8211; problem with sdl2.lib</title>
		<link>https://learncgames.com/rust-on-windows-problem-with-sdl2-lib/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rust-on-windows-problem-with-sdl2-lib</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 06 Apr 2025 12:59:46 +0000</pubDate>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[Rust]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[compile error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[SDL2]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3364</guid>

					<description><![CDATA[<p>I&#8217;m currently unable to compile Rust programs that use SDL2 on Windows. No problems on Ubuntu or Raspberry Pi OS, just Windows 11. Although it says cannot open input file SDL2.lib, I think the problem is a parameter passed into Link.exe. The text from the image above is listed below- I&#8217;ve broken it to make [&#8230;]</p>
The post <a href="https://learncgames.com/rust-on-windows-problem-with-sdl2-lib/">Rust on Windows – problem with sdl2.lib</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>I&#8217;m currently unable to compile Rust programs that use SDL2 on Windows. No problems on Ubuntu or Raspberry Pi OS, just Windows 11.<br />
<img loading="lazy" decoding="async" class="alignleft size-large wp-image-3365" src="https://learncgames.com/wp-content/uploads/2025/04/compiling_sdl2_on_windows-1024x174.png" alt="Compiling an SDL2 app (in Rust) on Windows" width="1024" height="174" srcset="https://learncgames.com/wp-content/uploads/2025/04/compiling_sdl2_on_windows-1024x174.png 1024w, https://learncgames.com/wp-content/uploads/2025/04/compiling_sdl2_on_windows-300x51.png 300w, https://learncgames.com/wp-content/uploads/2025/04/compiling_sdl2_on_windows-768x130.png 768w, https://learncgames.com/wp-content/uploads/2025/04/compiling_sdl2_on_windows.png 1213w" sizes="auto, (max-width: 1024px) 100vw, 1024px" />Although it says cannot open input file SDL2.lib, I think the problem is a parameter passed into Link.exe.</p>
<p>The text from the image above is listed below- I&#8217;ve broken it to make it readable as it&#8217;s displayed preformatted and unmodified it is all on a single very wide line!</p>
<pre> = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.43.34808\\bin\\HostX64\\x64\\link.exe" 
"/NOLOGO" "C:\\Users\\dhbol\\AppData\\Local\\Temp\\rustcA1PhoK\\symbols.o" "&lt;70 object files omitted&gt;" 
"D:\\development\\rustapps\\choice\\target\\debug\\deps/{libsdl2-f8d94d30d19bed49.rlib,libsdl2_sys-325e30d8e9547ff4.rlib,
libbitflags-d15393d08e2f31fc.rlib,liblazy_static-c28c0e13093a4168.rlib,liblibc-851e0bf801239f69.rlib}.rlib" 
"&lt;sysroot&gt;\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libstd-*,libpanic_unwind-*,libwindows_targets-*,
librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libunwind-*,libcfg_if-*,liballoc-*,
librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "SDL2.lib" "SDL2_image.lib" "SDL2_ttf.lib" 
"legacy_stdio_definitions.lib" "kernel32.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" 
"dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/OUT:D:\\development\\rustapps\\choice\\target\\debug\\deps\\choice.exe" 
"/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:&lt;sysroot&gt;\\lib\\rustlib\\etc\\intrinsic.natvis" 
"/NATVIS:&lt;sysroot&gt;\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:&lt;sysroot&gt;\\lib\\rustlib\\etc\\libcore.natvis" 
"/NATVIS:&lt;sysroot&gt;\\lib\\rustlib\\etc\\libstd.natvis"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: LINK : fatal error LNK1181: cannot open input file 'SDL2.lib'␍</pre>
<p>But if you try running part of it like the first line<br />
&#8220;C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.43.34808\\bin\\HostX64\\x64\\link.exe&#8221;<br />
&#8220;/NOLOGO&#8221; &#8220;C:\\Users\\dhbol\\AppData\\Local\\Temp\\rustcA1PhoK\\symbols.o&#8221;</p>
<p>Well the path to link..exe is correct, but there&#8217;s no  rustcA1PhoK\symbols.o in that temp folder. Any suggestions welcomed&#8230;</p>
<h2>I just solved it.</h2>
<p>I&#8217;ve left this in, in case anyone else has this problem.</p>
<p>You need to add an environment variable LIB with the address of the SDL .lib files including ttf, image and mixer. Make sure they&#8217;re all in this folder:</p>
<p>C:\Users\<strong>dhbol</strong>\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib</p>
<p>The bold part of the path will be different on you PC.</p>
<p>In File Explorer, right-click on <strong>This PC </strong>then click Properties on the popup menu.</p>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-3372" src="https://learncgames.com/wp-content/uploads/2025/04/this_pc.png" alt="File Explorer - This PC,." width="170" height="70" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>It&#8217;ll open Settings &#8211; About, and you need to click <strong>Advanced system settings</strong>.</p>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-3374" src="https://learncgames.com/wp-content/uploads/2025/04/settings_about-300x154.png" alt="settings_about" width="300" height="154" srcset="https://learncgames.com/wp-content/uploads/2025/04/settings_about-300x154.png 300w, https://learncgames.com/wp-content/uploads/2025/04/settings_about.png 600w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<p>This opens System Properties and on that you click <strong>Environment variables</strong>.</p>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-3375" src="https://learncgames.com/wp-content/uploads/2025/04/System_properties-264x300.png" alt="System properties on Windows" width="264" height="300" srcset="https://learncgames.com/wp-content/uploads/2025/04/System_properties-264x300.png 264w, https://learncgames.com/wp-content/uploads/2025/04/System_properties.png 412w" sizes="auto, (max-width: 264px) 100vw, 264px" /></p>
<p><img loading="lazy" decoding="async" class="alignleft wp-image-3376 size-full" src="https://learncgames.com/wp-content/uploads/2025/04/environment_variables.png" alt="Environment variables popup on Windows" width="646" height="585" srcset="https://learncgames.com/wp-content/uploads/2025/04/environment_variables.png 646w, https://learncgames.com/wp-content/uploads/2025/04/environment_variables-300x272.png 300w" sizes="auto, (max-width: 646px) 100vw, 646px" /></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Now just click New and add Lib and that path It should look something like mine. Now reopen Visual Studio and your SDL2 Rust app should now build and run.</p>The post <a href="https://learncgames.com/rust-on-windows-problem-with-sdl2-lib/">Rust on Windows – problem with sdl2.lib</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3364</post-id>	</item>
		<item>
		<title>Interesting bug with controllermap</title>
		<link>https://learncgames.com/interesting-bug-with-controllermap/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=interesting-bug-with-controllermap</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 23 Mar 2025 14:35:44 +0000</pubDate>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[raspberry-pi]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[utility]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3356</guid>

					<description><![CDATA[<p>So I&#8217;ve been playing with a Rust program that uses the config string generated by controllermap. It shows all the keys and the text of a particular button turns green when you press it and it shows PRESSED/RELEASED. But it got A and B buttons mixed up and also X and Y. I&#8217;d press A, [&#8230;]</p>
The post <a href="https://learncgames.com/interesting-bug-with-controllermap/">Interesting bug with controllermap</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignleft wp-image-3357" src="https://learncgames.com/wp-content/uploads/2025/03/test.png" alt="Running a Rust program to show gamepad controls" width="500" height="390" srcset="https://learncgames.com/wp-content/uploads/2025/03/test.png 801w, https://learncgames.com/wp-content/uploads/2025/03/test-300x234.png 300w, https://learncgames.com/wp-content/uploads/2025/03/test-768x598.png 768w" sizes="auto, (max-width: 500px) 100vw, 500px" /></p>
<p>So I&#8217;ve been playing with a Rust program that uses the config string generated by <a title="Link to blog post about controllermap" href="https://learncgames.com/new-tutorial-posted-how-to-build-controllermap-in-linux/" target="_blank" rel="noopener">controllermap</a>. It shows all the keys and the text of a particular button turns green when you press it and it shows PRESSED/RELEASED.</p>
<p>But it got A and B buttons mixed up and also X and Y. I&#8217;d press A, it highlighted B etc.</p>
<p>I checked my code, it wasn&#8217;t there. I ran controllermap again and it generated a similar config string.</p>
<p>I then went back to the Pi version of Asteroids, put it on a Pi, started debugging it, pressed the fire button and it hit the line of code for the A button. D&#8217;oh.</p>
<p>The only conclusion I can come up with is that controllermap gets it wrong for my gamepad. I had somehow missed it when I added gamepad control for the Asteroid Pi.</p>
<p>It&#8217;s quite easy to fix.  This is what the full text in gamepad.txt look like.</p>
<pre>030000001008000001e5000010010000,usb gamepad,platform:Linux,crc:417e,<strong>a:b2,b:b1,x:b3,y:b0</strong>,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,</pre>
<p>but we&#8217;re only interesed in the button mappings for a,b, x and y which are in bold.</p>
<p>a:b2,b:b1,x:b3,y:b0,</p>
<p>Just swap the a b mappings and the x and y so it looks like</p>
<pre>a:b1,b:b2,x:b0,y,b3</pre>
<p>Then save the file and it now works correctly.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/interesting-bug-with-controllermap/">Interesting bug with controllermap</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3356</post-id>	</item>
		<item>
		<title>So I found the fix</title>
		<link>https://learncgames.com/so-i-found-the-fix/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=so-i-found-the-fix</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 23 Feb 2025 20:03:51 +0000</pubDate>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[Rust]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3312</guid>

					<description><![CDATA[<p>Well actually I asked Microsoft&#8217;s CoPilot AI and it sorted it! This is what you need in the dependencies section in cargo.toml [dependencies] sdl2-sys = &#34;*&#34; sdl2 = { version = &#34;0.37&#34;, features = [&#34;image&#34;,&#34;ttf&#34;] } It compiled with no problems after saving that.</p>
The post <a href="https://learncgames.com/so-i-found-the-fix/">So I found the fix</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-3314" src="https://learncgames.com/wp-content/uploads/2025/02/its-fixed.png" alt="It's fixed text on a technology background" width="752" height="436" srcset="https://learncgames.com/wp-content/uploads/2025/02/its-fixed.png 752w, https://learncgames.com/wp-content/uploads/2025/02/its-fixed-300x174.png 300w" sizes="auto, (max-width: 752px) 100vw, 752px" />Well actually I asked Microsoft&#8217;s CoPilot AI and it sorted it!</p>
<p>This is what you need in the dependencies section in cargo.toml</p>
<pre><code class="language-yaml" data-line="">[dependencies]
sdl2-sys = &quot;*&quot;
sdl2 = { version = &quot;0.37&quot;, features = [&quot;image&quot;,&quot;ttf&quot;] }</code></pre>
<p>It compiled with no problems after saving that.</p>The post <a href="https://learncgames.com/so-i-found-the-fix/">So I found the fix</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3312</post-id>	</item>
		<item>
		<title>A slight problem with SDL2 and Rust</title>
		<link>https://learncgames.com/a-slight-problem-with-sdl2-and-rust/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-slight-problem-with-sdl2-and-rust</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sat, 22 Feb 2025 00:05:18 +0000</pubDate>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[Rust]]></category>
		<category><![CDATA[SDL]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3308</guid>

					<description><![CDATA[<p>This is on Ubuntu 24.04 LTS. I&#8217;ve installed the dev versions of SDL2, including images and TTF.  You can read how to install them in this tutorial. Once that&#8217;s done you add them to the rust project with commands like this cargo add sdl2 You can see these instruction in the relevant crates pages. For [&#8230;]</p>
The post <a href="https://learncgames.com/a-slight-problem-with-sdl2-and-rust/">A slight problem with SDL2 and Rust</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:22,&quot;href&quot;:&quot;https:\/\/crates.io\/crates\/sdl2&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251226013606\/https:\/\/crates.io\/crates\/sdl2&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:46:48&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-09 20:08:03&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-12 22:35:49&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-18 23:31:02&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-22 05:49:46&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-26 17:30:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-03 01:04:19&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-09 09:34:25&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-12 21:08:00&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-16 05:48:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-19 09:46:55&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-22 20:58:11&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-30 12:24:14&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-03 05:13:08&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-08 07:07:54&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 23:19:51&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-16 05:22:10&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-19 08:52:04&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 08:52:04&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:23,&quot;href&quot;:&quot;https:\/\/crates.io\/crates\/sdl2_image&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20241114201358\/https:\/\/crates.io\/crates\/sdl2_image&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:46:50&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-09 20:08:02&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-12 22:35:49&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-18 23:31:02&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-22 05:49:46&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-26 17:30:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-03 01:04:19&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-09 09:34:25&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-12 21:07:59&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-16 05:48:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-19 09:46:55&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-22 20:58:12&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-30 12:24:12&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-03 05:13:09&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-08 07:07:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-13 06:32:44&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-17 05:36:48&quot;,&quot;http_code&quot;:503}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-17 05:36:48&quot;,&quot;http_code&quot;:503},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:24,&quot;href&quot;:&quot;https:\/\/crates.io\/crates\/sdl2_ttf&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20241114201545\/https:\/\/crates.io\/crates\/sdl2_ttf&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 10:46:51&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-09 20:08:02&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-12 22:35:49&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-18 23:31:02&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-22 05:49:46&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-02-26 17:30:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-03 01:04:20&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-09 09:34:25&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-12 21:08:00&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-16 05:48:52&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-19 09:46:55&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-22 20:58:11&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-30 12:24:12&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-03 05:13:09&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-08 07:07:57&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 23:19:42&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-16 05:22:11&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-19 08:52:04&quot;,&quot;http_code&quot;:404}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 08:52:04&quot;,&quot;http_code&quot;:404},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-3309" src="https://learncgames.com/wp-content/uploads/2025/02/error.png" alt="VS Code Rust SDL Copikle problem" width="996" height="396" srcset="https://learncgames.com/wp-content/uploads/2025/02/error.png 996w, https://learncgames.com/wp-content/uploads/2025/02/error-300x119.png 300w, https://learncgames.com/wp-content/uploads/2025/02/error-768x305.png 768w" sizes="auto, (max-width: 996px) 100vw, 996px" />This is on Ubuntu 24.04 LTS. I&#8217;ve installed the dev versions of SDL2, including images and TTF.  You can read how to install them in <a title="Link to How to install SDL on Linux" href="https://learncgames.com/tutorials/how-to-install-sdl-on-linux/" target="_blank" rel="noopener">this tutoria</a>l.</p>
<p>Once that&#8217;s done you add them to the rust project with commands like this</p>
<pre>cargo add sdl2</pre>
<p>You can see these instruction in the relevant crates pages. For instance <a title="Link to SDL2 Crate" href="https://crates.io/crates/sdl2" target="_blank" rel="noopener">SDL2 crate</a>, <a title="Linbk to SDL2 Image Crate" href="https://crates.io/crates/sdl2_image" target="_blank" rel="noopener">SDL2 Image</a> and <a title="Link to SDL2 TTF crate" href="https://crates.io/crates/sdl2_ttf" target="_blank" rel="noopener">SDL2 TTF</a>.</p>
<p>So far so good. The cargo add added the crates into cargo.toml as expected but when I compiled it. Not a compile error as such but a version of dll hell.</p>
<p>The text in that image says:</p>
<pre><em>Updating crates.io index</em>
<em>error: failed to select a version for `sdl2-sys`.</em>
<em>... required by package `sdl2_image v0.25.0`</em>
<em>... which satisfies dependency `sdl2_image = "^0.25.0"` of package `sdl1 v0.1.0 (/home/david/rust/sdl1)`</em>
<em>versions that meet the requirements `^0.25.0` are: 0.25.0</em>

<em>the package `sdl2-sys` links to the native library `SDL2`, but it conflicts with a previous package which links to `SDL2` as well:</em>
<em>package `sdl2-sys v0.37.0`</em>
<em>... which satisfies dependency `sdl2-sys = "^0.37.0"` of package `sdl1 v0.1.0 (/home/david/rust/sdl1)`</em>
<em>Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the `links = "SDL2"` value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.</em>

<em>failed to select a version for `sdl2-sys` which could resolve this conflict</em></pre>
<p>The problem appears to be a clash between sdl-sys and sdl2-ttf or sdl2-image. If anyone knows a fix&#8230;</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/a-slight-problem-with-sdl2-and-rust/">A slight problem with SDL2 and Rust</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3308</post-id>	</item>
		<item>
		<title>Compiling C with Visual C++ 2022</title>
		<link>https://learncgames.com/compiling-c-with-visual-c-2022/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=compiling-c-with-visual-c-2022</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Tue, 28 Mar 2023 23:00:22 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[settings]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3237</guid>

					<description><![CDATA[<p>It&#8217;s been a few years since I compiled the code for the first eBook and I needed to create an SDL application on Windows. I copied a project, as it was the fastest way to setup the include and lib paths, and the lib files needed to compile. Compared to clang/gcc on Linux, setting up [&#8230;]</p>
The post <a href="https://learncgames.com/compiling-c-with-visual-c-2022/">Compiling C with Visual C++ 2022</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-3239" src="https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-300x200.jpg" alt="monitor displaying programming language" width="300" height="200" srcset="https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-300x200.jpg 300w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-1024x683.jpg 1024w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-768x512.jpg 768w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q-1536x1024.jpg 1536w, https://learncgames.com/wp-content/uploads/2023/03/u2ru4qbxa5q.jpg 1600w" sizes="auto, (max-width: 300px) 100vw, 300px" />It&#8217;s been a few years since I compiled the code for the first eBook and I needed to create an SDL application on Windows. I copied a project, as it was the fastest way to setup the <em>include</em> and <em>lib</em> paths, and the lib files needed to compile.</p>
<p>Compared to clang/gcc on Linux, setting up visual studio projects on Windows can be a bit of a pita. You&#8217;ve got to be careful not to mix up the x64 and x86 files, add everything twice (once for Win 32 and once for x64).</p>
<p>So I copied .sln and .vcxproj files, started compiling and kept getting this error:</p>
<p><em>Error LNK2019 unresolved external symbol main referenced in function &#8220;int __cdecl invoke_main(void)&#8221; (?invoke_main@@YAHXZ) maze D:\development\LinuxFormat\maze\MSVCRTD.lib(exe_main.obj) </em></p>
<p>I messed around with settings, still no joy. did a bit of searching around and found that some people fixed it by setting the Link System Subsystem but that didn&#8217;t fix it. Also one person had forgotten to add SDL2_main.lib to the list of lib files to be linked in.</p>
<p>Then I noticed the project was defaulting to 64-bit. I checked my includes and it was only setup for 32-bit. D&#8217;oh. So copying the settings from 32-bit to 64-bit fixed it.</p>The post <a href="https://learncgames.com/compiling-c-with-visual-c-2022/">Compiling C with Visual C++ 2022</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3237</post-id>	</item>
		<item>
		<title>Update to the Windows eBook</title>
		<link>https://learncgames.com/update-to-the-windows-ebook/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=update-to-the-windows-ebook</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 27 Nov 2022 11:28:17 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Ebook]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[asteroids]]></category>
		<category><![CDATA[Sounds]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=3101</guid>

					<description><![CDATA[<p>A reader asked me how to setup SDL2 for Windows given recent changes in SDL2. Specifically the files and libsdl projects have been moved from the libsdl.org website to GitHub. You can easily find SDL2 Image, Mixer, TTF etc. However it can still be quite daunting setting up Visual Studio for SDL2. You have to [&#8230;]</p>
The post <a href="https://learncgames.com/update-to-the-windows-ebook/">Update to the Windows eBook</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:45,&quot;href&quot;:&quot;https:\/\/github.com\/David-H-Bolton\/LearnC\/blob\/master\/New%20Instructions%20for%20setting%20up%20SDL2%20files%20on%20Windows.pdf&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20221223025630\/https:\/\/github.com\/David-H-Bolton\/LearnC\/blob\/master\/New%20Instructions%20for%20setting%20up%20SDL2%20files%20on%20Windows.pdf&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:15:41&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-02-06 11:15:41&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:46,&quot;href&quot;:&quot;https:\/\/github.com\/libsdl-org\/SDL_mixer&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251216065846\/https:\/\/github.com\/libsdl-org\/SDL_mixer&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 11:15:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 20:59:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:35:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-16 07:53:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 23:41:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-23 15:31:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 07:19:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-02 23:11:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 15:02:44&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-10 06:52:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-13 14:42:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-16 22:33:28&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-20 06:21:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-23 14:10:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 22:00:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-30 13:45:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 21:39:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 05:31:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-09 13:24:27&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-04-12 21:15:53&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-16 05:07:08&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-19 20:57:01&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-19 20:57:01&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-3102" src="https://learncgames.com/wp-content/uploads/2022/11/configure-sdl-for-vc-300x116.png" alt="Visual Studio configuration" width="300" height="116" srcset="https://learncgames.com/wp-content/uploads/2022/11/configure-sdl-for-vc-300x116.png 300w, https://learncgames.com/wp-content/uploads/2022/11/configure-sdl-for-vc-768x296.png 768w, https://learncgames.com/wp-content/uploads/2022/11/configure-sdl-for-vc.png 904w" sizes="auto, (max-width: 300px) 100vw, 300px" />A reader asked me how to setup SDL2 for Windows given recent changes in SDL2. Specifically the files and libsdl projects have been moved from the libsdl.org website to GitHub. You can easily find SDL2 Image, Mixer, TTF etc.</p>
<p>However it can still be quite daunting setting up Visual Studio for SDL2. You have to download the specific files, then configure the project properties to specify the include paths for header files and then the lib files, both the path to them and identify the ones you want to use.</p>
<p>As I&#8217;m on my new PC, I bit the bullet and went through the process of setting it up. It took just over an hour to configure it.  I&#8217;ve put it into <a title="Link to Setting up Visual Studio for SDL" href="https://github.com/David-H-Bolton/LearnC/blob/master/New%20Instructions%20for%20setting%20up%20SDL2%20files%20on%20Windows.pdf" target="_blank" rel="nofollow noopener">a PDF</a> that&#8217;s a couple of pages long.</p>
<p>So the game works but only after I disabled the sound code; it was failing in the call to <strong>Mix_OpenAudio()</strong>. I think recent work on the SDL Mixer needs some work on my part. I need to sit down and look at the <a title="Link to SDL Mixer page on GitHub" href="https://github.com/libsdl-org/SDL_mixer" target="_blank" rel="nofollow noopener">SDL Mixer page</a> and figure out what&#8217;s failing. Once that&#8217;s done, I&#8217;ll update the files.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/update-to-the-windows-ebook/">Update to the Windows eBook</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3101</post-id>	</item>
		<item>
		<title>New Tutorial on getting started with SDL</title>
		<link>https://learncgames.com/new-tutorial-on-getting-started-with-sdl/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=new-tutorial-on-getting-started-with-sdl</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Sun, 07 Mar 2021 00:00:31 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[tutorials]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2838</guid>

					<description><![CDATA[<p>I had this tutorial pencilled in to do and it&#8217;s now done. It&#8217;s the old SDL rectangles program that was part of the eBook. I&#8217;ve modernised it a bit so the same file will now compile under either MSVC on Windows or VS Code/Clang on Linux without changes. I used the _WIN32 predefined macro so [&#8230;]</p>
The post <a href="https://learncgames.com/new-tutorial-on-getting-started-with-sdl/">New Tutorial on getting started with SDL</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-2836" src="https://learncgames.com/wp-content/uploads/2021/03/SDL-Rectangles-300x234.png" alt="SDL REctangles" width="300" height="234" srcset="https://learncgames.com/wp-content/uploads/2021/03/SDL-Rectangles-300x234.png 300w, https://learncgames.com/wp-content/uploads/2021/03/SDL-Rectangles-1024x798.png 1024w, https://learncgames.com/wp-content/uploads/2021/03/SDL-Rectangles-768x599.png 768w, https://learncgames.com/wp-content/uploads/2021/03/SDL-Rectangles.png 1026w" sizes="auto, (max-width: 300px) 100vw, 300px" />I had this tutorial pencilled in to do and it&#8217;s <a title="Link to Getting started with SDL tutorial" href="https://learncgames.com/getting-started-with-sdl-and-c/" target="_blank" rel="nofollow noopener">now done</a>. It&#8217;s the old SDL rectangles program that was part of the eBook. I&#8217;ve modernised it a bit so the same file will now compile under either MSVC on Windows or VS Code/Clang on Linux without changes.</p>
<p>I used the _WIN32 predefined macro so it compiles the call to Windows cod on Windows. Here&#8217;s an example:</p>
<pre><code class="language-c" data-line="">#ifdef _WIN32
		sprintf_s(buff, sizeof(buff), &quot;%10.6f&quot;, getElapsedTime(&amp;s));
#else
		snprintf(buff, sizeof(buff),&quot;%10.6f&quot;,diff(&amp;s));
#endif</code></pre>
<p>I do a similar thing with the path to SDL which is &#8220;SDL.h&#8221; on Windows but &#8220;SDL2/SDL.h&#8221; on Ubuntu. Writing code this way makes it  lot less of a hassle.</p>The post <a href="https://learncgames.com/new-tutorial-on-getting-started-with-sdl/">New Tutorial on getting started with SDL</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2838</post-id>	</item>
		<item>
		<title>The game of 2048 in C in your browser</title>
		<link>https://learncgames.com/the-game-of-2048-in-c-in-your-browser/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-game-of-2048-in-c-in-your-browser</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Fri, 05 Mar 2021 00:00:12 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[WebAssembly]]></category>
		<category><![CDATA[2048]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=2819</guid>

					<description><![CDATA[<p>Back in 2014, an Italian developer called Gabriele Cirulli devised a puzzle game called 2048. It has been implemented on many platforms (I have it on my iPhone) and here is a link to a C version of it (in 300 lines) by developer Nishchith Shetty that plays it in a browser using WebAssembly. The [&#8230;]</p>
The post <a href="https://learncgames.com/the-game-of-2048-in-c-in-your-browser/">The game of 2048 in C in your browser</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:122,&quot;href&quot;:&quot;https:\/\/github.com\/inishchith\/2048.wasm&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20251209091006\/https:\/\/github.com\/inishchith\/2048.wasm&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:09:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 20:59:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:35:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 14:25:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-23 14:39:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 10:58:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-03 08:00:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-07 08:12:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 21:28:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 05:18:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 02:51:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 09:00:02&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 04:02:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 12:15:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-10 13:53:21&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 08:01:56&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 15:53:12&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 15:53:12&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:123,&quot;href&quot;:&quot;https:\/\/en.wikipedia.org\/wiki\/WebAssembly&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260204131036\/https:\/\/en.wikipedia.org\/wiki\/WebAssembly&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:09:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-09 20:59:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-12 22:35:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-19 14:25:39&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-24 15:15:59&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-28 10:02:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-07 08:12:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-11 21:28:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 05:18:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-22 02:51:25&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 09:00:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-03 04:02:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-06 12:15:20&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-10 13:53:20&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-15 08:01:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-21 15:53:11&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 15:53:11&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:124,&quot;href&quot;:&quot;https:\/\/emscripten.org&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260206121429\/https:\/\/emscripten.org\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-09 20:59:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-14 09:49:11&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 14:25:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 15:16:03&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-02-28 10:02:33&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-07 08:12:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 21:28:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 05:18:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 02:51:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 03:55:19&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-03 04:02:57&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-06 12:15:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-10 13:53:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 08:02:00&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-04-21 15:53:22&quot;,&quot;http_code&quot;:503}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 15:53:22&quot;,&quot;http_code&quot;:503},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:125,&quot;href&quot;:&quot;https:\/\/2048.nishchith.com&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250718042908\/https:\/\/2048.nishchith.com\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 12:10:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-09 20:59:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-12 22:35:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-19 14:25:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-24 15:15:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-28 10:02:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-07 08:12:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 21:28:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-17 05:18:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-22 02:51:25&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 09:00:02&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-03 04:02:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 12:15:19&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-10 13:53:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-15 08:01:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-21 15:53:12&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-21 15:53:12&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<p><img loading="lazy" decoding="async" class="alignleft size-medium wp-image-2820" src="https://learncgames.com/wp-content/uploads/2021/03/2048-230x300.png" alt="2048 game playing in a browser" width="230" height="300" srcset="https://learncgames.com/wp-content/uploads/2021/03/2048-230x300.png 230w, https://learncgames.com/wp-content/uploads/2021/03/2048.png 497w" sizes="auto, (max-width: 230px) 100vw, 230px" />Back in 2014, an Italian developer called Gabriele Cirulli devised a puzzle game called 2048. It has been implemented on many platforms (<em>I have it on my iPhone</em>) and here is <a title="Link to Wasm version of 2048 on GitHub" href="https://github.com/inishchith/2048.wasm" target="_blank" rel="nofollow noopener">a link to a C version</a> of it (<em>in 300 lines</em>) by developer Nishchith Shetty that plays it in a browser using WebAssembly.</p>
<p>The idea behind the puzzle is that you combine the numbered pieces by moving pieces intro same numbered pieces. 2 into 3, 4 into 4 and so on.</p>
<p><a title="Link to WebAssembly on Wikipedia" href="https://en.wikipedia.org/wiki/WebAssembly" target="_blank" rel="nofollow noopener">WebAssembly</a> is the technology that lets you run programs in many languages (<em>including C and C++</em>) in your browser at speeds up to 50% of native code.  It&#8217;s also used in Blazor where you can write C# programs that run in the browser.</p>
<p>To convert the C code to WebAssembly, you have to install a transpiler (<em>a program that converts one programming language to another</em>) called <a title="Link to Emscripten.org" href="https://emscripten.org/" target="_blank" rel="nofollow noopener">Emscripten</a>, then it&#8217;s a single command line instruction to build the WebAssembly from the C sources and SDL2. Or you can just play it online <a title="Link to 2048 running on nishchith.com" href="https://2048.nishchith.com/" target="_blank" rel="nofollow noopener">here</a>.</p>
<p>I&#8217;ve been meaning to do a WebAssembly version of my asteroids game using Emscripten. it&#8217;s just been sheer laziness that I haven&#8217;t got round to it.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/the-game-of-2048-in-c-in-your-browser/">The game of 2048 in C in your browser</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2819</post-id>	</item>
	</channel>
</rss>
