Strange jump executing get_accName. (but it works fine in MS VC++ and MinGW/Upp and mingw win32 app)

Pages: 12
Jan 5, 2014 at 7:18pm
Hi all

I have this code in a button pressed event:
1
2
3
4
5
6
7
8
9
10
11
12
13
IAccessible* accessibleFrame = NULL;
if (S_OK != AccessibleObjectFromWindow((HWND)GetHWND(),OBJID_CLIENT,IID_IAccessible, (void**) & accessibleFrame))
{
     return;
}
VARIANT varID;
varID.lVal = CHILDID_SELF;
varID.vt = VT_I4;

BSTR MyBstr = L"Just to init it                                                ";
HRESULT hr = accessibleFrame->get_accName(varID, &MyBstr);

wxMessageBox("Done", "Done", wxYES_NO | wxCANCEL, this);


When I debug it, step by step, everything works fine until get_accName instruction line. When this instruction is executed, the execution stream jumps to appbase.cpp ti the followinf method:

1
2
3
4
5
6
7
#if wxUSE_EXCEPTIONS
Void wxAppConsoleBase::HandleEvent(wxEvtHandler *handler,
                              wxEventFunction func,
                              wxEvent& event) const
{
// by default, simply call the handler
 (handler->*func)(event);



If I continue to press F7, the execution stream jumps again to get_accName and then again to HandleEvent(). What is happening?

If I press shift+F7 in the get_accName call, the flow jumps to HandleEvent in the same way. Is there any way to step into get_accName?

Can not understand what is going on. the execution stream never reachs wxMessageBox()

I also surrounded get_accName like this:
1
2
3
4
5
6
7
8
try
    {
        HRESULT hr = accessibleFrame->get_accName(varID, &MyBstr);
    }
    catch(char* strg)
    {
        wxMessageBox("Hello", "Hello", wxYES_NO | wxCANCEL, this);
    }

but catch is never called either…

Any help would be very appreciated


I tested this code in MS VC++ and it runs well...

Alex

Env: codeblocks, mingw, win7, WxSmith and DEBUG configuration
This code works fine when I use ms vc++ (using MS compiler), when I use Mingw and Ultima++ and when I use the same codeblocks and mingw with a win32 app

Is it WxWidgets the main problem?
Last edited on Jan 6, 2014 at 1:01pm
Jan 6, 2014 at 1:05pm
Try it with minGW-w64from here:
http://tdragon.net/recentgcc/

You need to recompile all libraries and add -m32 to compiler and linker flags if you want to build for X86.
Jan 6, 2014 at 5:14pm
which \bin folder sloud I use in codeblocks? There is 2 folders containning compiler tools... I am confused... :-(
Jan 6, 2014 at 5:49pm
C:\TDM-GCC-64 if you used default install path. Code::Blocks should autodetect it anyway.
Jan 6, 2014 at 6:43pm
Now, when I compile something (simple) it says:

ld.exe||cannot find -lwxmsw30u|

in both release and debug configuration :-(

I searched and I found only:
wxmsw30ud_gl_gcc_custom.dll
wxmsw30ud_gcc_custom.dll
wxmsw30u_gl_gcc_custom.dll
wxmsw30u_gcc_custom.dll
( compiled with previous mingw/codeblocks verion)

I did not compiled Wxwidgets with this new minggw. should I?

Alex

Jan 6, 2014 at 7:39pm
Yes, all libraries must be compiled using the same compiler and same compiler options. Beware that for compiling wxwidgets as X86 you must also specify -m32 as CFLAGS, CXXFLAGS and LDFLAGS if you use the makefile.gcc.
Jan 6, 2014 at 11:50pm
Error while cmpilling wxwidgets...


C:\wxWidgets-3.0.0\build\msw>mingw32-make.exe -f makefile.g
cc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CFLAGS="-m32" CXXFLAGS="-m32" L
DFLAGS="-m32"

...
gw32/bin/ld.exe: i386:x86-64 architecture of input file `gcc_mswudll\monodll_ver
sion_rc.o' is incompatible with i386 output
collect2.exe: error: ld returned 1 exit status
makefile.gcc:5202: recipe for target '..\..\lib\gcc_dll\wxmsw30u_gcc_custom.dll'
failed
mingw32-make.exe: *** [..\..\lib\gcc_dll\wxmsw30u_gcc_custom.dll] Error 1


Alex
Jan 8, 2014 at 6:44am
Yes, I forgot about that ...

You need to invoke windres using windres -F pe-i386 while compiling for X86 either by pathching the makefile or just just replace windres.exe with the one from minGW-32 (the old one that came with codeblocks). It could be possible to set RCFLAGS too, but I haven't tested this.

This trick is also required while compiling your application if you use any resource file.


Read build\msw\config.gcc, at the end it says:

# Windows resource compiler to use, possibly including extra options.
# For example, add "-F pe-i386" here if using 64 bit windres for 32 bit build.
WINDRES ?= windres --use-temp-file
Last edited on Jan 8, 2014 at 6:49am
Jan 8, 2014 at 10:37am
I replaced the file and executed the same command and now I got:


c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-min
gw32/bin/ld.exe: i386:x86-64 architecture of input file `gcc_mswuddll\monodll_ve
rsion_rc.o' is incompatible with i386 output
collect2.exe: error: ld returned 1 exit status
makefile.gcc:5202: recipe for target '..\..\lib\gcc_dll\wxmsw30ud_gcc_custom.dll
' failed
mingw32-make.exe: *** [..\..\lib\gcc_dll\wxmsw30ud_gcc_custom.dll] Error 1

:-( Sorry all these messages but I can not solve this alone...

Alex
Jan 8, 2014 at 2:35pm
Do a makefile clean and rebuild.
As for replacing, is not a very good idea after all, adding WINDRES="windres --use-temp-file -F pe-i386" to build command will do the trick.

However, this is not your problem, as you replaced the file, do a cleanup and rebuild.

I just tested this without replacing windres.exe and it worked.
Last edited on Jan 8, 2014 at 2:35pm
Jan 8, 2014 at 2:51pm
C:\wxWidgets-3.0.0\build\msw>mingw32-make.exe -f makefile.gcc clean

C:\wxWidgets-3.0.0\build\msw>mingw32-make.exe -f makefile.g
cc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CFLAGS="-m32" CXXFLAGS="-m32" L
DFLAGS="-m32"



c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-min
gw32/bin/ld.exe: i386:x86-64 architecture of input file `gcc_mswuddll\monodll_ve
rsion_rc.o' is incompatible with i386 output
collect2.exe: error: ld returned 1 exit status
makefile.gcc:5202: recipe for target '..\..\lib\gcc_dll\wxmsw30ud_gcc_custom.dll
' failed
mingw32-make.exe: *** [..\..\lib\gcc_dll\wxmsw30ud_gcc_custom.dll] Error 1

So, I am trying now not to overwrite that file.



Modoran, do you mean simple execute this:


C:\wxWidgets-3.0.0\build\msw>mingw32-make.exe -f makefile.g
cc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32" WINDRES="windres --use-temp-file -F pe-i386"

This returns an error too...




Where to put WINDRES="windres --use-temp-file -F pe-i386" ?
Last edited on Jan 8, 2014 at 2:57pm
Jan 8, 2014 at 5:04pm
Run EXACTLY this command-line while in build/msw:

mingw32-make.exe -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32" WINDRES="windres --use-temp-file -F pe-i386"


Replacing original windres.exe is NOT required, I used untouched Mingw-w64 installation and it just worked.

Folders lib/gcc_dll and build/msw/gcc_mswudll should NOT exists upon mingw32-make -f makefile.gcc clean.


You could also add CFG=mynewfolderhere if you want to build in another folder.
Last edited on Jan 8, 2014 at 5:08pm
Jan 8, 2014 at 7:16pm
Great! WxWidgets compile now with success....
By the way, if in the future I will need to compile it in 64 bit format which commandline options should I changed?

Thanks a lot Modoran!!

Alex
Last edited on Jan 8, 2014 at 7:19pm
Jan 8, 2014 at 7:51pm
To compile for 64 bit just remove -m32 switch AND you must use original windres.exe that came with MinGw-w64 (wxwidgets will compile with it using command line I give it to you).

Also -F pe-i386 is NOT required for windres when compiling for X64.


Alternatively, use -m64 instead of -m32 and -F pe-x86-64, but again, this is the default anyway.
Last edited on Jan 8, 2014 at 7:53pm
Jan 8, 2014 at 11:39pm
Returning to the first message one application (WxWidgets, dialog), now, when I compile that application I see:


ld.exe cannot find -lwxmsw30ud


I compiled WxWidgets with SHARED=1 and SHARED=0 both for RELEASE and DEbUG

That lib exists:

libwxmsw30ud.a and libwxmsw30u.a in C:\wxWidgets-3.0.0\lib\gcc_dll. this path is configured in "search directories | linker" but it seems that it is not found

Alex
Last edited on Jan 9, 2014 at 12:00am
Jan 9, 2014 at 8:50am
Enable "full command line logging" on codeblocks settings to see what exactly it does.

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29

As far as I know, GNU ld linker will throw that error too if you pass a static library instead of a dynamic one (yes, I know is misleading).
Last edited on Jan 9, 2014 at 8:53am
Jan 9, 2014 at 10:38am
I tried to understand and fix that but did not foound how to...

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

windres.exe -IC:\wxWidgets-3.0.0\include -IC:\wxWidgets-3.0.0\lib\gcc_dll\mswud -J rc -O coff -i C:\YYYYYY~1\resource.rc -o obj\Debug\resource.res
x86_64-w64-mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\wxWidgets-3.0.0\include -IC:\wxWidgets-3.0.0\lib\gcc_dll\mswud -c C:\yyyyyyyyyyyyy\yyyyyyyyyyyyyApp.cpp -o obj\Debug\yyyyyyyyyyyyyApp.o
x86_64-w64-mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Wall -g -D__WXDEBUG__ -IC:\wxWidgets-3.0.0\include -IC:\wxWidgets-3.0.0\lib\gcc_dll\mswud -c C:\yyyyyyyyyyyyy\yyyyyyyyyyyyyMain.cpp -o obj\Debug\yyyyyyyyyyyyyMain.o
x86_64-w64-mingw32-g++.exe -LC:\wxWidgets-3.0.0\lib\gcc_dll -o bin\Debug\yyyyyyyyyyyyy.exe obj\Debug\yyyyyyyyyyyyyApp.o obj\Debug\yyyyyyyyyyyyyMain.o obj\Debug\resource.res -mthreads -lwxmsw30ud -mwindows
c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\wxWidgets-3.0.0\lib\gcc_dll/libwxmsw30ud.a when searching for -lwxmsw30ud
c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\wxWidgets-3.0.0\lib\gcc_dll\libwxmsw30ud.a when searching for -lwxmsw30ud
c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:\wxWidgets-3.0.0\lib\gcc_dll/libwxmsw30ud.a when searching for -lwxmsw30ud
c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lwxmsw30ud
collect2.exe: error: ld returned 1 exit status


Jan 9, 2014 at 1:31pm
Well, you are trying to compile a X64 application using X86 version of wxWidgets.

Pass -m32 as compiler and linker flags too. This switch is required for every library that you use, not only for wxWidgets.


Also, it is original windres.exe ? Because if you did not add -F pe-i386 you will get an error, see:
windres.exe -IC:\wxWidgets-3.0.0\include -IC:\wxWidgets-3.0.0\lib\gcc_dll\mswud -J rc -O coff -i C:\YYYYYY~1\resource.rc -o obj\Debug\resource.res


You must read:
windres.exe -IC:\wxWidgets-3.0.0\include -IC:\wxWidgets-3.0.0\lib\gcc_dll\mswud -J rc -O coff -F pe-i386 -i C:\YYYYYY~1\resource.rc -o obj\Debug\resource.res
Last edited on Jan 9, 2014 at 1:33pm
Jan 9, 2014 at 2:21pm
Sorry, i can not find window in codeblocks where to specify that flag...

It seems that using a 64 bit compiler brings confusion to me (beginner on these tools) but it seems also that traditional 32 bit compiler does not executes get_accName() method in good conditions...

:-(

Jan 9, 2014 at 2:26pm
project -> build options -> compiler settings -> other options
project -> build options -> linker settings -> other linker options
Pages: 12