A Beginner's Helper: Build wxWidgets on Win32 w/ MinGW Topic is solved

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply

Do you think this script can be, is, or will be good for beginning wx users?

Stupid Script
1
13%
It's OK, if you are idiot
0
No votes
Its good for beginners
0
No votes
Beginners rejoice!
4
50%
Great even for the experienced!
3
38%
 
Total votes: 8

jmason1182
Earned some good credits
Earned some good credits
Posts: 149
Joined: Fri Dec 14, 2007 3:40 pm
Location: Midland, TX
Contact:

A Beginner's Helper: Build wxWidgets on Win32 w/ MinGW

Post by jmason1182 » Fri Apr 24, 2009 2:53 pm

New windows users/developers aren't dumb. It's just that some people don't understand how to build a library when they start out, and let's face it. Lots of people have MS Windows, use Windows, and so they try to learn on Windows. The point of this script is to help people like that. Hey, back in the Windows 3.1 days I was one of those people! Sure, I was in the 5th grade, but I was still trying to teach myself how to program C/C++ on windows! So go for it you windows noobies! And good luck.


I wrote this script quite a while ago, but while searching for my own issues, I discovered how many people try to develop in windows that don't know the first thing about building libraries, the difference between static/dynamic, etc. Thus I wrote this script.

For anybody that wants it, I made a little batch file that simplifies the process of building wxWidgets on windows using MinGW. I use it and have used it for a while so that if I need to "redo" the compile I don't have to worry about opening a command prompt, remember where and what config options I needed, etc. etc.

Using the script
The third line of the batch file needs to be adjusted so that it points to you widgets library build/msw directory.

Example: I unzipped wxWidgets 2.8.10 into

Code: Select all

c:\dev\wx\wxWidgets-2.8.10
so my third line says

Code: Select all

pushd c:\dev\wx\wxWidgets-2.8.10\build\msw
You'll need to just change that third line of this batch script and it seems to all work fine. OH! And make sure that mingw is in your path. So yes, this script assumes you have mingw installed and in your path, and wxWidgets downloaded (I prefer the zip file, but to each his own) and in a known location. You'll need that location for the third line of this script.

myWxMake.bat

Code: Select all

@echo off
SETLOCAL
pushd C:\dev\wx\wxWidgets-2.8.10\build\msw

cls
echo.
echo -----------------------------------------------------------------------------------
echo wxWidgets Win32/MinGW Helper build script
echo      Author:   John A. Mason
echo      Date:     04/24/2009
echo      Release:  For anyone to use/copy/manipulate/learn. Hope it helps.
echo -----------------------------------------------------------------------------------
echo.
echo.
echo This script will ask a series of questions to figure out which build you wish to
echo construct. There are many ways, depending on your needs, to build the wxWidgets
echo library. 
echo.
echo The defaults have been setup so that you can build the standard build of wxWidgets.
echo Leaving every question blank and just pressing enter will fill in the 
echo standard [default] options.
echo.
echo.
echo Let's begin.
echo.
echo -----------------------------------------------------------------------------------
pause
cls
echo.
echo The developers of wxWidgets did a great thing starting with version 2.5 
echo in reducing the footprint of the requirements for a wxWidgets application
echo by splitting the giant library into smaller library files. However, this has
echo led to some developers having trouble figuring out which library files they
echo must link to. This script can still build the giant monolithic library if you
echo wish. However, the new default is to build the multilib version (of many,
echo smaller, individual library files).
echo.
echo Would you like to build the libraries as Monolithic library (y/n)? [no]
set /p myMONOLITHIC=
cls
echo.
echo Depending on the needs of your application and the platform requirements, 
echo you may wish to build this library as a unicode library. It does require to use
echo of the wxT() macro or _T() macro when defining any and all string literals in 
echo all of your application code, however.
echo.
echo Would you like build Unicode libraries (y/n)? [yes]
set /p myUNICODE=
cls
echo.
echo This script can help you build both the static and shared libraries of wxWidgets,
echo or it can be told to only build the shared or only the static.
echo.
echo Leaving the next two prompts at the default is recommended unless you are building
echo a special build that requires you to build the shared libraries separately from
echo the static. E.g. using RUNTIME_LIBS=static cannot be used when building the shared
echo libraries. In that case, you would first build the shared libraries without 
echo RUNTIME_LIBS=static. Then you would build the static libraries with the option added.
echo.
echo Would you like to build static libraries (y/n)? [yes]
set /p mySTATIC=
echo Would you like to build shared libraries (y/n)? [yes]
set /p mySHARED=
cls
echo.
echo The vendor name determines the appended name on shared dll files. If you are company
echo ABC, you might want your dll files to be wxbase28u_core_abc.dll to identify that
echo your company provided them as part of your application. Since this is considered a
echo custom build, the default is to add custom to all dll files.
echo.
echo What vendor name for your custom dll files? [custom]
set /p myVENDOR=
cls
echo.
echo All object files are stored in a directory under build\msw, depending on build settings,
echo compiler name, and the CFG setting. Examples of directory names:
echo.
echo   build\msw\bcc_msw            SHARED=0
echo   build\msw\bcc_mswdll         SHARED=1
echo   build\msw\bcc_mswunivd       SHARED=0, WXUNIV=1, BUILD=debug
echo   build\msw\vc_mswunivd        ditto, with Visual C++
echo.
echo Libraries and DLLs are stored in a directory structure similar, along with the setup.h
echo that matches the build configuration. Examples:
echo with name that contains other settings:
echo.
echo   lib\bcc_msw
echo   lib\bcc_lib\msw\wx\setup.h
echo   lib\bcc_dll
echo   lib\bcc_dll\msw\wx\setup.h
echo   lib\bcc_lib
echo   lib\bcc_lib\mswunivd\wx\setup.h
echo   lib\vc_lib
echo   lib\vc_lib\mswunivd\wx\setup.h
echo.
pause
cls
echo If you set CFG to something, the value is appended to directory names. Thus, if you set CFG you
echo will need to change your linker command to reflect the changed directory names. E.g.
echo for CFG=MyBuild, you'll have object files in
echo.
echo   build\msw\bcc_mswMyBuild
echo   build\msw\bcc_mswdllMyBuild
echo   etc.
echo.
echo and libraries in
echo.
echo   lib\bcc_libMyBuild
echo   lib\bcc_dllMyBuild
echo   etc.
echo.
echo The purpose of this is to allow for multiple builds with multiple setups that don't conflict.
echo So if you want to build both the monolithic AND the multilib version, set CFG to something
echo different for each build or else the latter build will overwrite the first build.
echo.
echo Would you like to set the CFG of this build? [(empty)]
set /p myCUSTOM=
cls
echo.
echo Reading the INSTALL-MSW.txt file will provide other options that can be used for building.
echo Examples include:
echo.
echo   MSLU=1
echo   RUNTIME_LIBS=static
echo   WXUNIV=1
echo   etc.
echo  * NOTE: Be sure to read the INSTALL-MSW.txt file for important information. For instance, 
echo          adding RUNTIME_LIBS=static along side of the SHARED=1 will cause issues!
echo.
echo Would you like to set any other options for this build? [(empty)]
set /p myOTHER=
cls

if "%myMONOLITHIC%" == "" set myMONOLITHIC=no
if "%myUNICODE%" == "" set myUNICODE=yes
if "%mySTATIC%" == "" set mySTATIC=yes
if "%mySHARED%" == "" set mySHARED=yes
if "%myVENDOR%" == "" set myVENDOR=custom
if "%myCUSTOM%" == "" set myCUSTOM=
if "%myOTHER%" == "" set myOTHER=

echo.
echo -----------------------------------------------------------------------------------
echo.
echo Configuration complete:
echo.
echo   Build Monolithic:      %myMONOLITHIC%
echo   Build Unicode:         %myUNICODE%
echo   Build Static libs:     %mySTATIC%
echo   Build Shared libs:     %mySHARED%
echo   Vendor Label:          %myVENDOR%
echo   Custom Build dir:      %myCUSTOM%
echo   Other Build options:   %myOTHER%
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Please confirm:
echo.
echo Is this correct? (y/n) [y]
set /p myConfirm=

if "%myConfirm%" == "" set myConfirm=yes
if "%myConfirm%" == "n" GOTO END
if "%myConfirm%" == "0" GOTO END
if "%myConfirm%" == "no" GOTO END

cls
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Beginning Build Process...
echo.
echo.

if "%myMONOLITHIC%" == "n" GOTO SKIPMONO
if "%myMONOLITHIC%" == "0" GOTO SKIPMONO
if "%myMONOLITHIC%" == "no" GOTO SKIPMONO
if "%myUNICODE%" == "n" GOTO SKIPUNICODEMONO
if "%myUNICODE%" == "0" GOTO SKIPUNICODEMONO
if "%myUNICODE%" == "no" GOTO SKIPUNICODEMONO

if "%mySTATIC%" == "n" GOTO SKIPSTATICA
if "%mySTATIC%" == "0" GOTO SKIPSTATICA
if "%mySTATIC%" == "no" GOTO SKIPSTATICA
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MONOLITHIC UNICODE STATIC
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
:SKIPSTATICA

if "%mySHARED%" == "n" GOTO END
if "%mySHARED%" == "0" GOTO END
if "%mySHARED%" == "no" GOTO END
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MONOLITHIC UNICODE SHARED
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=1 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
GOTO END

:SKIPUNICODEMONO
if "%mySTATIC%" == "n" GOTO SKIPSTATICB
if "%mySTATIC%" == "0" GOTO SKIPSTATICB
if "%mySTATIC%" == "no" GOTO SKIPSTATICB
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MONOLITHIC STATIC
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
:SKIPSTATICB

if "%mySHARED%" == "n" GOTO END
if "%mySHARED%" == "0" GOTO END
if "%mySHARED%" == "no" GOTO END
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MONOLITHIC SHARED
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=0 MONOLITHIC=1 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
GOTO END

:SKIPMONO
if "%myUNICODE%" == "n" GOTO SKIPUNICODE
if "%myUNICODE%" == "0" GOTO SKIPUNICODE
if "%myUNICODE%" == "no" GOTO SKIPUNICODE

if "%mySTATIC%" == "n" GOTO SKIPSTATICC
if "%mySTATIC%" == "0" GOTO SKIPSTATICC
if "%mySTATIC%" == "no" GOTO SKIPSTATICC
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MULTILIB UNICODE STATIC
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
:SKIPSTATICC

if "%mySHARED%" == "n" GOTO END
if "%mySHARED%" == "0" GOTO END
if "%mySHARED%" == "no" GOTO END
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MULTILIB UNICODE SHARED
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=1 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
GOTO END

:SKIPUNICODE

if "%mySTATIC%" == "n" GOTO SKIPSTATICD
if "%mySTATIC%" == "0" GOTO SKIPSTATICD
if "%mySTATIC%" == "no" GOTO SKIPSTATICD
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MULTILIB STATIC
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=debug UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=0 BUILD=release UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
:SKIPSTATICD

if "%mySHARED%" == "n" GOTO END
if "%mySHARED%" == "0" GOTO END
if "%mySHARED%" == "no" GOTO END
echo.
echo -----------------------------------------------------------------------------------
echo.
echo Building: MULTILIB SHARED
echo.
echo -----------------------------------------------------------------------------------
echo.
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=debug UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" clean
mingw32-make -f makefile.gcc %myOTHER% SHARED=1 BUILD=release UNICODE=0 MONOLITHIC=0 CFG="%myCUSTOM%" VENDOR="%myVENDOR%" 


echo -----------------------------------------------------------------------------------
echo.
echo Building: COMPLETE
echo.
echo Hope this helped you.
echo.
echo -----------------------------------------------------------------------------------
echo.

:END
set myUNICODE=
set myMONOLITHIC=
set myVENDOR=
set myCUSTOM=
set myOTHER=
set myConfirm=
popd
ENDLOCAL

Hope this helps someone.
Attachments
mymake.zip
A batch file to help with building wxWidgets library on Win32 with MinGW. A beginner's helper.
(2.73 KiB) Downloaded 148 times
John A. Mason
Midland, TX

basile
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Feb 28, 2008 10:21 am

Post by basile » Tue May 12, 2009 10:00 am

Hi,

I used it for standard wx2.8.10. It works fine!

May be an interesting improvement will be to support compiling libs that needs WX_UNICODE, WX_BUILD, WX_SHARED, etc... variables. This will also help beginners to compile libraries founded on wxCode website.

I known that it can be done by search&replace variables to new one but, may be we can change the script in a way that it will automatically detects which variables are requiered by the compiler for the target library....

Regards,

Basile
MS Windows SP3 / Debian UNSTABLE/ WX2.9.10

jmason1182
Earned some good credits
Earned some good credits
Posts: 149
Joined: Fri Dec 14, 2007 3:40 pm
Location: Midland, TX
Contact:

Post by jmason1182 » Tue May 12, 2009 3:11 pm

For the main wxWidgets libraries, this is done via the make file... so I'm not sure what you mean.

Are you talking about the rest of the wxCode libraries and other "extra" libraries?

I think a generic makefile might be helful because it can do some more than a windows batch file can do (without lots and lots of windows batch file junk). Then the makefile could be adjusted for the particular library being built, but at the least the framework would all be done.

What do you think?
John A. Mason
Midland, TX

basile
In need of some credit
In need of some credit
Posts: 9
Joined: Thu Feb 28, 2008 10:21 am

Post by basile » Tue May 12, 2009 4:02 pm

For the main WxWidgets, it's alright!

I just want to adapt your script to libraries like wxpdfdoc, keybinder, etc... provided by the wxCode website.

For example, when you want to compile the library wxpdfdoc. In the configure.gcc, you have to define the value of the following variable:
WX_DEBUG
WX_SHARED
WX_UNICODE
WX_MONOLITHIC

For beginners, using your batch file and replacing the name of the variable can be helpfull for compiling extra libraries.

But I agree with you that at the end the makefile will be the only solution when "beginners" want to compile their developed application.

I hope I'm more understandable now...
MS Windows SP3 / Debian UNSTABLE/ WX2.9.10

Post Reply