wxMSW samples/mfc build problems

27 views
Skip to first unread message

wsu

unread,
May 20, 2023, 5:05:17 PM5/20/23
to wx-dev
After failing to build wxMSW master branch samples/mfc using static libraries (see previous posting), I switched to trying to build using dynamic libraries, and have run into issues there as well.

1)  I don't see .vcxproj or .sln files for samples/mfc, only command line makefile.vc.  Is that expected?

2)  I assumed that I should build using nmake -f makefile.vc, I ran into problems where LPCTSTR could not be converted to LPCWSTR.  Normally, the UNICODE preprocessor setting is enabled by include\wx\platform.h.  However, that is not the case for samples/mfc.  The samples/mfc/mfctest.cpp sets WINVER explicitly; should the same be done for UNICODE?

3)  Assuming 2 to be correct, I did that, but then I ran into problems with converting (narrow) string constants to LPCTSTR:

Microsoft (R) Program Maintenance Utility Version 14.35.32215.0
Copyright (C) Microsoft Corporation.  All rights reserved.

cl /c /nologo /TP /Fovc_x64_mswuddll\mfctest_mfctest.obj /MDd /DWIN32  /Zi /Fdvc_x64_mswuddll\mfctest.pdb /D_DEBUG  /Od /D_CRT_SECURE_NO_DEPRECATE=1  /D_CRT_NON_CONFORMING_SWPRINTFS=1 /D_SCL_SECURE_NO_WARNINGS=1    /D__WXMSW__          /I.\..\..\lib\vc_x64_dll\mswud /I.\..\..\include  /W4 /I.  /DWXUSINGDLL /D_WINDOWS /I.\..\..\samples /DNOPCH /GR  /EHsc   .\mfctest.cpp
mfctest.cpp
.\mfctest.cpp(175): error C2664: 'BOOL CFrameWnd::LoadAccelTable(LPCTSTR)': cannot convert argument 1 from 'const char [15]' to 'LPCTSTR'
.\mfctest.cpp(175): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ATLMFC\include\afxwin.h(4077): note: see declaration of 'CFrameWnd::LoadAccelTable'
.\mfctest.cpp(175): note: while trying to match the argument list '(const char [15])'
.\mfctest.cpp(176): error C2664: 'BOOL CFrameWnd::Create(LPCTSTR,LPCTSTR,DWORD,const RECT &,CWnd *,LPCTSTR,DWORD,CCreateContext *)': cannot convert argument 2 from 'const char [29]' to 'LPCTSTR'
.\mfctest.cpp(176): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ATLMFC\include\afxwin.h(4078): note: see declaration of 'CFrameWnd::Create'
.\mfctest.cpp(176): note: while trying to match the argument list '(nullptr, const char [29], long, const CRect, nullptr, const char [9])'
.\mfctest.cpp(208): error C2665: 'CDialog::CDialog': no overloaded function could convert all the argument types
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ATLMFC\include\afxwin.h(3341): note: could be 'CDialog::CDialog(UINT,CWnd *)'
.\mfctest.cpp(208): note: 'CDialog::CDialog(UINT,CWnd *)': cannot convert argument 1 from 'const char [9]' to 'UINT'
.\mfctest.cpp(208): note: There is no context in which this conversion is possible
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ATLMFC\include\afxwin.h(3340): note: or       'CDialog::CDialog(LPCTSTR,CWnd *)'
.\mfctest.cpp(208): note: 'CDialog::CDialog(LPCTSTR,CWnd *)': cannot convert argument 1 from 'const char [9]' to 'LPCTSTR'
.\mfctest.cpp(208): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
.\mfctest.cpp(208): note: while trying to match the argument list '(const char [9], CMainWindow *)'
NMAKE : fatal error U1077: 'cl /c /nologo /TP /Fovc_x64_mswuddll\mfctest_mfctest.obj /MDd /DWIN32  /Zi /Fdvc_x64_mswuddll\mfctest.pdb /D_DEBUG  /Od /D_CRT_SECURE_NO_DEPRECATE=1  /D_CRT_NON_CONFORMING_SWPRINTFS=1 /D_SCL_SECURE_NO_WARNINGS=1    /D__WXMSW__          /I.\..\..\lib\vc_x64_dll\mswud /I.\..\..\include  /W4 /I.  /DWXUSINGDLL /D_WINDOWS /I.\..\..\samples /DNOPCH /GR  /EHsc   .\mfctest.cpp' : return code '0x2'
Stop.



Have I missed something important, or is this sample not maintained any more?

Maarten Bent

unread,
May 20, 2023, 5:50:49 PM5/20/23
to wx-...@googlegroups.com
Hi,

1) There are indeed no .vcxproj or .sln for the samples. Only the minimal sample has these.

2) I see the same problem. UNICODE define is missing. For a quick test I added it to stdafx.h.
Since the master branch is unicode only, I think we can always define this.

3) And then I get the build problems too. Easy to fix by making them a wide string using 'L', e.g.L"MainAccelTable".
After that, the sample builds and runs.

This sample has indeed not been maintained for a while. I wanted to try it with CMake, but there it has been disabled since the initial CMake system was created 6 years ago: https://github.com/wxWidgets/wxWidgets/blob/master/build/cmake/samples/CMakeLists.txt#L282

Maarten

--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-dev/723ee903-c069-46ae-bfb7-099f54fb7d4en%40googlegroups.com.

Vadim Zeitlin

unread,
May 20, 2023, 8:52:30 PM5/20/23
to wx-...@googlegroups.com
On Sat, 20 May 2023 23:50:51 +0200 Maarten Bent wrote:

MB> 1) There are indeed no .vcxproj or .sln for the samples. Only the
MB> minimal sample has these.

We still have to do something about this, but I still have no idea what (I
planned to try using Premake for generating them, but never got around to
even trying to do this seriously).

MB> 2) I see the same problem. UNICODE define is missing. For a quick test I
MB> added it to stdafx.h.
MB> Since the master branch is unicode only, I think we can always define this.
MB>
MB> 3) And then I get the build problems too. Easy to fix by making them a
MB> wide string using 'L', e.g.L"MainAccelTable".
MB> After that, the sample builds and runs.

If you already have these changes, could you please push them to a branch
and make a PR with them?

MB> This sample has indeed not been maintained for a while. I wanted to try
MB> it with CMake, but there it has been disabled since the initial CMake
MB> system was created 6 years ago:
MB> https://github.com/wxWidgets/wxWidgets/blob/master/build/cmake/samples/CMakeLists.txt#L282

This sample can't be enabled by default because it requires MFC and even
MSVS installation doesn't need to (and is quite likely not to) have MFC
installed.

Regards,
VZ
Reply all
Reply to author
Forward
0 new messages