Do not build the MFC sample with CMake when linking CRT statically (PR #26770)

21 views
Skip to first unread message

PB

unread,
Aug 1, 2026, 9:45:07 AM (3 days ago) Aug 1
to wx-...@googlegroups.com, Subscribed

I have originally tried to make the sample work even when linking the CRT statically with

diff --git a/samples/mfc/stdafx.h b/samples/mfc/stdafx.h
index a814f87e7f..86a22b0afc 100644
--- a/samples/mfc/stdafx.h
+++ b/samples/mfc/stdafx.h
@@ -1,7 +1,7 @@
 // normally this is defined by the IDE by "Using MFC" option but if it isn't
 // (e.g. because we use bakefile-generated projects), do it ourselves to ensure
 // that MFC libraries are linked in
-#ifndef _AFXDLL
+#if !defined(_AFXDLL) && defined(_DLL)
     #define _AFXDLL
 #endif
 #include <afxwin.h>

The sample worked great but when shutting it down I got an exception

[Exception thrown at 0x00007FFED9A476BD (ntdll.dll) in mfc.exe: 0xC0000005: Access violation reading location 0x0000000000000012.] Annotated Frame
ntdll.dll!00007ffed9a476bd() Unknown No symbols loaded.
mfc.exe!__vcrt_uninitialize_locks() Line 45 C++ Symbols loaded.
ntdll.dll!00007ffed9acad6c() Unknown No symbols loaded.

I probably could not figure what is wrong, this is a rather niche sample and edge case, so I opted for the simplest solution: Do not attempt to build the sample when it is doomed to fail.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26770

Commit Summary

  • 9fe422f Do not build the MFC sample with CMake when linking CRT statically

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26770@github.com>

VZ

unread,
Aug 1, 2026, 4:14:23 PM (3 days ago) Aug 1
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26770)

Looks good, thanks!


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26770/c5153225977@github.com>

VZ

unread,
Aug 2, 2026, 3:40:22 PM (2 days ago) Aug 2
to wx-...@googlegroups.com, Subscribed

Closed #26770 via cf9d191.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26770/issue_event/28856571348@github.com>

Reply all
Reply to author
Forward
0 new messages