Help building non-UNICODE version of 3.1.0 Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
rdaniel
In need of some credit
In need of some credit
Posts: 4
Joined: Tue May 02, 2017 12:53 pm

Help building non-UNICODE version of 3.1.0

Post by rdaniel »

Hi all,

I have a product that has been upgraded from Visual Studio 2008 to Visual Studio 2015. It supports both Windows and Native C++ deployment so we've made use of wxWidgets to create a cross platform UI for testing. The previous version of wxWidgets that we were using is 2.8.12 where we were able to build the libraries on Windows with the Character Set property not set. I've tried building 3.1.0 with the wxUSE_UNICODE value set to 0 as suggested by this statement:

Code: Select all

// ----------------------------------------------------------------------------
// Unicode support
// ----------------------------------------------------------------------------

// These settings are obsolete: the library is always built in Unicode mode
// now, only set wxUSE_UNICODE to 0 to compile legacy code in ANSI mode if
// absolutely necessary -- updating it is strongly recommended as the ANSI mode
// will disappear completely in future wxWidgets releases.
#ifndef wxUSE_UNICODE
    #define wxUSE_UNICODE 0
#endif
However, I am unable to successfully build the solution as it appears there are errors with mixing UNICODE and ANSI build objects:

8>------ Build started: Project: base, Configuration: Debug Win32 ------
8> dummy.cpp
6> jcdctmgr.c
6> jchuff.c
6> jcinit.c
6> jcmainct.c
8>C:\wxWidgets-3.1.0\include\wx/msw/private.h(886): error C2664: 'DWORD GetModuleFileNameW(HMODULE,LPWSTR,DWORD)': cannot convert argument 2 from 'wxStringTypeBuffer<wxChar>' to 'LPWSTR'
8> C:\wxWidgets-3.1.0\include\wx/msw/private.h(886): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
6> jcmarker.c
6> jcmaster.c
6> jcomapi.c
6> jcparam.c

I have taken into consideration the comments on the libraries moving to UNICODE permanently in the future and eventually an effort will be made to up date our product to support UNICODE. However, at this time we still need the legacy support for our in house testing efforts.

Any help compiling the ANSI version successfully would be greatly appreciated.

Thanks,
Ryan
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Help building non-UNICODE version of 3.1.0

Post by ONEEYEMAN »

Hi,
You best bet would be to post to the wx-dev ML.
This is the users forum. No core wx-dev are coming here.

But more to it - why not try to compile everything with UNICODE? The upgrade should be trivial and most issues (if not all) were already solved
a long time ago.

So all you will need is to compile everything in UNICODE mode and start you application testing.
rdaniel
In need of some credit
In need of some credit
Posts: 4
Joined: Tue May 02, 2017 12:53 pm

Re: Help building non-UNICODE version of 3.1.0

Post by rdaniel »

Unfortunately, the intention of this upgrade was to hopefully compile the new wxWidgets libraries and then be able to just recompile the old project referencing the new libraries with minimal to no changes being made. It's a bit of a time sensitive scenario that wasn't well thought out so the last option would be to modify the existing project to work with UNICODE.

I will post in the dev forum to see if this is possible.
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Help building non-UNICODE version of 3.1.0

Post by doublemax »

Are you sure you edited the correct version of setup.h? I just tested this with VS2010, only changed wxUSE_UNICODE to 0 and the libs were built fine.

Change <wxdir>/include/wx/msw/setup.h and do a clean rebuild.
Use the source, Luke!
rdaniel
In need of some credit
In need of some credit
Posts: 4
Joined: Tue May 02, 2017 12:53 pm

Re: Help building non-UNICODE version of 3.1.0

Post by rdaniel »

I edited the correct setup.h but I also noticed that in platform.h there is a redefine of the wxUSE_UNICODE flag. If I explicitly set the flag to 0 here then the build fails.

Code: Select all

/*
   adjust the Unicode setting: wxUSE_UNICODE should be defined as 0 or 1
   and is used by wxWidgets, _UNICODE and/or UNICODE may be defined or used by
   the system headers so bring these settings in sync
 */

/* set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined */
#if defined(_UNICODE) || defined(UNICODE)
#   undef wxUSE_UNICODE
#   define wxUSE_UNICODE 0
#else /* !UNICODE */
#   ifndef wxUSE_UNICODE
#       define wxUSE_UNICODE 0
#   endif
#endif /* UNICODE/!UNICODE */
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Help building non-UNICODE version of 3.1.0

Post by ONEEYEMAN »

Hi,
rdaniel wrote: Unfortunately, the intention of this upgrade was to hopefully compile the new wxWidgets libraries and then be able to just recompile the old project referencing the new libraries with minimal to no changes being made. It's a bit of a time sensitive scenario that wasn't well thought out so the last option would be to modify the existing project to work with UNICODE.

I will post in the dev forum to see if this is possible.
Please re-read my reply.
This is exactly what will happen if you stay with the official release of 3.1.0 - minimal or no changes.
Keep in mind that you will still have to do some changes - some behavior did change between those versions and some new functionality exist which was not available at the time of 2.8. So porting the application will not be "completely trivial" already. ;-)

Thank you.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Help building non-UNICODE version of 3.1.0

Post by ONEEYEMAN »

Hi,
rdaniel wrote: I edited the correct setup.h but I also noticed that in platform.h there is a redefine of the wxUSE_UNICODE flag. If I explicitly set the flag to 0 here then the build fails.

Code: Select all

/*
   adjust the Unicode setting: wxUSE_UNICODE should be defined as 0 or 1
   and is used by wxWidgets, _UNICODE and/or UNICODE may be defined or used by
   the system headers so bring these settings in sync
 */

/* set wxUSE_UNICODE to 1 if UNICODE or _UNICODE is defined */
#if defined(_UNICODE) || defined(UNICODE)
#   undef wxUSE_UNICODE
#   define wxUSE_UNICODE 0
#else /* !UNICODE */
#   ifndef wxUSE_UNICODE
#       define wxUSE_UNICODE 0
#   endif
#endif /* UNICODE/!UNICODE */
You need to go and explicitly undefine the UNICODE and/or _UNICODE from all wx projects inside the solution of MSVC.
Then you will be able (hopefully) compile it in the ANSI mode.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Help building non-UNICODE version of 3.1.0

Post by doublemax »

I also noticed that in platform.h there is a redefine of the wxUSE_UNICODE flag. If I explicitly set the flag to 0 here then the build fails.
What happens if you don't do that?

BTW: Have you tried how many compiler errors you get when building your project in Unicode mode?
Use the source, Luke!
rdaniel
In need of some credit
In need of some credit
Posts: 4
Joined: Tue May 02, 2017 12:53 pm

Re: Help building non-UNICODE version of 3.1.0

Post by rdaniel »

doublemax wrote:
I also noticed that in platform.h there is a redefine of the wxUSE_UNICODE flag. If I explicitly set the flag to 0 here then the build fails.
What happens if you don't do that?

BTW: Have you tried how many compiler errors you get when building your project in Unicode mode?
When I don't explicitly set the wxUSE_UNICODE flag to 0 in platform.h it compiles fine in all configurations. When I then try to compile my old solution I get the following errors:

Code: Select all

14>C:\wxWidgets-3.1.0\include\wx/strvararg.h(349): error C2039: 'value': is not a member of 'wxFormatStringSpecifierNonPodType<false>'
14>  C:\wxWidgets-3.1.0\include\wx/strvararg.h(349): note: see declaration of 'wxFormatStringSpecifierNonPodType<false>'
Now I understand with this release there were a vast amount of changes done around the string functionality so I imagine I will have to rework a lot of the code that does any string formatting.
Post Reply