Helloworld MinGW32 GCC Compiler Errors

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.
chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Tue Apr 19, 2016 2:26 am

Hi
re http://docs.wxwidgets.org/stable/overvi ... world.html

Have others been able to compile this using latest wxWdidgets 3.1.0 , under MinGW32 gcc ?
(In the CodeBlocks.org C/C++ IDE)

I'm seeing a number of function header differences and omissions, which may be due to them being
superseded by newer versions of the functions in 3.1.0 ? Is there a latest version of helloworld.cpp
somewhere ? It's vitally important for learning how to begin wxWidgets programming.

Ta

User avatar
xaviou
Super wx Problem Solver
Super wx Problem Solver
Posts: 430
Joined: Mon Aug 21, 2006 3:18 pm
Location: Annecy - France
Contact:

Re: Helloworld MinGW32 GCC Compiler Errors

Post by xaviou » Tue Apr 19, 2016 11:02 am

Hi.

The sample code is up to date : I've just copied/pasted the whole code in a simple wxWidgets project, and it works fine (see attached screenshot).

What are the problems you're seeing ?

Regards
Xav'
Attachments
ScreenShot.png
ScreenShot.png (56.26 KiB) Viewed 7919 times
My wxWidgets stuff web page : [email protected]'s wxStuff

User avatar
doublemax
Moderator
Moderator
Posts: 15260
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Helloworld MinGW32 GCC Compiler Errors

Post by doublemax » Tue Apr 19, 2016 1:50 pm

Which GCC version are you using? The newest ones often create problem with wxWidgets.

Please post exact compiler/linker errors.
Use the source, Luke!

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Tue Apr 19, 2016 10:00 pm

Good to hear that some gcc compiler and command line works, I wonder what they are ?

I'm trying to use the latest Codeblocks IDE with the mingw32 included -> codeblocks-16.01mingw-setup.exe
Codeblocks is quite a nice IDE so it would be great if we can get it to work with wxWidget & helloworld.cpp.
I'm hoping to build a Windows 32 bit app so it can be used on the large number of Windows PCs (though
my PC is 64 bit Windows 8.1)

I also have mingw-w64 installed but I don't think Codeblocks sees that version of gcc, having it's own
mingw32 setup apparently?

WXWIN is set to E:\wx , but i've found it necessary to duplicate wx directory contents in the helloworld source directory.
Codeblocks Compiler & Linker settings are per Codeblocks instructions -> $(#wx.lib)\gcc_dll\mswu


||=== Build: Debug in Factors (compiler: GNU GCC Compiler) ===|
\wx\longlong.h|45|warning: #warning "Your compiler does not appear to support 64 bit " "integers, using emulation class instead.\n" "Please report your compiler version to " "[email protected]!" [-Wcpp]|
\wx\longlong.h|782|error: 'wxString' does not name a type|
\wx\longlong.h|792|error: 'wxString' does not name a type|
\wx\longlong.h||In member function 'long int wxLongLongWx::ToLong() const':|
\wx\longlong.h|685|error: 'wxT' was not declared in this scope|
\wx\longlong.h|685|error: 'wxASSERT_MSG' was not declared in this scope|
\wx\longlong.h|998|error: 'wxString' does not name a type|
\wx\longlong.h|1008|error: 'wxString' does not name a type|
\wx\longlong.h||In constructor 'wxULongLongWx::wxULongLongWx(wxLongLongWx)':|
\wx\longlong.h|853|error: 'wxASSERT' was not declared in this scope|
\wx\longlong.h||In member function 'long unsigned int wxULongLongWx::ToULong() const':|
\wx\longlong.h|910|error: 'wxT' was not declared in this scope|
\wx\longlong.h|910|error: 'wxASSERT_MSG' was not declared in this scope|
\wx\longlong.h||In function 'wxLongLong operator-(long unsigned int, const wxULongLong&)':|
\wx\longlong.h|1064|error: 'wxInt32' was not declared in this scope|
\wx\buffer.h|81|error: 'wxNO_LEN' was not declared in this scope|
\wx\buffer.h|96|error: 'wxNO_LEN' was not declared in this scope|
\wx\buffer.h|83|error: 'wxNO_LEN' was not declared in this scope|
\wx\buffer.h|98|error: 'wxNO_LEN' was not declared in this scope|
\wx\buffer.h||In member function 'wxScopedCharTypeBuffer<T>::CharType* wxScopedCharTypeBuffer<T>::release() const':|
\wx\buffer.h|138|error: there are no arguments to 'wxT' that depend on a template parameter, so a declaration of 'wxT' must be available [-fpermissive]|
\wx\buffer.h|138|note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)|
\wx\buffer.h|139|error: there are no arguments to 'wxT' that depend on a template parameter, so a declaration of 'wxT' must be available [-fpermissive]|
\wx\buffer.h|255|error: 'wxNO_LEN' was not declared in this scope|
\wx\buffer.h||In constructor 'wxCharTypeBuffer<T>::wxCharTypeBuffer(const CharType*, size_t)':|
\wx\buffer.h|259|error: 'wxNO_LEN' was not declared in this scope|
\wx\buffer.h||In constructor 'wxCharBuffer::wxCharBuffer(const CharType*)':|
\wx\buffer.h|368|error: call to 'wxCharTypeBuffer<T>::wxCharTypeBuffer(const CharType*, size_t) [with T = char; wxCharTypeBuffer<T>::CharType = char; size_t = unsigned int]' uses the default argument for parameter 2, which is not yet defined|
\wx\buffer.h||In constructor 'wxWCharBuffer::wxWCharBuffer(const CharType*)':|
\wx\buffer.h|385|error: call to 'wxCharTypeBuffer<T>::wxCharTypeBuffer(const CharType*, size_t) [with T = wchar_t; wxCharTypeBuffer<T>::CharType = wchar_t; size_t = unsigned int]' uses the default argument for parameter 2, which is not yet defined|
\wx\buffer.h||In member function 'void* wxMemoryBufferData::release()':|
\wx\buffer.h|489|error: 'wxASSERT_MSG' was not declared in this scope|
\wx\buffer.h||In member function 'void wxMemoryBuffer::SetDataLen(size_t)':|
\wx\buffer.h|558|error: 'wxASSERT' was not declared in this scope|
\wx\buffer.h||In member function 'void wxMemoryBuffer::AppendByte(char)':|
\wx\buffer.h|590|error: 'wxT' was not declared in this scope|
\wx\buffer.h|590|error: 'wxCHECK_RET' was not declared in this scope|
\wx\buffer.h||In member function 'void wxMemoryBuffer::AppendData(const void*, size_t)':|
\wx\buffer.h|599|error: 'memcpy' was not declared in this scope|
\wx\strconv.h|68|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|71|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|252|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|254|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|339|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|341|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|365|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|367|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|408|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|410|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|422|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|424|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|454|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|456|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|468|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|470|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|494|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|496|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|564|error: 'wxNO_LEN' was not declared in this scope|
\wx\strconv.h|572|error: 'wxNO_LEN' was not declared in this scope|
\wx\stringimpl.h|44|error: 'wxChar' does not name a type|
\wx\dlimpexp.h|111|note: in definition of macro 'WXDLLIMPEXP_DATA_BASE'|
\wx\msgout.h|41|error: 'Printf' has not been declared|
\wx\msgout.h|41|error: expected identifier before numeric constant|
\wx\msgout.h|41|error: expected ',' or '...' before numeric constant|
\wx\msgout.h|42|error: expected ';' at end of member declaration|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 1 warning(s) (0 minute(s), 30 second(s)) ===|

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Tue Apr 19, 2016 10:19 pm

ps I've found the gcc version for codeblocks-16.01mingw-setup.exe :-
Release 16.01 rev 10702 (2016-01-25 19:50:14) gcc 4.9.2 Windows/unicode - 32 bit

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Wed Apr 20, 2016 3:39 am

I've now tried the helloworld.cpp wxWidgets compilation with a few MinGW versions, from version 3.4.5 to version mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin , and the default minGW32 (gcc 4.9.2 Windows/unicode - 32 bit) that comes with Codeblocks IDE, and they all cough up pretty much the same errors. It would be nice to hear of a MinGW version that is believed to work with WxWidgets 3.1.0 ? None of the older MinGW versions work so far as I can determine; but it could just be a pothole for WxWidgets Newbies or i may need earlier versions of both WxWidgets as well as MinGW g++. Bit of a worry for Wx 3.1.0 perhaps ?

User avatar
doublemax
Moderator
Moderator
Posts: 15260
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Helloworld MinGW32 GCC Compiler Errors

Post by doublemax » Wed Apr 20, 2016 5:32 am

I don't use MinGW myself, but i know that at least TDM-GCC 4.8.1 does work. But the kind of errors you getting is different, i think there is something wrong with include paths, preprocessor symbols etc.

Instead of building your own Helloworld, try to build both wxWidgets and the "minimal" sample that comes with it from the command line using the provided makefiles.
Use the source, Luke!

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 361
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Helloworld MinGW32 GCC Compiler Errors

Post by New Pagodi » Wed Apr 20, 2016 12:00 pm

Codeblocks does work, but you need to make sure it can find and libraries it needs.

First set the wx global variable if it's not already set. This has nothing to do with the hello world example, but do it anyway. From the menu select, Settings->Global variables... Then in the resulting popup, from Current Variables select wx. If wx does not appear in the combobox, hit the new button and create it. Make sure base points to the root of your wxwidgets installation.
01.png
01.png (7.95 KiB) Viewed 7859 times
Next, from the menu select File->New->Project. Select "wxWidgets project" in the dialog that pops up. This will start a wizard.

On the first page, just hit next.

On the second page, select the wxwidgets version. As of this writing, codeblocks doesn't have 3.1 available yet, so if you're using that select 3.0 and you'll have to change 1 thing later on.

On the third page, enter a name for the project such as "HelloWorld"

On the forth page, enter whatever you want (including nothing).

On the fifth page, enter whatever (for this example it doesn't matter)

On the sixth page, for wxWidgets' location enter "$(#wx)" (without the quotes). This is why the first thing we did was define the wx global variable.

On the seventh page, make sure compiler is set to "GNU GCC Compiler". If you built a debug version of the library, make sure "Create "Debug"" is checked. If you built a release version, make sure "Create "Release"" is checked. If you've built both, pick one or both.

The 8th page is the most important one:
02.png
02.png (3.72 KiB) Viewed 7859 times
  • If you built a shared version of the library (ie SHARED=1 was part of the command used to build the library) select "Use wxWidgets DLL". Otherwise, make sure that is unchecked.
  • If you built a monolithic version, make sure that is checked.
  • Check enable unicode. (For 3.0 and later, this shouldn't matter, but it doesn't hurt anything.)
  • Check create empty project.
  • For simplicity, uncheck "Create and use precompiled header"
If you're using 3.1, you may get some warnings about matching configurations. Just hit yes.

If you did not select monolithic, you'll get a 9th page. Just hit finish.

Now go to File->New->File... Select C/C++ source in the resulting popup. Click through the resulting wizard to add new file to the project. This will add a file to the project and open it for editing. Just paste the hello world example into it.

Until codeblocks updates to support 3.1, we need to make 1 final change if you're using that. From the menu select "Project->Build options". In the resulting popup, select linker settings. For a release,non-monolithic build you'll see something like this:
03.png
03.png (5.05 KiB) Viewed 7859 times
Change libwxmsw30u_core.a to libwxmsw31u_core.a and change libwxbase30u.a to libwxbase31u.a. Similar changes should be made for debug or monolithic builds.

Finally select Build->Build from the menu (or just hit the build button). When that finishes, select Build->Run (or hit the run button).

I hope that gets you started with code::blocks and wxWidgets.

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 361
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Helloworld MinGW32 GCC Compiler Errors

Post by New Pagodi » Wed Apr 20, 2016 1:31 pm

Here's a script replacement you can use in codeblocks to add 3.1 to the library version page until the wizard is officially updated.
wx.txt
(55.84 KiB) Downloaded 1255 times

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Wed Apr 20, 2016 9:48 pm

You're a champion, it looks good. Ta

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Thu Apr 21, 2016 10:04 am

re problem -- ld.exe||cannot find E:\wxWidgets-3.1.0/lib/gcc_dll/: Permission denied|
i've tried to use both backslash and forward slash but the same mix of both occurs either way in the ld.exe command line.
I don't have environment variable WXWIN set at the moment, but when it was it didn't seem needed or a problem.
Anyone have thoughts on why my lib path/s are a mix of backslash and forward slashes for the subdirectory ? Linking can't work while this occurs.
My Build options are setup correctly it seems, as seen here
Project build options.jpg
Project build options.jpg (36.4 KiB) Viewed 7812 times
and global variable seems ok
Global variables.jpg
Global variables.jpg (30.31 KiB) Viewed 7812 times
.

Ta.

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 361
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Helloworld MinGW32 GCC Compiler Errors

Post by New Pagodi » Thu Apr 21, 2016 2:37 pm

You don't need "$(#wx)\lib\gcc_dll\mswu" on the linker search path. That should be on the compiler search path.

Based on this thread, do you by any chance have folders listed under linker settings? Either in this project or in the global compiler options?

If not, can you have codeblocks show the full command line as described here and post your build log.

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Thu Apr 21, 2016 9:43 pm

Ta, the global Compiler options Linker settings did have the back slash set as forward slashes, and correcting this did fix the ld.exe command line.
But another related problem has occurred, i can't access the lib directory for linking, 'Permission denied' even though i have read&execute privileges under Windows 8.1 per the attachment :-
ld.exe||cannot find E:\wxWidgets-3.1.0\lib\gcc_dll: Permission denied|
Attachments
Priveleges.jpg
Priveleges.jpg (30.86 KiB) Viewed 7788 times

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Thu Apr 21, 2016 9:57 pm

-------------- Build: Debug in Helloworld (compiler: GNU GCC Compiler)---------------

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ E:\wxWidgets-3.1.0\lib\gcc_dll\mswu -IE:\wxWidgets-3.1.0\include -IE:\wxWidgets-3.1.0\lib\gcc_dll\mswud -IE:\wxWidgets-3.1.0 -IE:\Chris\Dev\Cpp\HelloWorld -c E:\Chris\Dev\Cpp\HelloWorld\HelloworldApp.cpp -o obj\Debug\HelloworldApp.o
g++.exe: warning: E:\wxWidgets-3.1.0\lib\gcc_dll\mswu: linker input file unused because linking not done
g++.exe -LE:\wxWidgets-3.1.0\lib\gcc_dll -LE:\wxWidgets-3.1.0\lib\gcc_dll\ -o bin\Debug\Helloworld.exe obj\Debug\HelloworldApp.o -mthreads -lwxmsw31ud E:\wxWidgets-3.1.0\lib\gcc_dll -mwindows
E:/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find E:\wxWidgets-3.1.0\lib\gcc_dll: Permission denied
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 2 second(s))
2 error(s), 1 warning(s) (0 minute(s), 2 second(s))

chrismac
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Apr 19, 2016 1:57 am

Re: Helloworld MinGW32 GCC Compiler Errors

Post by chrismac » Thu Apr 21, 2016 10:19 pm

Aha, changing Settings->Compiler->Linker settings search path to $(#wx)\lib\gcc_dll\*.* rather than $(#wx)\lib\gcc_dll fixes the Permission denied. But a related problem remains. I'm unclear how to similarly correct the search paths for the mswu & mswud subdirectories.
ld.exe||cannot find E:\wxWidgets-3.1.0\lib\gcc_dll\mswu: Permission denied|
ld.exe||cannot find E:\wxWidgets-3.1.0\lib\gcc_dll\mswud: Permission denied|
Looking quite hopeful of getting HelloworldApp.cpp going now, once linking is resolved.

Post Reply