wxWidgets Compile Options

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.
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxWidgets Compile Options

Post by spflanze »

This time I tried Manolo's recommendation. The procedure I followed:

Add the WXWIN enviornment variable and set it to c:\wxWidgets-3.0.4 .
How to: https://www.computerhope.com/issues/ch000549.htm

Install a fresh wxWidgets 3.0.4 from the file wxMSW-3.0.4-Setup.exe downloaded from https://github.com/wxWidgets/wxWidgets/ ... tag/v3.0.4 .
Add the WXWIN enviornment variable and set it to C:\wxWidgets-3.0.4
How to: https://www.computerhope.com/issues/ch000549.htm

Download MinGW 64 from: http://mingw-w64.sourceforge.net/ and install it.
Download MSYS2 from https://www.msys2.org/ and install it.

Open MSYS2 terminal emulator, and execut the commands:

Code: Select all

pacman -Syu
When finished close the MSYS2's window (x in the window's upper left ). Avoid closing it by command line as instructed.

I reoponed MSYS2 and executed:

Code: Select all

pacman -Su
pacman -S git
cd $WXWIN
mkdir build-debug
cd build-debug
../configure --enable-debug --disable-shared --with-msw
I got the error:

Code: Select all

checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/c/wxWidgets-3.0.4/build-debug':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
In the directory C:\TDM-GCC-64\bin I see the file gcc.exe . So in MSYS2 I executed the command:

Code: Select all

PATH=$PATH:/c/TDM-GCC-64/bin
and once again executed the above the config command. This time config did a lot more, but fnally ended with the error message:

Code: Select all

configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING:  '../../../src/expat/Makefile.in' seems to ignore the --datarootdir setting
config.status: creating expat.pc
config.status: creating expat_config.h
config.status: executing libtool commands
../../../src/expat/configure: line 18667: make: command not found
configure: error: ../../../src/expat/configure failed for src/expat
No file named "make" was created. The file named "Makefile" that was created does not seem to be a make file. There were many errors when executed.

What did I miss here?
Last edited by spflanze on Wed Apr 03, 2019 3:45 am, edited 1 time in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets Compile Options

Post by ONEEYEMAN »

Hi,
So when you executed:

Code: Select all

c:\wxWidgets-3.0.4\build\msw>mingw32-make -f Makefile.gcc BUILD=Debug
does it finished successfully? Did it give you any errors?

Please start from scratch in order to eliminate any leftovers:

1. Unpack wxWidgets source code.
2. Execute the command above.
3. Check for any errors.

Also, please say which compiler from the list Manolo posted you will be using and what version.

Thank you.
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxWidgets Compile Options

Post by spflanze »

I tried again ONEEYEMAN's method with a fresh unpack of wxWidgets 3.0.4. I compiled wxWidgets using the command:

Code: Select all

C:\wxWidgets-3.0.4\build\msw>mingw32-make -f Makefile.gcc BUILD=Debug > mingw32-make.txt 2>&1 
The mingw32-make.txt file the above command produced can be downloaded from: http://www.mediafire.com/file/f4pgfdsdg ... e.txt/file (2.7 MB). There are many warnings, but no errors.

I was able to create a project in Code::Blocks 17.12 as before. But as before I got the same errors when I attempted to compile the starter files the project wizard created. The compiler used in Code::Blocks is in a directory named C:\TDM-GCC-64 . In this directory there is a text file named "README-gcc-tdm64.txt". In this file's header there is this version information:
__/__/ TDM-GCC Compiler Suite for Windows \__\__
| « « | GCC 5 Series | » » |
¯¯\¯¯\ MinGW-w64 64/32-bit Edition /¯¯/¯¯
This edition of TDM-GCC is a bi-arch bootstrap of GCC's x86_64-w64-mingw32
target, built to run on 32-bit or 64-bit Windows and generate binaries for
32-bit or 64-bit Windows.
This is also the compiler I used for Manolo's recommendation when I attempted to compile wxWidgits 3.0.4
Last edited by spflanze on Thu May 02, 2019 1:32 am, edited 1 time in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets Compile Options

Post by ONEEYEMAN »

Hi,
As a test can you do this:

Code: Select all

cd c:\wxWidgets-3.0.4\samples\minimal
mingw32-make -f Makefile.gcc BUILD=Debug
minimal
Tell us if there will be any errors or whether you will get a nice window with the title "wxWidgets Minimal sample".

Thank you.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: wxWidgets Compile Options

Post by Manolo »

I never said I prefer MSYS to "normal" mingw environment. In fact, next I tell the steps to go:

1) Have a Mingw compiler downloaded and installed. Let's say you use mingw-64 or TDM. For example you have now this folder: C:\Mingw64\bin
2) Delete any previous leftovers related to wxWidgets, included PATH or WXWIN OS's vars.
3) Download the wx version sources you like from https://www.wxwidgets.org/downloads/ Please, take care of only download sources, as specific versions (gcc, vc) will include already compiled binaries which likely are not compatible with your current compiler (a matter of versions). For example, the file wxWidgets-3.0.4.7z (or .zip) will give you only sources.
4) Unzip that wx file to some directory, for example "C:\wx304"

5) Open a shell window ( "command window", "command prompt", PowerShell, whatever name you are used to)
6) Navigate (using "cd" command) to the wxWidgets dir you unziped the downloaded file (to C:\wx304 in our example)
7) Change the current directoy:

Code: Select all

cd build\msw
8)Tell Windows where to find the compiler while this command window is opened.

Code: Select all

PATH=%PATH%;C:\Mingw64\bin
It will not stay after the window is closed. If you want it to stay even after a PC reboot then change PATH var at Windows Configuration.

9) Build wxWidgets with the options you wish. For a "debug, static" building then use the command Oneeyeman gave you:

Code: Select all

mingw32-make -f makefile.gcc BUILD=debug
If you wish to see the full log in a file (lets name it "debugbuiltlog.txt" (as opposite to quick-lost info in the command window) then use this command insteas of the previous:

Code: Select all

mingw32-make -f makefile.gcc BUILD=debug > debugbuiltlog.txt > 2&1
10)After some time (half an hour?) you can take a look at the folder "C:\wx304\lib" (or lib subdir of your wx unzip choice). Find the ".a" files you need to add to your own app.

While there are many sites on Internet to search for wxWidgets info (or download wx files) I advise to trust only in the official ones, those you can arrive from wxWidgets.org, like this forum itself.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: wxWidgets Compile Options

Post by Manolo »

Now you have succesfully built wxWidgets, next is the C::B thing. This forum is for wxWidgets, Code::Blocks has its own forum. Despite of it, I write here some quick clues.

First, the compiler you use in C::B must be the same as the one use for wx building. If not, "undefined reference" errors will raise continously.
C::B detecs the compiler. But it may get confused if you have several compilers (or several versions) installed at once. While you can deal with several compilers by adding them to C::B, at recommend to start using only one compiler (remove tbe rest from your PC so C::B doesn't find them).

Next, the template "wxWidgets project" may be confused also, specially if you use some directory names of your own.
You must assure some matters. Go to "Project build options", and:
** "Compiler settings, #defines" tag contains __WXMSW__
** "Linker settings" has the wx .a files you use and a lot of Windows libs (kernel32, user32, gdi32, etc)
** "Search directories" contains the paths to yourwxdir\include,and yourwxdir\lib\gcc_lib and yourwxdir\lib\...\mswwud or similar names. Pay attention to complier searchs for ".h" files while linker searches for ".a" files

If you have in C::B several project targets (debug, release, etc) some settings are common for all targets, while other settings are target-dependant.
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxWidgets Compile Options

Post by spflanze »

ONEEYEMAN wrote: Wed Apr 03, 2019 2:41 pm Hi,
As a test can you do this:

Code: Select all

cd c:\wxWidgets-3.0.4\samples\minimal
mingw32-make -f Makefile.gcc BUILD=Debug
minimal
Tell us if there will be any errors or whether you will get a nice window with the title "wxWidgets Minimal sample".

Thank you.
This action created this file:
C:\wxWidgets-3.0.4\samples\minimal\gcc_mswu\minimal.exe
When that file is run a window opens with the title: "Minimal wxWidgets App"
and in the window there is the message: "Welcome to wxWidgets".

The Code::Blocks build log for the Wizard created starter project that does not compile can be downloaded from: http://www.mediafire.com/folder/ptl7p42 ... aav/shared . In this log I see that it used the x86_64-w64-mingw32-g++.exe compiler. Is this the right one? This compiler resides in the C:\TDM-GCC-64\bin directory where the other choices I see are:

x86_64-w64-mingw32-c++.exe
x86_64-w64-mingw32-gcc.exe
x86_64-w64-mingw32-gcc-5.1.0.exe
x86_64-w64-mingw32-gcc-ar.exe
x86_64-w64-mingw32-gcc-nm.exe
x86_64-w64-mingw32-gcc-ranlib.exe
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets Compile Options

Post by ONEEYEMAN »

Hi,
Apparently you have a lot of different comppilers installed in the same place.
If you can try to un-install ALL those compilers and install only one (from Manolo's list): MinGW, TDM-GCC or MinGW64, then re-build wxWidgets with this compiler and then build C::B project with this compiler it should build and run correctly.
Or what you can do is to ask C::B to properly identify the compiler you need to use. However, how to do that I don't know as I don't use C::B IDE.

But the proof that everything is built correctly is in the minimal.exe being built and run successfully.
Now you just need to find the proper compiler for C::B.

Thank you.
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxWidgets Compile Options

Post by spflanze »

How can I identify which compiler built minimal.exe?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets Compile Options

Post by ONEEYEMAN »

Hi,
Can you try

Code: Select all

mingw32-make --version
or maybe just

Code: Select all

mingw32-make
This should give you the version.

And then you will need to un-install all other compilers and leave one that will be used.

Thank you.
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxWidgets Compile Options

Post by spflanze »

The result of that command:

Code: Select all

C:\wxWidgets-3.0.4\build\msw>mingw32-make --version
GNU Make 3.82.90
Built for i686-pc-mingw32
If "i686-pc-mingw32" is what created minimal.exe it would have to be already installed of course, but I cannot find it. A disk wide search for filenames containing "i686-pc-mingw32" did not get any hits. Also, I do not see anything like it in the selection box where the compiler is selected in Code::Blocks at Settings => Global Compiler Settings => Compiler => Selected compiler . Where would this compiler be?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets Compile Options

Post by ONEEYEMAN »

Hi,
Can you check the $PATH variable?

You can check it in the Terminal by just typing:

Code: Select all

set
and then search for $PATH variable, or just search for it on the "My Computer" options.

Thank you.
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxWidgets Compile Options

Post by spflanze »

The $PATH system variable has more information than I am comfortable posting here. So I have put the set command's output in a file that can be downloaded here:
http://www.mediafire.com/file/d325o7v1r ... t.txt/file
I will remove it when it has served its purpose in this thread.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxWidgets Compile Options

Post by ONEEYEMAN »

Hi,
It looks like you have TDM-GCC installed and nothing else:

Code: Select all

C:\TDM-GCC-64\bin;
in the $PATH variable.

And so in this directory "mingw32-make" is located and this what C::B should be used.

Just for curiosity, do this:

Code: Select all

cd c:\wxWidgets-3.0.4\samples\minimal
mingw32-make -f Makefile.gcc clean
mingw32-make -f Makefile.gcc  BUILD=Debug
Make a not of what command that is used to compile the sample.
Next try to build the project inside the C::B.

Now try to compare the commands used for compilation.

Are they different?

Thank you.

P.S.: Now the fact that you are able to build minimal sample says that the library was build successfully. It is now the issue with setting up the C::B IDE.
spflanze
Earned some good credits
Earned some good credits
Posts: 130
Joined: Tue Feb 15, 2011 10:02 pm

Re: wxWidgets Compile Options

Post by spflanze »

This is what happened:

Code: Select all

cd c:\wxWidgets-3.0.4\samples\minimal

c:\wxWidgets-3.0.4\samples\minimal>mingw32-make -f Makefile.gcc clean
if exist gcc_mswud\*.o del gcc_mswud\*.o
if exist gcc_mswud\*.d del gcc_mswud\*.d
if exist gcc_mswud\minimal.exe del gcc_mswud\minimal.exe

c:\wxWidgets-3.0.4\samples\minimal>mingw32-make -f Makefile.gcc  BUILD=Debug
mingw32-make: Nothing to be done for 'all'.
There was nothing to be done because the "mingw32-make -f Makefile.gcc clean" command failed to delete these files:

minimal.exe
minimal_minimal.o
minimal_minimal.o.d
minimal_sample_rc.o

that were in the directory:
C:\wxWidgets-3.0.4\samples\minimal\gcc_mswu
When I deleted these files using the MS Windows Explorer and executed this command: "mingw32-make -f Makefile.gcc BUILD=Debug" again, the minimal project was compiled. New versions of the above file appeared in the "C:\wxWidgets-3.0.4\samples\minimal\gcc_mswu" directory. The file minimal.exe did execute as expected. During the mininal project's compilation the above make command produced many lines of output. The final line was:

Code: Select all

g++ -o gcc_mswu\minimal.exe gcc_mswu\minimal_sample_rc.o gcc_mswu\minimal
l.o   -mthreads -L.\..\..\lib\gcc_lib -Wl,--subsystem,windows -mwindows
sw30u_core  -lwxbase30u    -lwxtiff -lwxjpeg -lwxpng   -lwxzlib -lwxregex
xpat    -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell
mctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lwininet
The result of the "mingw32-make --version" command is still:

Code: Select all

GNU Make 3.82.90
Built for i686-pc-mingw32
It appears "built for" did not mean what I thought it meant. It is not the compiler. It shows the machine and environment specification. The compiler is actually g++.

When I compile the Code::Blocks wizzard created starter project, these are the first few lines I see in the Build Log tab:

Code: Select all

-------------- Build: Release in Test Project (compiler: TDM-GCC-64)---------------

[100.0%] x86_64-w64-mingw32-g++.exe -LC:\wxWidgets-3.0.4\lib\gcc_lib -o "bin\Release\Test Project.exe"  obj\Release\Test_ProjectApp.o obj\Release\Test_ProjectMain.o obj\Release\resource.res -s -mthreads -m64  -lwxmsw30u_core -lwxbase30u -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32
C:\wxWidgets-3.0.4\lib\gcc_lib/libwxmsw30u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x592): undefined reference to `jpeg_std_error'
C:\wxWidgets-3.0.4\lib\gcc_lib/libwxmsw30u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x76a): undefined reference to `jpeg_destroy_decompress'
C:\wxWidgets-3.0.4\lib\gcc_lib/libwxmsw30u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0x7aa): undefined reference to `jpeg_CreateDecompress'
This shows the compiler used is "x86_64-w64-mingw32-g++.exe" . To make Code::Blocks use the same g++ compiler that compiled the test project I navigated to:

Settings => Compiler => Global compiler settings => Toochain executables (tab) => Program Files

In this tab I saw these settings:

Code: Select all

Compiler's installation directory: C:\TDM-GCC-64
C compiler: x86_64-w64-mingw32-gcc.exe
C++ compiler: x86_64-w64-mingw32-g++.exe
Linker for dynamic libs: x86_64-w64-mingw32-g++.exe
Linker for static libs: x86_64-w64-mingw32-gcc-ar.exe
Debugger: GDB/CDB debugger : TDM-GCC-64
Resource: windres.exe
Make: mingw32-make.exe
I made these changes:

Code: Select all

C compiler: g++.exe
C++ compiler: g++.exe
Linker for dynamic libs: g++.exe
Linker for static libs:  g++-ar.exe
When I attempted to compile I still got the same linker errors. So I navigated to:

Project => Build options

In the tree in the left pane I highlighted the project name, selected the Linker settings tab, and in the "Link libraries" field I added:

Code: Select all

libwxjpeg.a
libwxtiff.a
This solved the linker errors. The Code::Blocks Wizzard generated starter project compiled and ran.
Post Reply