Skip to content

Commit

Permalink
new post added
Browse files Browse the repository at this point in the history
  • Loading branch information
downIoads committed Oct 26, 2023
1 parent 318eed1 commit 99698f0
Show file tree
Hide file tree
Showing 16 changed files with 323 additions and 68 deletions.
55 changes: 55 additions & 0 deletions content/posts/wxwidget-macos-universal-binary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: "Wxwidgets macOS guide to compile universal binaries"
date: 2023-10-25T14:00:23+02:00
description: A tutorial that actually works.
draft: false
tags: [tutorial, macOS, wxwidgets]
---

## Introduction

I wanted to publish my wxwidgets project "D2R Runeword Calculator" which I already blogged about, to the macOS App Store. In order to do this with wxwidgets, you are advised to create statically-linked binaries that run both on x86_64 and arm64. But the instructions in the wxwidgets tutorials are outdated and lack crucial information. It took me a few hours, but I figured out how it can be done on macOS Ventura (13.6). The wxwidgets version I will be using is 3.2.3, which was released on October 10, 2023.

## Guide

### Step 1 - Acquire latest source code of wxwidgets

Just go to their [website](https://www.wxwidgets.org/downloads/) and download the latest stable "Source for Linux, macOS, etc". Then unpack it.

### Step 2 - Building

It took me lots of tries to find a command that would work but there it is:

```zsh
cd wxWidgets-3.2.3 && mkdir build-cocoa-static && cd build-cocoa-static && ../configure CXXFLAGS="-std=c++17" --enable-debug --disable-shared --with-osx_cocoa --with-libiconv --with-macosx-version-min=13.6 --enable-macosx_arch=x86_64,arm64 && make -j
```

This will take a long time, but it ensures that you get statically linked binaries that target both x86_64 and arm64 macOS. If you want to use a different C++ standard than 17, feel free to remove the part CXXFLAGS="-std=c++17" (I don't think it's needed).

### Step 3 - Installing

After the previous command terminates, just one more command is required to install wxwidgets:

```zsh
sudo make install
```

### Step 4 - Compiling your project

Now just cd to your project folder and run:

```zsh
g++ -arch x86_64 -arch arm64 -mmacosx-version-min=13.6 -std=c++17 *.cpp -w `wx-config --cxxflags --libs` -o myExecutable
```

The parameters "-arch x86_64 -arch arm64" ensure universal compilation. I kept getting warnings about some .dylibs (dynamic libaries) which are irrelevant, so I added "-w" to silence these warnings. I used "-mmacosx-version-min=13.6" because I am running Ventura 13.6 and the value here should be the same one as you used in the configure command; otherwise, you keep getting warnings about how it's linked against 13.0 or whatever. I use "-std=c++17" because that is the C++ version I am targeting.

You can verify that your binary works on x86_64 and arm64 by using the command:

```zsh
lipo -archs <yourBinary>
```

## Conclusion

This seems like a short and simple tutorial, but it is extremely frustrating to get to the point where things are working as they should. The wxwidgets tutorials are mostly outdated or lack crucial information. Then Brew baited me into trying that approach, but it kept ignoring my edits (the default is dynamic linking, which I don't want), and even after everything was set up it was not clear to me that -arch arm64 needs to be added to the command. I am glad that everything is working now, and the next steps are packaging the binary into a .App file that can be published on the App Store. I already noticed that the wxwidgets tutorial for building on XCode is already outdated, so I will see how that goes and maybe write another post after I am successful.
22 changes: 11 additions & 11 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@



<section class="list-item">
<h1 class="title"><a href="/posts/wxwidget-macos-universal-binary/">Wxwidgets macOS guide to compile universal binaries</a></h1>
<time>Oct 25, 2023</time>
<br><div class="description">

A tutorial that actually works.

</div>
<a class="readmore" href="/posts/wxwidget-macos-universal-binary/">Read more ⟶</a>
</section>

<section class="list-item">
<h1 class="title"><a href="/posts/hackintosh-xps9370/">Hackintosh #3: Running Sonoma on XPS 9370 (i7 8550u - 4k display)</a></h1>
<time>Oct 24, 2023</time>
Expand Down Expand Up @@ -129,17 +140,6 @@ <h1 class="title"><a href="/posts/golang-unintuitive-pitfalls/">Golang&#39;s uni
<a class="readmore" href="/posts/golang-unintuitive-pitfalls/">Read more ⟶</a>
</section>

<section class="list-item">
<h1 class="title"><a href="/posts/d2-runewords/">C&#43;&#43; runeword calculator GUI for Diablo 2 Resurrected</a></h1>
<time>Jul 27, 2023</time>
<br><div class="description">

Uses wxWidgets and has been tested on Windows, macOS and Linux.

</div>
<a class="readmore" href="/posts/d2-runewords/">Read more ⟶</a>
</section>



<ul class="pagination">
Expand Down
11 changes: 10 additions & 1 deletion public/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
<description>Recent content on Blog for Tech Enjoyers</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<lastBuildDate>Tue, 24 Oct 2023 08:00:23 +0200</lastBuildDate><atom:link href="https://example.com/index.xml" rel="self" type="application/rss+xml" />
<lastBuildDate>Wed, 25 Oct 2023 14:00:23 +0200</lastBuildDate><atom:link href="https://example.com/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Wxwidgets macOS guide to compile universal binaries</title>
<link>https://example.com/posts/wxwidget-macos-universal-binary/</link>
<pubDate>Wed, 25 Oct 2023 14:00:23 +0200</pubDate>

<guid>https://example.com/posts/wxwidget-macos-universal-binary/</guid>
<description>Introduction I wanted to publish my wxwidgets project &amp;ldquo;D2R Runeword Calculator&amp;rdquo; which I already blogged about, to the macOS App Store. In order to do this with wxwidgets, you are advised to create statically-linked binaries that run both on x86_64 and arm64. But the instructions in the wxwidgets tutorials are outdated and lack crucial information. It took me a few hours, but I figured out how it can be done on macOS Ventura (13.</description>
</item>

<item>
<title>Hackintosh #3: Running Sonoma on XPS 9370 (i7 8550u - 4k display)</title>
<link>https://example.com/posts/hackintosh-xps9370/</link>
Expand Down
11 changes: 11 additions & 0 deletions public/page/2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@



<section class="list-item">
<h1 class="title"><a href="/posts/d2-runewords/">C&#43;&#43; runeword calculator GUI for Diablo 2 Resurrected</a></h1>
<time>Jul 27, 2023</time>
<br><div class="description">

Uses wxWidgets and has been tested on Windows, macOS and Linux.

</div>
<a class="readmore" href="/posts/d2-runewords/">Read more ⟶</a>
</section>

<section class="list-item">
<h1 class="title"><a href="/posts/llama-python/">Python script for Llama 2 conversations</a></h1>
<time>Jul 26, 2023</time>
Expand Down
2 changes: 2 additions & 0 deletions public/posts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ <h1 class="page-title">All articles</h1>


<ul class="posts"><li class="post">
<a href="/posts/wxwidget-macos-universal-binary/">Wxwidgets macOS guide to compile universal binaries</a> <span class="meta">Oct 25, 2023</span>
</li><li class="post">
<a href="/posts/hackintosh-xps9370/">Hackintosh #3: Running Sonoma on XPS 9370 (i7 8550u - 4k display)</a> <span class="meta">Oct 24, 2023</span>
</li><li class="post">
<a href="/posts/stable-diffusion-gopher/">Using Stable Diffusion as Discord Emote Generator</a> <span class="meta">Oct 20, 2023</span>
Expand Down
11 changes: 10 additions & 1 deletion public/posts/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
<description>Recent content in Posts on Blog for Tech Enjoyers</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<lastBuildDate>Tue, 24 Oct 2023 08:00:23 +0200</lastBuildDate><atom:link href="https://example.com/posts/index.xml" rel="self" type="application/rss+xml" />
<lastBuildDate>Wed, 25 Oct 2023 14:00:23 +0200</lastBuildDate><atom:link href="https://example.com/posts/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Wxwidgets macOS guide to compile universal binaries</title>
<link>https://example.com/posts/wxwidget-macos-universal-binary/</link>
<pubDate>Wed, 25 Oct 2023 14:00:23 +0200</pubDate>

<guid>https://example.com/posts/wxwidget-macos-universal-binary/</guid>
<description>Introduction I wanted to publish my wxwidgets project &amp;ldquo;D2R Runeword Calculator&amp;rdquo; which I already blogged about, to the macOS App Store. In order to do this with wxwidgets, you are advised to create statically-linked binaries that run both on x86_64 and arm64. But the instructions in the wxwidgets tutorials are outdated and lack crucial information. It took me a few hours, but I figured out how it can be done on macOS Ventura (13.</description>
</item>

<item>
<title>Hackintosh #3: Running Sonoma on XPS 9370 (i7 8550u - 4k display)</title>
<link>https://example.com/posts/hackintosh-xps9370/</link>
Expand Down
133 changes: 133 additions & 0 deletions public/posts/wxwidget-macos-universal-binary/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<!DOCTYPE html>
<html><head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Wxwidgets macOS guide to compile universal binaries - Blog for Tech Enjoyers</title><link rel="icon" type="image/png" href=https://www.pngmart.com/files/23/Nerd-Emoji-PNG.png /><meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="A tutorial that actually works." />
<meta property="og:image" content=""/>
<meta property="og:title" content="Wxwidgets macOS guide to compile universal binaries" />
<meta property="og:description" content="A tutorial that actually works." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://example.com/posts/wxwidget-macos-universal-binary/" /><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2023-10-25T14:00:23+02:00" />
<meta property="article:modified_time" content="2023-10-25T14:00:23+02:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Wxwidgets macOS guide to compile universal binaries"/>
<meta name="twitter:description" content="A tutorial that actually works."/>
<script src="https://example.com/js/feather.min.js"></script>

<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">


<link rel="stylesheet" type="text/css" media="screen" href="https://example.com/css/main.11f18f89079b6a945895b72d837341dfd89f35ac277810cdb01c507ea0faeb47.css" />
<link id="darkModeStyle" rel="stylesheet" type="text/css" href="https://example.com/css/dark.c95c5dcf5f32f8b67bd36f7dab66680e068fce2b303087294114aabf7a7c080b.css" disabled />



</head><body>
<div class="content"><header>
<div class="main">
<a href="https://example.com/">Blog for Tech Enjoyers</a>
</div>
<nav>

<a href="/posts">Posts</a>

<a href="/about">About</a>

<a href="/tags">Tags</a>

| <a id="dark-mode-toggle" onclick="toggleTheme()" href=""></a>
<script src="https://example.com/js/themetoggle.js"></script>

</nav>
</header>
<main>

<article>
<div class="title">
<h1 class="title">Wxwidgets macOS guide to compile universal binaries</h1>
<div class="meta">Posted on Oct 25, 2023</div>
</div>


<aside>
<hr>
Table of Contents:
<nav id="TableOfContents">
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#guide">Guide</a>
<ul>
<li><a href="#step-1---acquire-latest-source-code-of-wxwidgets">Step 1 - Acquire latest source code of wxwidgets</a></li>
<li><a href="#step-2---building">Step 2 - Building</a></li>
<li><a href="#step-3---installing">Step 3 - Installing</a></li>
<li><a href="#step-4---compiling-your-project">Step 4 - Compiling your project</a></li>
</ul>
</li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</nav>
<hr>
</aside>


<section class="body">
<h2 id="introduction">Introduction</h2>
<p>I wanted to publish my wxwidgets project &ldquo;D2R Runeword Calculator&rdquo; which I already blogged about, to the macOS App Store. In order to do this with wxwidgets, you are advised to create statically-linked binaries that run both on x86_64 and arm64. But the instructions in the wxwidgets tutorials are outdated and lack crucial information. It took me a few hours, but I figured out how it can be done on macOS Ventura (13.6). The wxwidgets version I will be using is 3.2.3, which was released on October 10, 2023.</p>
<h2 id="guide">Guide</h2>
<h3 id="step-1---acquire-latest-source-code-of-wxwidgets">Step 1 - Acquire latest source code of wxwidgets</h3>
<p>Just go to their <a href="https://www.wxwidgets.org/downloads/">website</a> and download the latest stable &ldquo;Source for Linux, macOS, etc&rdquo;. Then unpack it.</p>
<h3 id="step-2---building">Step 2 - Building</h3>
<p>It took me lots of tries to find a command that would work but there it is:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-zsh" data-lang="zsh"><span style="display:flex;"><span>cd wxWidgets-3.2.3 <span style="color:#f92672">&amp;&amp;</span> mkdir build-cocoa-static <span style="color:#f92672">&amp;&amp;</span> cd build-cocoa-static <span style="color:#f92672">&amp;&amp;</span> ../configure CXXFLAGS<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;-std=c++17&#34;</span> --enable-debug --disable-shared --with-osx_cocoa --with-libiconv --with-macosx-version-min<span style="color:#f92672">=</span>13.6 --enable-macosx_arch<span style="color:#f92672">=</span>x86_64,arm64 <span style="color:#f92672">&amp;&amp;</span> make -j
</span></span></code></pre></div><p>This will take a long time, but it ensures that you get statically linked binaries that target both x86_64 and arm64 macOS. If you want to use a different C++ standard than 17, feel free to remove the part CXXFLAGS=&quot;-std=c++17&quot; (I don&rsquo;t think it&rsquo;s needed).</p>
<h3 id="step-3---installing">Step 3 - Installing</h3>
<p>After the previous command terminates, just one more command is required to install wxwidgets:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-zsh" data-lang="zsh"><span style="display:flex;"><span>sudo make install
</span></span></code></pre></div><h3 id="step-4---compiling-your-project">Step 4 - Compiling your project</h3>
<p>Now just cd to your project folder and run:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-zsh" data-lang="zsh"><span style="display:flex;"><span>g++ -arch x86_64 -arch arm64 -mmacosx-version-min<span style="color:#f92672">=</span>13.6 -std<span style="color:#f92672">=</span>c++17 *.cpp -w <span style="color:#e6db74">`</span>wx-config --cxxflags --libs<span style="color:#e6db74">`</span> -o myExecutable
</span></span></code></pre></div><p>The parameters &ldquo;-arch x86_64 -arch arm64&rdquo; ensure universal compilation. I kept getting warnings about some .dylibs (dynamic libaries) which are irrelevant, so I added &ldquo;-w&rdquo; to silence these warnings. I used &ldquo;-mmacosx-version-min=13.6&rdquo; because I am running Ventura 13.6 and the value here should be the same one as you used in the configure command; otherwise, you keep getting warnings about how it&rsquo;s linked against 13.0 or whatever. I use &ldquo;-std=c++17&rdquo; because that is the C++ version I am targeting.</p>
<p>You can verify that your binary works on x86_64 and arm64 by using the command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-zsh" data-lang="zsh"><span style="display:flex;"><span>lipo -archs &lt;yourBinary&gt;
</span></span></code></pre></div><h2 id="conclusion">Conclusion</h2>
<p>This seems like a short and simple tutorial, but it is extremely frustrating to get to the point where things are working as they should. The wxwidgets tutorials are mostly outdated or lack crucial information. Then Brew baited me into trying that approach, but it kept ignoring my edits (the default is dynamic linking, which I don&rsquo;t want), and even after everything was set up it was not clear to me that -arch arm64 needs to be added to the command. I am glad that everything is working now, and the next steps are packaging the binary into a .App file that can be published on the App Store. I already noticed that the wxwidgets tutorial for building on XCode is already outdated, so I will see how that goes and maybe write another post after I am successful.</p>

</section>

<div class="post-tags">


<nav class="nav tags">
<ul class="tags">

<li><a href="/tags/tutorial">tutorial</a></li>

<li><a href="/tags/macos">macOS</a></li>

<li><a href="/tags/wxwidgets">wxwidgets</a></li>

</ul>
</nav>


</div>
</article>



</main>
<footer>
<div style="display:flex"></div>
<div class="footer-info">
2023 <a
href="https://github.com/athul/archie">Archie Theme</a> | Built with <a href="https://gohugo.io">Hugo</a>
</div>
</footer>


</div>
</body>
</html>
33 changes: 18 additions & 15 deletions public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,30 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url>
<loc>https://example.com/</loc>
<lastmod>2023-10-24T08:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/hackintosh/</loc>
<lastmod>2023-10-24T08:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/posts/hackintosh-xps9370/</loc>
<lastmod>2023-10-24T08:00:23+02:00</lastmod>
<lastmod>2023-10-25T14:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/macos/</loc>
<lastmod>2023-10-24T08:00:23+02:00</lastmod>
<lastmod>2023-10-25T14:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/posts/</loc>
<lastmod>2023-10-24T08:00:23+02:00</lastmod>
<lastmod>2023-10-25T14:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/</loc>
<lastmod>2023-10-25T14:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/tutorial/</loc>
<lastmod>2023-10-25T14:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/wxwidgets/</loc>
<lastmod>2023-10-25T14:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/posts/wxwidget-macos-universal-binary/</loc>
<lastmod>2023-10-25T14:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/hackintosh/</loc>
<lastmod>2023-10-24T08:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/posts/hackintosh-xps9370/</loc>
<lastmod>2023-10-24T08:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/ai/</loc>
Expand All @@ -34,9 +43,6 @@
</url><url>
<loc>https://example.com/posts/twitch-adblock-streamlink/</loc>
<lastmod>2023-10-14T08:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/tutorial/</loc>
<lastmod>2023-10-14T08:00:23+02:00</lastmod>
</url><url>
<loc>https://example.com/posts/hackintosh-ventura-rx6650xt/</loc>
<lastmod>2023-10-10T08:00:23+02:00</lastmod>
Expand Down Expand Up @@ -79,9 +85,6 @@
</url><url>
<loc>https://example.com/tags/gaming/</loc>
<lastmod>2023-07-27T22:50:00+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/wxwidgets/</loc>
<lastmod>2023-07-27T22:50:00+02:00</lastmod>
</url><url>
<loc>https://example.com/tags/llama/</loc>
<lastmod>2023-07-26T18:00:23+02:00</lastmod>
Expand Down
Loading

0 comments on commit 99698f0

Please sign in to comment.