wxQT branch patch to compile under Qt5, but problem to compile for Android

263 views
Skip to first unread message

Mariano Reingart

unread,
Mar 20, 2014, 9:12:59 AM3/20/14
to wx-dev
Dear devs:

For the GSOC 2014 proposal, I've working in a patch to run the current wxQT branch (2.9.2) under Qt 5.2.1.
This includes the PlatformInfo patch sent last year, and fixes some issues due deprecated features from Qt4 

* changed moc precompiler path (to use my qt5.2.1)
* updated configure.in to include Qt5* libs
* changed includes from QtGui/QPushButton to QtWidgets/QPushButton (warning: not allways)
* changed toAscii -> toLatin
* removed QApplication::GuiClient from QApplication() in main;
* etc

It can be compiled doing (in my machine, change paths!):

PKG_CONFIG_PATH=/home/reingart/qt/5.2.1/gcc_64/lib/pkgconfig/ 
../configure --with-qt --enable-debug --enable-utf8 --disable-dataviewctrl --without-regex --disable-treelist --disable-aui --disable-uiactionsim --disable-stc --disable-ribbon --disable-propgrid --disable-aui


Attached is an screenshot (minimal sample)

So far, it works as expected like the Qt4.8 version.

When trying to cross-compile it for Android (arm-linux-androideabi), it raises the following error:

../include/wx/wxcrtbase.h:758:68: error: 'wcsdup' was not declared in this scope
../include/wx/wxcrt.h:325:47: error: 'wcscasecmp' was not declared in this scope
...

Attached is the full log with the details

I cannot figure out why, I've readed several sites without a clear answer.

Can you tell me what I'm doing wrong?

NOTE: I could compile and package (.apk) a minimal example for Android, and wxWidgets should be using the same executables / paths / etc. than the Makefile generated by qmake

Comments are welcome!

Best regards,
wxQT_android_cross_compile_wchar.txt
gsoc2014_wxqt521.png

Vadim Zeitlin

unread,
Mar 20, 2014, 9:44:49 AM3/20/14
to wx-...@googlegroups.com
On Thu, 20 Mar 2014 10:12:59 -0300 Mariano Reingart wrote:

MR> For the GSOC 2014 proposal, I've working in a patch to run the current wxQT
MR> branch (2.9.2) under Qt 5.2.1.

Thanks!

MR> * changed moc precompiler path (to use my qt5.2.1)

This seems unnecessary, you can just set your PATH to include this
directory in front of it.

MR> * updated configure.in to include Qt5* libs
MR> * changed includes from QtGui/QPushButton to QtWidgets/QPushButton
MR> (warning: not allways)
MR> * changed toAscii -> toLatin
MR> * removed QApplication::GuiClient from QApplication() in main;
MR> * etc

There are a lot of changes to just the RCS-ID line, I wonder if we could
filter them out somehow? Also, there are some EOL changes (e.g. in
include/wx/qt/calctrl.h) which distract from the real changes...

MR> The patch:
MR>
MR> https://dl.dropboxusercontent.com/u/75600582/wxQT_5_2_1.patch

Do I understand correctly that this should be applied to wxQT branch?

MR> When trying to cross-compile it for Android (arm-linux-androideabi), it
MR> raises the following error:
MR>
MR> ../include/wx/wxcrtbase.h:758:68: error: 'wcsdup' was not declared in this
MR> scope

AFAIR Android didn't have wchar_t support at all until relatively
recently. But I think it is supposed to have it now... So perhaps it's just
a matter of using a newer SDK? In any case, it looks like configure wrongly
detected wcsdup() availability, you'd need to look at config.log to see
what happened when testing for it and why was it found even though it
doesn't seem to be there.

Regards,
VZ

Mariano Reingart

unread,
Mar 20, 2014, 2:19:03 PM3/20/14
to wx-dev
On Thu, Mar 20, 2014 at 10:44 AM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Thu, 20 Mar 2014 10:12:59 -0300 Mariano Reingart wrote:

MR> For the GSOC 2014 proposal, I've working in a patch to run the current wxQT
MR> branch (2.9.2) under Qt 5.2.1.

 Thanks!

MR> * changed moc precompiler path (to use my qt5.2.1)

 This seems unnecessary, you can just set your PATH to include this
directory in front of it.


Ok, I wanted to be sure, I have currently three versions of qt (4.8, 5.0 -packaged by ubuntu- and 5.2, installed as a third party folder)
I'ld see if there is a more polished to do that.
 
MR> * updated configure.in to include Qt5* libs
MR> * changed includes from QtGui/QPushButton to QtWidgets/QPushButton
MR> (warning: not allways)
MR> * changed toAscii -> toLatin
MR> * removed QApplication::GuiClient from QApplication() in main;
MR> * etc

 There are a lot of changes to just the RCS-ID line, I wonder if we could
filter them out somehow? Also, there are some EOL changes (e.g. in
include/wx/qt/calctrl.h) which distract from the real changes...


Yes, I saw them, maybe I'm omitting some setting at the svn level
About the EOL, I just edited the files, but it seems gedit has changed the file beyond my modifications.
Do you have a guide or something similar about this two?
(and IDE that you can recomend and is not too cumbersone)
Next time I'll try this:

I'm setting up hg-git so I could a fine grainded local commits in a easier way.
 
MR> The patch:
MR>
MR> https://dl.dropboxusercontent.com/u/75600582/wxQT_5_2_1.patch

 Do I understand correctly that this should be applied to wxQT branch?
 
Yes:

reingart@s5ultra:~/src/wxQT$ LANG=C svn info
Path: .
Working Copy Root Path: /home/reingart/src/wxQT
Repository UUID: c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
Revision: 74593
Node Kind: directory
Schedule: normal
Last Changed Author: PMO
Last Changed Rev: 67976
Last Changed Date: 2011-06-18 09:03:50 -0300
 
MR> When trying to cross-compile it for Android (arm-linux-androideabi), it
MR> raises the following error:
MR>
MR> ../include/wx/wxcrtbase.h:758:68: error: 'wcsdup' was not declared in this
MR> scope

 AFAIR Android didn't have wchar_t support at all until relatively
recently. But I think it is supposed to have it now... So perhaps it's just
a matter of using a newer SDK? In any case, it looks like configure wrongly
detected wcsdup() availability, you'd need to look at config.log to see
what happened when testing for it and why was it found even though it
doesn't seem to be there.

I'm using the latest SDK (android-sdk_r22.6-linux.tgz) and NDK (android-ndk-r9d-linux-x86_64.tar.bz2), so it should updated.
As system root I'm using android-9/arch-amd (to be sure I passed it as --sysroot)

According to the NDK, wchar should be supported (at least support that functions if I understand it correctly, see see docs/STANDALONE-TOOLCHAIN.html):

---

7.2/ wchar_t support:

As documented, the Android platform did not really support wchar_t until Android 2.3. What this means in practical terms is that:

If you target platform android-9 or higher, the size of wchar_t is 4 bytes, and most wide-char functions are available in the C library (with the exception of multi-byte encoding/decoding functions and wsprintf/wsscanf).

If you target any prior API level, the size of wchar_t will be 1 byte and none of the wide-char functions will work anyway.

We recommend any developer to get rid of any dependencies on the wchar_t type and switch to better representations. The support provided in Android is only there to help you migrate existing code.

---

I've tried --enable-utf8, --enable-utf8only, --disable-std_string (and several combinations enabling/disabling them) without luck.

In fact, configure seems to pass ok:

configure:19689: checking for wchar.h
configure:19689: result: yes

Attached is the configure output (configure_android.txt) and the commands I'm using (configure_android_sh.txt), note that it includes the paths that works for the standalone qt app.

This is the complete config.log:

https://dl.dropboxusercontent.com/u/75600582/config_log_android_wxqt.txt

BTW, how can I compile the __WXANDROID__ port already in the trunk?
(I tried with no luck either patching those files in this branch)
I understand that it is minimal, but perhaps I could figure out the settings from that prior experience.
It is documented elsewere?
The page in the wiki only explains how to set up the sdk/ndk and the other have just ideas:


Best regards
configure_android.txt
configure_android_sh.txt

Vadim Zeitlin

unread,
Mar 20, 2014, 4:12:58 PM3/20/14
to wx-...@googlegroups.com
On Thu, 20 Mar 2014 15:19:03 -0300 Mariano Reingart wrote:

MR> > There are a lot of changes to just the RCS-ID line, I wonder if we could
MR> > filter them out somehow? Also, there are some EOL changes (e.g. in
MR> > include/wx/qt/calctrl.h) which distract from the real changes...
MR> >
MR> Yes, I saw them, maybe I'm omitting some setting at the svn level
MR> About the EOL, I just edited the files, but it seems gedit has changed the
MR> file beyond my modifications.
MR> Do you have a guide or something similar about this two?

We don't really have any guides specifically about the EOLs but my
personal advice would be to keep everything (except some specific files,
like MSVS projects and .bat files) in Unix format, always, i.e. even under
Windows. Any decent editor should support Unix file format too and this
avoids problems if you ever copy files between the systems or use a VCS
which doesn't do any EOL translation (or use one which is capable of doing
it but don't want to bother with it).

MR> (and IDE that you can recomend and is not too cumbersone)

I'm not the one to ask about IDEs as I am a Vim person.

MR> I'm setting up hg-git so I could a fine grainded local commits in a easier
MR> way.

While using git-svn works very well and I think that using hg-git works
well too, I really question the idea of using hg-git-svn. Even if it also
works (which would be amazing on its own), this seems like just asking for
trouble. Personally, I'd recommend switching to git, if you're comfortable
with hg, it won't be a big problem. But if you absolutely want to use hg,
then I think you should use hg-svn directly.

MR> > MR> The patch:
MR> > MR>
MR> > MR> https://dl.dropboxusercontent.com/u/75600582/wxQT_5_2_1.patch
MR> >
MR> > Do I understand correctly that this should be applied to wxQT branch?
MR>
MR> Yes

OK, I can apply it without problems then (I'd be more careful with the
trunk...), just let me know if you can make a new version fixing the RCS-ID
and EOL problems. TIA!

MR> I've tried --enable-utf8, --enable-utf8only,

Yes, I think using those two should be the default for Android.

MR> --disable-std_string

This shouldn't be needed.

MR> I'm using (configure_android_sh.txt), note that it includes the paths that
MR> works for the standalone qt app.

Ugh, this is pretty horrible. Is this really the best/only way to do it?

MR> This is the complete config.log:
MR>
MR> https://dl.dropboxusercontent.com/u/75600582/config_log_android_wxqt.txt

I don't see anything wrong in it... It seems to detect wcsdup just fine.
The only explanation I have is that wcsdup actually exists in the library
but is not declared in any header. Can you try grepping them to check if
this is really the case?

MR> BTW, how can I compile the __WXANDROID__ port already in the trunk?

Only wxBase can be compiled for Android, there is no GUI Android port
(yet).

Regards,
VZ

Mariano Reingart

unread,
Mar 21, 2014, 12:45:25 AM3/21/14
to wx-dev
On Thu, Mar 20, 2014 at 5:12 PM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Thu, 20 Mar 2014 15:19:03 -0300 Mariano Reingart wrote:

MR> >  There are a lot of changes to just the RCS-ID line, I wonder if we could
MR> > filter them out somehow? Also, there are some EOL changes (e.g. in
MR> > include/wx/qt/calctrl.h) which distract from the real changes...
MR> >
MR> Yes, I saw them, maybe I'm omitting some setting at the svn level
MR> About the EOL, I just edited the files, but it seems gedit has changed the
MR> file beyond my modifications.
MR> Do you have a guide or something similar about this two?

 We don't really have any guides specifically about the EOLs but my
personal advice would be to keep everything (except some specific files,
like MSVS projects and .bat files) in Unix format, always, i.e. even under
Windows. Any decent editor should support Unix file format too and this
avoids problems if you ever copy files between the systems or use a VCS
which doesn't do any EOL translation (or use one which is capable of doing
it but don't want to bother with it).


Ok
 
MR> (and IDE that you can recomend and is not too cumbersone)

 I'm not the one to ask about IDEs as I am a Vim person.

MR> I'm setting up hg-git so I could a fine grainded local commits in a easier
MR> way.

 While using git-svn works very well and I think that using hg-git works
well too, I really question the idea of using hg-git-svn. Even if it also
works (which would be amazing on its own), this seems like just asking for
trouble. Personally, I'd recommend switching to git, if you're comfortable
with hg, it won't be a big problem. But if you absolutely want to use hg,
then I think you should use hg-svn directly.


Ok, I'll try hg-svn 
I use hg-git to maintain mirrors from googlecode and even github only projects, it has worked perfect for my so I prefer not use git (last time I tried, I didn't have time to understand some complex git workflows).
Also, I have used it git-svn but had problems

MR> > MR> The patch:
MR> > MR>
MR> > MR> https://dl.dropboxusercontent.com/u/75600582/wxQT_5_2_1.patch
MR> >
MR> >  Do I understand correctly that this should be applied to wxQT branch?
MR>
MR> Yes

 OK, I can apply it without problems then (I'd be more careful with the
trunk...), just let me know if you can make a new version fixing the RCS-ID
and EOL problems. TIA!


Ok, I'll try to make a new patch ASAP.
I've revised my svn config and already have the ID and EOL config, so I don't really know where the problem could be.
I'll investigate.
Last time this kind os minor issues also blocked and screw up the merge attempt.
 
MR> I've tried --enable-utf8, --enable-utf8only,

 Yes, I think using those two should be the default for Android.

MR> --disable-std_string

 This shouldn't be needed.


Ok, I'll try again.
 
MR> I'm using (configure_android_sh.txt), note that it includes the paths that
MR> works for the standalone qt app.

 Ugh, this is pretty horrible. Is this really the best/only way to do it?


No, it is just a quick and dirty approach. 
It should be possible to simplify a lot the directives, flags, etc..

BTW, it can get worse... I'm trying to compile just for one Android platform / architecture
QtCreator has several kits (at least for 3 android architectures: armeabi-v5, armeabi-v7, x86)
Also, you have 9 Android Platform SDK to choose to deploy (android-10 to android-19)
 
MR> This is the complete config.log:
MR>
MR> https://dl.dropboxusercontent.com/u/75600582/config_log_android_wxqt.txt

 I don't see anything wrong in it... It seems to detect wcsdup just fine.
The only explanation I have is that wcsdup actually exists in the library
but is not declared in any header. Can you try grepping them to check if
this is really the case?


Yes, it seems that exists but is not in the headers:

reingart@s5ultra:~/src/android-ndk-r9d/platforms/android-9/arch-arm/usr$ grep wcsdup * -r
Coincidencia en el archivo binario lib/libc.so
Coincidencia en el archivo binario lib/libc.a
reingart@s5ultra:~/src/android-ndk-r9d/platforms/android-9/arch-arm/usr$ grep atoi * -r
include/stdlib.h:extern int atoi(const char *);
Coincidencia en el archivo binario lib/libc.so
Coincidencia en el archivo binario lib/libc.a

BTW this are all the wcs symbols:

reingart@s5ultra:~/src/android-ndk-r9d/platforms$ nm android-9/arch-arm/usr/lib/libc.so | grep wcs
0000b0cc T mbsrtowcs
0000b0e0 T mbstowcs
0000cd8c T wcscasecmp
0000cda0 T wcscat
0000cdb4 T wcschr
0000cdc8 T wcscmp
0000cddc T wcscoll
0000cdf0 T wcscpy
0000ce04 T wcscspn
0000ce18 T wcsdup
0000ce2c T wcsftime
0000ce40 T wcslcat
0000ce54 T wcslcpy
0000ce68 T wcslen
0000ce7c T wcsncasecmp
0000ce90 T wcsncat
0000cea4 T wcsncmp
0000ceb8 T wcsncpy
0000cecc T wcsnlen
0000cee0 T wcspbrk
0000cef4 T wcsrchr
0000cf08 T wcsrtombs
0000cf1c T wcsspn
0000cf30 T wcsstr
0000cf44 T wcstod
0000cf58 T wcstok
0000cf6c T wcstol
0000cf80 T wcstombs
0000cf94 T wcstoul
0000cfa8 T wcswcs
0000cfbc T wcswidth
0000cfd0 T wcsxfrm

What should be done in this cases?
Should I define it manually in the wx sources?
 
MR> BTW, how can I compile the __WXANDROID__ port already in the trunk?

 Only wxBase can be compiled for Android, there is no GUI Android port
(yet).


How can it be compiled? 
What toolchain?
What configuration?
I would like to try at least wxBase to see how it works.

Vadim Zeitlin

unread,
Mar 21, 2014, 12:01:02 PM3/21/14
to wx-...@googlegroups.com
On Fri, 21 Mar 2014 01:45:25 -0300 Mariano Reingart wrote:

MR> > MR> This is the complete config.log:
MR> > MR>
MR> > MR> https://dl.dropboxusercontent.com/u/75600582/config_log_android_wxqt.txt
MR> >
MR> > I don't see anything wrong in it... It seems to detect wcsdup just fine.
MR> > The only explanation I have is that wcsdup actually exists in the library
MR> > but is not declared in any header. Can you try grepping them to check if
MR> > this is really the case?
MR> >
MR> Yes, it seems that exists but is not in the headers:
...
MR> What should be done in this cases?
MR> Should I define it manually in the wx sources?

We have two choices: either we can run the tests for it using C++ compiler
and then they'd fail under Android and we'd use our own version as
fallback. Or we could declare it ourselves, as we already do for e.g.
vsnprintf(), see the logic related to HAVE_VSNPRINTF_DECL. The latter is
probably better.

MR> > MR> BTW, how can I compile the __WXANDROID__ port already in the trunk?
MR> >
MR> > Only wxBase can be compiled for Android, there is no GUI Android port
MR> > (yet).
MR> >
MR> How can it be compiled?
MR> What toolchain?
MR> What configuration?
MR> I would like to try at least wxBase to see how it works.

You should look at http://review.bakefile.org/r/362/ and its updated
version at https://github.com/cwalther/wxWidgets/tree/android, it has
instructions in the README.

Regards,
VZ

Mariano Reingart

unread,
Mar 23, 2014, 3:30:38 PM3/23/14
to wx-dev
I could compile wxQt for Android, just document some steps here as this could help also the native port and maybe other developers facing related issues.
Please tell me if there are other better alternatives or corrections.

First, in chartype.h, added the missing declarations:

    #include <wchar.h>

    extern wchar_t *wcsdup(const wchar_t *);
    extern size_t wcslen (const wchar_t *);
    extern size_t wcsnlen (const wchar_t *, size_t );
    extern int wcscasecmp (const wchar_t *, const wchar_t *);
    extern int wcsncasecmp (const wchar_t *, const wchar_t *, size_t);

(note: this is a quick and dirty patch, it should be correctly enclosed by a #ifdef android block)
Althought wcsdup is appears as symbol in libc.a, it still doesn't work (the linker complies for the missing reference, I have to review the declaration...).

../include/wx/wxcrtbase.h:759: error: undefined reference to 'wcsdup(wchar_t const*)'
collect2: error: ld returned 1 exit status

This can be related to a known android issue:


I resolved this copying the function from android sources (I have to check the proper project site and version for the final patch, and/or see if there is other way to solve this using wx own versions as VZ commented in the previous mail):


Then it compiles, but sometimes I had to check wxWCHAR_T_IS_REAL_TYPE was defined in 0 so was failing by a conversion ambiguity between wxUniChar and wchar_t (surely I was trying with some incorrect configuration options):

../include/wx/wxcrt.h:613:46: error: conversion from 'const wxUniChar' to 'const wchar_t' is ambiguous
     { return wxCRT_StrchrW(s, (const wchar_t)c); }
 
In lib/wx/include/arm-linux-androideabi-qt-unicode-2.9/wx/setup.h assure that:
#define wxWCHAR_T_IS_REAL_TYPE 1

Next problem fixed was a change in time_t (this is in the Android code already in trunk), see static_cast<time_t>

Other problem is that the Android C library seems not have some locale structure members (decimal point and so, for wxLocale::GetInfo ), according suport forums, a Java API should be used:
 
https://groups.google.com/forum/#!topic/android-ndk/PBK4KkRpDoU

In sockets also seems to be missing a declaration: 
../src/common/sckaddr.cpp:303:73: error: 'gethostbyaddr_r' was not declared in this scope

I've commented out wxLocale::GetInfo and disabled sockets (to see if then compiles).
The final configure parametes were:
--with-qt --enable-debug --enable-utf8 --disable-dataviewctrl --without-regex --disable-treelist --disable-aui --disable-uiactionsim --disable-stc --disable-ribbon --disable-propgrid --disable-aui   --without-libpng --without-libjpeg --without-libtiff --without-zlib --disable-compat28 --without-expat  --host=arm-linux-androideabi  --target=arm-linux-androideabi --disable-std_string  --enable-utf8only --disable-sockets --disable-svg  --disable-richtext --disable-richmsgdlg --disable-dragimage  --enable-shared

Everything seems ok, the output in lib folder:

libwx_baseu-2.9.so.2
libwx_baseu-2.9.so.2.0.0
libwx_baseu_net-2.9.so.2
libwx_baseu_net-2.9.so.2.0.0
libwx_baseu_xml-2.9.so.2
libwx_baseu_xml-2.9.so.2.0.0
libwx_qtu_adv-2.9.so.2
libwx_qtu_adv-2.9.so.2.0.0
libwx_qtu_core-2.9.so.2
libwx_qtu_core-2.9.so.2.0.0
libwx_qtu_html-2.9.so.2
libwx_qtu_html-2.9.so.2.0.0
libwx_qtu_media-2.9.so.2
libwx_qtu_media-2.9.so.2.0.0
libwx_qtu_qa-2.9.so.2
libwx_qtu_qa-2.9.so.2.0.0

I could compile the minimal sample too (with some changes to Makefile to write the .so required by the packaging tools of android qt).

Then I made the apk package and tried it, but it seems it does not like libraries ending without .so (as libwx_qtu_core-2.9.so.2), as they are not included automatically in the package:

E/AndroidRuntime(  339): FATAL EXCEPTION: main
E/AndroidRuntime(  339): java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1962]:    32 could not load needed library 'libwx_qtu_core-2.9.so.2' for 'libgsoc2014.so' (load_library[1104]: Library 'libwx_qtu_core-2.9.so.2' not found)
E/AndroidRuntime(  482): java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1962]:    32 could not load needed library 'libwx_qtu_core-2.9.so.2' for 'libgsoc2014.so' (load_library[1104]: Library 'libwx_qtu_core-2.9.so.2' not found)

I will keep trying to investigate this, and of course, if you have any comment it will be welcome!

Mariano Reingart

unread,
Mar 25, 2014, 3:44:50 AM3/25/14
to wx-dev
Update:

I'd resolved the wcsdup issue (not defining wxCRT_StrdupW in wxcrtbase.h to use the wx code in wxcrt.cpp, but I'ld like investigate why HAVE_WCSDUP get defined by configure...)

Also, I've compiled wx and minimal with --disable-shared so I can avoid the problem of loading extra libraries by now.

Outcome: 




When testing the apk on the AVD, I get a "terminated by signal (5)" message:

I/Qt      (  598): qt start
D/dalvikvm(  598): Trying to load lib /data/data/org.reingart.gsoc2014/lib/libgsoc2014.so 0x40512a28
D/Zygote  (   32): Process 598 terminated by signal (5)
I/ActivityManager(   60): Process org.reingart.gsoc2014 (pid 598) has died.

In some blogs, I saw this can be caused by extra libraries not being lodaded, but It looks like the minimal qt app I've made (just some libs are in different order):

reingart@s5ultra:~/src/wxQT/android/samples/minimal$ /home/reingart/src/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-readelf -d libgsoc2014.so  | grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libQt5Widgets.so]
 0x00000001 (NEEDED)                     Shared library: [libQt5Gui.so]
 0x00000001 (NEEDED)                     Shared library: [libQt5Core.so]
 0x00000001 (NEEDED)                     Shared library: [libGLESv2.so]
 0x00000001 (NEEDED)                     Shared library: [libgnustl_shared.so] 
 0x00000001 (NEEDED)                     Shared library: [liblog.so]
 0x00000001 (NEEDED)                     Shared library: [libz.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so] 
 0x00000001 (NEEDED)                     Shared library: [libm.so]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so]


When I try to debug, in the emulator appears:

reingart@s5ultra:~/src/gsoc2014$ /home/reingart/src/android-sdk-linux/platform-tools/adb shell LD_LIBRARY_PATH=/data/local/tmp /data/local/gdbserver :1234 /data/local/tmp/minimal
Process /data/local/tmp/minimal created; pid = 669
Listening on port 1234
Remote debugging from host 127.0.0.1
% in DoGetArgumentType(): more arguments than format string specifiers?
5663204 in wxArgNormalizerUtf8(): format specifier doesn't match argument type
% in DoGetArgumentType(): more arguments than format string specifiers?
5663204 in wxArgNormalizerUtf8(): format specifier doesn't match argument typ

In the host:

reingart@s5ultra:~/src/wxQT/android/samples/minimal$ ~/src/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gdb minimal
GNU gdb (GDB) 7.3.1-gg2
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-linux-android".
For bug reporting instructions, please see:
Reading symbols from /home/reingart/src/wxQT/android/samples/minimal/minimal...done.
(gdb) target remote :1234
Remote debugging using :1234
warning: Unable to find dynamic linker breakpoint function.
GDB will retry eventurally.  Meanwhile, it is likely
that GDB is unable to debug shared library initializers
or resolve pending breakpoints after dlopen().
0xb0001000 in ?? ()
(gdb) handle SIGTRAP noprint nostop
SIGTRAP is used by the debugger.
Are you sure you want to change it? (y or n) y

Signal        Stop Print Pass to program Description
SIGTRAP       No No No Trace/breakpoint trap
(gdb) cont
Continuing.
Cannot access memory at address 0x0

Program received signal SIGILL, Illegal instruction.
0x00017c78 in main () at ../../../samples/minimal/minimal.cpp:109
109 IMPLEMENT_APP(MyApp)
(gdb) 

Note that I had to do "handle SIGTRAP noprint nostop" to get the real signal (as far I could read, this could be related to a threading issue)
Also I'd read that Qt GUI apps cannot be debugged this way.

Any clue?

BTW, does anyone know how this could be debugged easily without setting the full environment? 
(ie.command line to avoid qt creator / eclipse...)

Also, if you can, just let me know if I'm going in the rigth or wrong direction...

Best regards,

Vadim Zeitlin

unread,
Mar 25, 2014, 9:35:10 AM3/25/14
to wx-...@googlegroups.com
On Tue, 25 Mar 2014 04:44:50 -0300 Mariano Reingart wrote:

MR> I'd resolved the wcsdup issue (not defining wxCRT_StrdupW in wxcrtbase.h to
MR> use the wx code in wxcrt.cpp, but I'ld like investigate why HAVE_WCSDUP get
MR> defined by configure...)

Hi,

I think it's very simple: configure uses C for this test and in C the lack
of function prototype is not an error, unlike in C++. So the program
compiles and links because wcsdup() is actually available in the libraries.
But in C++ it doesn't even compile because of this lack of prototype.

MR> When I try to debug, in the emulator appears:
MR>
MR> reingart@s5ultra:~/src/gsoc2014$
MR> /home/reingart/src/android-sdk-linux/platform-tools/adb shell
MR> LD_LIBRARY_PATH=/data/local/tmp /data/local/gdbserver :1234
MR> /data/local/tmp/minimal
MR> Process /data/local/tmp/minimal created; pid = 669
MR> Listening on port 1234
MR> Remote debugging from host 127.0.0.1
MR> % in DoGetArgumentType(): more arguments than format string specifiers?

Notice that this assert doesn't exist in the latest trunk code any more
(see r76027).

MR> 5663204 in wxArgNormalizerUtf8(): format specifier doesn't match argument
MR> type

This one looks bad though. Unfortunately I have no idea where does it come
from.

MR> BTW, does anyone know how this could be debugged easily without setting
MR> the full environment? (ie.command line to avoid qt creator /
MR> eclipse...)

I'd love to know this too, but I can't help you here, sorry.

Good luck,
VZ

Mariano Reingart

unread,
Mar 28, 2014, 3:45:52 AM3/28/14
to wx-dev
Well, wxQT on Android did work! 
(at least initially)
Attached is a minimal dialog box.
This is the app (please read bellow some comments):


Note that I reduced the minimal sample to just a dialog to start debugging it.

On Tue, Mar 25, 2014 at 10:35 AM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Tue, 25 Mar 2014 04:44:50 -0300 Mariano Reingart wrote:

MR> I'd resolved the wcsdup issue (not defining wxCRT_StrdupW in wxcrtbase.h to
MR> use the wx code in wxcrt.cpp, but I'ld like investigate why HAVE_WCSDUP get
MR> defined by configure...)

 Hi,

 I think it's very simple: configure uses C for this test and in C the lack
of function prototype is not an error, unlike in C++. So the program
compiles and links because wcsdup() is actually available in the libraries.
But in C++ it doesn't even compile because of this lack of prototype.


Yes, I understand that, but it doesn't links (see my previous mail) ...
I could fix adding the missing prototipes for wcslen, wcsnlen, wcscasecmp, wcsncasecmp (they seems to work) but with the missing prototipe of wcsdup doesn't link.

Anyway, there should be any other problem as the traps (Signal 5), assertions and segmentation faults are related to string methods...

See this wxWidgets Debug Alert:

 in FromWChar(): trying to encode undefined Unicode character.
Do you want to stop the program?
You can also choose [Cancel] to suppress further warnings.


(you can get garbage at the beggining of that dialogs sometimes)

The error happens in the wxString::Format at the dialog in the minimal example: 

 
(to reach that point, you need to use the debugger bellow to continue "Program received signal SIGTRAP, Trace/breakpoint trap." prior each debug alert, see bellow the complete gdb session transcript)

Also, other error was that android doesn't have "uname" so wxGetOsVersion and similar were causing a crash:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 396]
0x81588358 in wxGetCommandOutput(wxString const&) ()
    at ../include/wx/stringimpl.h:296
296    wxASSERT_MSG( stringSrc.GetStringData()->IsValid(),
(gdb) bt
#0  0x81588358 in wxGetCommandOutput(wxString const&) ()
    at ../include/wx/stringimpl.h:296
#1  0x815886ca in wxGetOsVersion(int*, int*) ()
    at ../src/unix/utilsunx.cpp:1021
#2  0x8156b936 in wxPlatformInfo::InitForCurrentPlatform() ()
    at ../src/common/platinfo.cpp:192
#3  0x8156b9e2 in wxPlatformInfo::Get() () at ../src/common/platinfo.cpp:209
#4  0x814f4a40 in wxGetLibraryVersionInfo() ()
    at ../src/common/utilscmn.cpp:1387
#5  0x814f4dda in wxInfoMessageBox(wxWindow*) ()
    at ../src/common/utilscmn.cpp:1427
#6  0x814f2d9c in MyApp::OnInit (this=0x2ac510) at ../minimal/minimal.cpp:80
#7  0x814f2a8c in wxAppConsoleBase::CallOnInit (this=0x2ac510)
    at ../../../src/wxQT/include/wx/app.h:92
#8  0x81568678 in wxEntry(int&, wchar_t**) () at ../src/common/init.cpp:456
#9  0x8156882a in wxEntry(int&, char**) () at ../src/common/init.cpp:485
#10 0x814f2c74 in main (argc=1, argv=0x448bbad0) at ../minimal/minimal.cpp:60
#11 0x80515c82 in ?? ()
#12 0x80515c82 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

MR> When I try to debug, in the emulator appears:
MR>
MR> reingart@s5ultra:~/src/gsoc2014$
MR> /home/reingart/src/android-sdk-linux/platform-tools/adb shell
MR> LD_LIBRARY_PATH=/data/local/tmp /data/local/gdbserver :1234
MR> /data/local/tmp/minimal
MR> Process /data/local/tmp/minimal created; pid = 669
MR> Listening on port 1234
MR> Remote debugging from host 127.0.0.1
MR> % in DoGetArgumentType(): more arguments than format string specifiers?

 Notice that this assert doesn't exist in the latest trunk code any more
(see r76027).

MR> 5663204 in wxArgNormalizerUtf8(): format specifier doesn't match argument
MR> type

 This one looks bad though. Unfortunately I have no idea where does it come
from.

MR> BTW, does anyone know how this could be debugged easily without setting
MR> the full environment? (ie.command line to avoid qt creator /
MR> eclipse...)

 I'd love to know this too, but I can't help you here, sorry.


Here is a minimal script that almost works to debug the minimal wxQT android package:


I've adapted and simplified ndk-gdb as much as I could, but I have to polish it
It loads debug info for most libraries correctly, but for libgsoc2014.so -minimal sample- has some issues (doesn't include debug info), so I need to continue investigating as the problem may be in the build process, see the complete backtraces with the original .so (the second one is a complete sessions with the traps described previously):



The ndk-gdb one didn't work out of the box in this case for me, as it expects some paths/config:

ERROR: The device does not support the application's targetted CPU ABIs!
       Device supports:  armeabi 
       Package supports: Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: ./jni/Android.mk 

Also, the JDK debugger part from ndk-gdb didn't work for me (the app waits forever “Waiting for debugger to attach”), so I modified the java part of the qt loader to wait a few seconds to the debugger to attach (src/org/qtproject/qt5/android/bindings/QtActivity.java):

        try {
            Log.d("SLEEP 500", "waiting debugger");
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

Also, there are some sleeps in the script to give time the gdb server / client to establish the connection.
So, if you run the app, expect a few seconds until the dialogs apperars.

Finally, I made a minimal qmake project fije to be used under QtCreator for compiling and testing:


Hope this helps!
(and sorry about my English and any mistake, I'm trying this after work at night)
wxQtAndroid.png

Vadim Zeitlin

unread,
Mar 29, 2014, 10:03:18 AM3/29/14
to wx-...@googlegroups.com
On Fri, 28 Mar 2014 04:45:52 -0300 Mariano Reingart wrote:

MR> Well, wxQT on Android did work!

Great news!

MR> On Tue, Mar 25, 2014 at 10:35 AM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
MR>
MR> > On Tue, 25 Mar 2014 04:44:50 -0300 Mariano Reingart wrote:
...
MR> > I think it's very simple: configure uses C for this test and in C the lack
MR> > of function prototype is not an error, unlike in C++. So the program
MR> > compiles and links because wcsdup() is actually available in the libraries.
MR> > But in C++ it doesn't even compile because of this lack of prototype.
MR> >
MR> Yes, I understand that, but it doesn't link

Then I don't understand how does the configure test pass...

MR> I could fix adding the missing prototipes for wcslen, wcsnlen, wcscasecmp,
MR> wcsncasecmp (they seems to work) but with the missing prototipe of wcsdup
MR> doesn't link.

Just a stupid question: did you use extern "C" for these prototypes?

MR> Anyway, there should be any other problem as the traps (Signal 5),
MR> assertions and segmentation faults are related to string methods...
MR>
MR> See this wxWidgets Debug Alert:
MR>
MR> in FromWChar(): trying to encode undefined Unicode character.

That's interesting... It really shouldn't happen. Can you see the actual
contents of "src" passed to FromWChar()? And if it's really invalid, where
does it come from?

MR> Also, other error was that android doesn't have "uname" so wxGetOsVersion
MR> and similar were causing a crash:

This is not right neither :-( If there is uname, these functions should
return an error, but not crash.

MR> > MR> BTW, does anyone know how this could be debugged easily without setting
MR> > MR> the full environment? (ie.command line to avoid qt creator /
MR> > MR> eclipse...)
MR> >
MR> > I'd love to know this too, but I can't help you here, sorry.
MR> >
MR> Here is a minimal script that almost works to debug the minimal wxQT
MR> android package:
MR>
MR> https://dl.dropboxusercontent.com/u/75600582/gsoc2014/wxQT/gdb.sh

Thanks, I'll try to test it when I have time (which unfortunately won't be
now...).
VZ

Mariano Reingart

unread,
Mar 29, 2014, 5:28:27 PM3/29/14
to wx-dev
On Sat, Mar 29, 2014 at 11:03 AM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Fri, 28 Mar 2014 04:45:52 -0300 Mariano Reingart wrote:

MR> Well, wxQT on Android did work!

 Great news!

MR> On Tue, Mar 25, 2014 at 10:35 AM, Vadim Zeitlin <va...@wxwidgets.org> wrote:
MR>
MR> > On Tue, 25 Mar 2014 04:44:50 -0300 Mariano Reingart wrote:
...
MR> >  I think it's very simple: configure uses C for this test and in C the lack
MR> > of function prototype is not an error, unlike in C++. So the program
MR> > compiles and links because wcsdup() is actually available in the libraries.
MR> > But in C++ it doesn't even compile because of this lack of prototype.
MR> >
MR> Yes, I understand that, but it doesn't link

 Then I don't understand how does the configure test pass...


My fault, see bellow
 
MR> I could fix adding the missing prototipes for wcslen, wcsnlen, wcscasecmp,
MR> wcsncasecmp (they seems to work) but with the missing prototipe of wcsdup
MR> doesn't link.

 Just a stupid question: did you use extern "C" for these prototypes?


Oops, sorry, I thought it was used but the extern "C" was inside a #ifdef __CYGWIN__  (chartype.h, just before #include <wchar.h>), so it wasn't, sorry again for not figuring this in the hurry, so embarrassing ...

Anyway, they still doesn't work, the behaving is the same, they compile but I keep getting assertions

#22 0x8156f9f6 in wxMBConvStrictUTF8::FromWChar(char*, unsigned int, wchar_t const*, unsigned int) const () at ../src/common/strconv.cpp:1208

            wxFAIL_MSG( wxT("trying to encode undefined Unicode character") );

I tried also with the wx versions (not declaring the externs at all and using the internal implementation in wxcrt.cpp), but it gives the same assertion.
 
MR> Anyway, there should be any other problem as the traps (Signal 5),
MR> assertions and segmentation faults are related to string methods...
MR>
MR> See this wxWidgets Debug Alert:
MR>
MR>  in FromWChar(): trying to encode undefined Unicode character.

 That's interesting... It really shouldn't happen. Can you see the actual
contents of "src" passed to FromWChar()? And if it's really invalid, where
does it come from?


Program received signal SIGTRAP, Trace/breakpoint trap.
0xafd0b47c in write () from /tmp/system_lib/libc.so
(gdb) bt
#0  0xafd0b47c in write () from /tmp/system_lib/libc.so
#1  0xafd1604c in eventfd_write () from /tmp/system_lib/libc.so
#2  0x8094a4e4 in QEventDispatcherUNIX::wakeUp() () from libQt5Core.so
#3  0x8092c23a in QCoreApplication::postEvent(QObject*, QEvent*, int) ()
   from libQt5Core.so
#4  0x8092efa8 in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const () from libQt5Core.so
#5  0x8092f5da in QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) () from libQt5Core.so
#6  0x8051b3ba in QtAndroidDialogHelpers::dialogResult(_JNIEnv*, _jobject*, long long, int) ()
   from /home/reingart/gsoc2014/android/libs/armeabi/libqtforandroid.so
#7  0x80017d78 in dvmPlatformInvoke () from /tmp/system_lib/libdvm.so
#8  0x0000ce48 in ?? ()
#9  0x0000ce48 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info threads
  Id   Target Id         Frame 
  9    Thread 1533       0x8119c66e in QWidgetTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(QTextCursor const&) const () from libQt5Widgets.so
  8    Thread 1527       0xafd0b6fc in __ioctl () from /tmp/system_lib/libc.so
  7    Thread 1526       0xafd0b6fc in __ioctl () from /tmp/system_lib/libc.so
  6    Thread 1525       0xafd0c738 in __futex_syscall3 ()
   from /tmp/system_lib/libc.so
  5    Thread 1524       0xafd0c22c in recvmsg () from /tmp/system_lib/libc.so
  4    Thread 1523       0xafd0bfec in __rt_sigtimedwait ()
   from /tmp/system_lib/libc.so
  3    Thread 1520       0xafd0c738 in __futex_syscall3 ()
   from /tmp/system_lib/libc.so
  2    Thread 1519       0xafd0c738 in __futex_syscall3 ()
   from /tmp/system_lib/libc.so
* 1    Thread 1517       0xafd0b47c in write () from /tmp/system_lib/libc.so

(gdb) thread 9
[Switching to thread 9 (Thread 1533)]
#0  0x8119c66e in QWidgetTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(QTextCursor const&) const () from libQt5Widgets.so

(gdb) bt
#0  0x8119c66e in QWidgetTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(QTextCursor const&) const () from libQt5Widgets.so
#1  0x8119c6f2 in QWidgetTextControlPrivate::repaintCursor() ()
   from libQt5Widgets.so
#2  0x8119c7fe in QWidgetTextControl::setCursorWidth(int) ()
   from libQt5Widgets.so
#3  0x8119c828 in QWidgetTextControlPrivate::init(Qt::TextFormat, QString const&, QTextDocument*) () from libQt5Widgets.so
#4  0x8119c960 in QWidgetTextControl::QWidgetTextControl(QObject*) ()
   from libQt5Widgets.so
#5  0x8115f4f8 in QLabelPrivate::ensureTextControl() const ()
   from libQt5Widgets.so
#6  0x81160022 in QLabel::setText(QString const&) () from libQt5Widgets.so
#7  0x811bf1d8 in QMessageBox::setText(QString const&) () from libQt5Widgets.so
#8  0x8154e9dc in wxMessageDialog::wxMessageDialog (this=0x448b9e1c, parent=
    0x0, message=..., caption=..., style=538, pos=...)
    at ../src/qt/msgdlg.cpp:25
#9  0x81546ec0 in wxMessageBox (message=..., caption=..., style=538, 
    parent=0x0) at ../src/common/utilscmn.cpp:1359
#10 0x8155edf0 in wxGUIAppTraitsBase::ShowAssertDialog (this=0x2af170, msg=...)
    at ../src/common/appcmn.cpp:452
#11 0x81660954 in ShowAssertDialog (file=..., line=1208, func=..., cond=..., 
    msgUser=..., traits=0x2af170) at ../src/common/appbase.cpp:1256
---Type <return> to continue, or q <return> to quit---
#12 0x8165f900 in wxAppConsoleBase::OnAssertFailure (this=0x2ac2b8, 
    file=0x2a1288 L"../src/common/strconv.cpp", line=1208, 
    func=0x2c6820 L"FromWChar", cond=0x299ed8 L"Assert failure", 
    msg=0x2c3800 L"trying to encode undefined Unicode character")
    at ../src/common/appbase.cpp:761
#13 0x8165fed8 in wxDefaultAssertHandler (file=..., line=1208, func=..., 
    cond=..., msg=...) at ../src/common/appbase.cpp:1056
#14 0x81660634 in wxOnAssert (file=0x8178e8a8 "../src/common/strconv.cpp", 
    line=1208, func=0x8178edf0 "FromWChar", cond=0x8178e8c8 "Assert failure", 
    msg=0x8178e8d8 L"trying to encode undefined Unicode character")
    at ../src/common/appbase.cpp:1141
#15 0x816b8454 in wxMBConvStrictUTF8::FromWChar (this=0x448ba3f8, dst=0x0, 
    dstLen=0, src=0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150", 
    srcLen=4294967295) at ../src/common/strconv.cpp:1208
#16 0x816b8a78 in wxMBConvUTF8::FromWChar (this=0x448ba3f8, buf=0x0, n=0, 
    psz=0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150", 
    srcLen=4294967295) at ../src/common/strconv.cpp:1382
#17 0x816b6df4 in wxMBConv::cWC2MB (this=0x448ba3f8, 
    inBuff=0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150", 
    inLen=4294967295, outLen=0x448ba3d8) at ../src/common/strconv.cpp:492
#18 0x816c2688 in wxString::ConvertStr (
    pwz=0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150", 
    nLength=4294967295, conv=...) at ../src/common/string.cpp:464
#19 0x81542768 in wxString::ImplStr (
    str=0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150")
    at ../include/wx/string.h:580
#20 0x81699c5c in wxString::assign (this=0x448ba474, 
    sz=0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150")
    at ../include/wx/string.h:2656
#21 0x816f244c in wxPrintfConvSpec<char>::Process (this=0x448ba8ec, 
    buf=0x2b8cf3 "", lenMax=1013, p=0x448ba6e8, written=11)
    at ../include/wx/private/wxprintf.h:712
#22 0x816f0d48 in wxDoVsnprintf<char> (buf=0x2b8ce8 "Welcome to ", 
    lenMax=1024, 
    format=0x2af08c "Welcome to %s!\n\nThis is the minimal wxWidgets sample\nrunning under %s.", argptr=...) at ../src/common/wxprintf.cpp:166
#23 0x816f000c in wxCRT_VsnprintfA (buf=0x2b8ce8 "Welcome to ", len=1024, 
    format=0x2af08c "Welcome to %s!\n\nThis is the minimal wxWidgets sample\nrunning under %s.", argptr=...) at ../src/common/wxprintf.cpp:240
#24 0x816ee808 in wxVsnprintf (str=0x2b8ce8 "Welcome to ", size=1024, 
    format=..., argptr=...) at ../src/common/wxcrt.cpp:688
#25 0x816c8a5c in DoStringPrintfV<wxStringTypeBuffer<char> > (str=..., 
    format=..., argptr=...) at ../src/common/string.cpp:2074
#26 0x816c7e88 in wxString::PrintfV (this=0x448bba18, format=..., argptr=...)
    at ../src/common/string.cpp:2156
#27 0x816c7d48 in wxString::DoFormatUtf8 (
    format=0x817597d0 "Welcome to %s!\n\nThis is the minimal wxWidgets sample\nrunning under %s.") at ../src/common/string.cpp:1926
#28 0x81541b58 in wxString::Format<wchar_t const*, char const*> (f1=..., 
    a1=0x81759818 L"wxWidgets 2.9.2", a2=0x81759858 "Android!")
    at ../src/wxQT/include/wx/string.h:2362
#29 0x815415a8 in MyApp::OnInit (this=0x2ac2b8) at minimal.cpp:93
#30 0x81541208 in wxAppConsoleBase::CallOnInit (this=0x2ac2b8)
    at ../src/wxQT/include/wx/app.h:92
#31 0x816a8d50 in wxEntry (argc=@0x817bff44, argv=0x2ac078)
    at ../src/common/init.cpp:456
#32 0x816a8e78 in wxEntry (argc=@0x448bba94, argv=0x448bbad0)
    at ../src/common/init.cpp:484
#33 0x815413f0 in main (argc=1, argv=0x448bbad0) at minimal.cpp:60
#34 0x80515c82 in startMainMethod(void*) ()
   from /home/reingart/gsoc2014/android/libs/armeabi/libqtforandroid.so
#35 0xafd11a80 in __thread_entry () from /tmp/system_lib/libc.so
#36 0xafd11644 in pthread_create () from /tmp/system_lib/libc.so
#37 0x00000000 in ?? ()

(gdb) select-frame 15

(gdb) info args
this = 0x448ba3f8
dst = 0x0
dstLen = 0
src = 0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150"
srcLen = 4294967295

(gdb) info locals
code = 1767340151
len = 0
wp = 0x2af1c0 L"\x69577877\x74656764\x2e322073\x322e39\x2af150"
out = 0x0
written = 0
__FUNCTION__ = "FromWChar"


I spend almost all my time today to see this, I need to go, but let me know what steps do you recommend at this stage.
 
MR> Also, other error was that android doesn't have "uname" so wxGetOsVersion
MR> and similar were causing a crash:

 This is not right neither :-( If there is uname, these functions should
return an error, but not crash.


Yes, sorry if I didn't expressed it correctly.
It should not crash, but it did due the string handling issues (I think)
 
MR> > MR> BTW, does anyone know how this could be debugged easily without setting
MR> > MR> the full environment? (ie.command line to avoid qt creator /
MR> > MR> eclipse...)
MR> >
MR> >  I'd love to know this too, but I can't help you here, sorry.
MR> >
MR> Here is a minimal script that almost works to debug the minimal wxQT
MR> android package:
MR>
MR> https://dl.dropboxusercontent.com/u/75600582/gsoc2014/wxQT/gdb.sh

 Thanks, I'll try to test it when I have time (which unfortunately won't be
now...).
VZ

Just in case, I've updated the apk with full debugging info (so it is now 34MB compressed)


(this version uses the internal wx methods for wcsdup and family, but it does the same using the ones from android)

Also, I've updated the tailored debug script to include all the libraries and sources:


Again, sorry about my mistakes, I'll try to be more ordered and work more carefully 
(I'll be commiting this stuff to my repo ASAP)

Thanks very much for your kind help!

Best regards,

Vadim Zeitlin

unread,
Mar 30, 2014, 5:50:42 PM3/30/14
to wx-...@googlegroups.com
On Sat, 29 Mar 2014 18:28:27 -0300 Mariano Reingart wrote:

MR> Anyway, they still doesn't work, the behaving is the same, they compile but
MR> I keep getting assertions
MR>
MR> #22 0x8156f9f6 in wxMBConvStrictUTF8::FromWChar(char*, unsigned int,
MR> wchar_t const*, unsigned int) const () at ../src/common/strconv.cpp:1208
MR>
MR> wxFAIL_MSG( wxT("trying to encode undefined Unicode character")

Sorry, I hoped to look at it today but I just ran out of time/energy, so
let me just mention one idea I had: could it be that Qt and wx have
different ideas of sizeof(wchar_t)? This is about the only thing I can
think of that could explain this happening, a priori...

Regards,
VZ

Mariano Reingart

unread,
Mar 30, 2014, 11:45:39 PM3/30/14
to wx-dev

I don't think so, Qt is not even reached where the assert is raisen.
I didn't studied this in detail, but wxQt seems to use utf8, so in qt/converter.cpp I've changed wxQtConvertString to return QString( str.utf8_str() )  instead of using c_str() to be safer.
Anyway this has no effect in the bug mentioned.

I think the problem has no relation to the size of wchar_t, instead it seems to be related to --enable-utf8only doing some implicit conversions:  L"\x69577877\x74656764\x2e322073\x322e39\x2af150" is in fact "wxWidgets 2.9" ascii/utf8 encoded AFAIK.
The strange part is that in the code it is correctly defined as L"wxWidgets 2.9.2" (see frame 28, and I tested it and is stored in 4 byte per char), but then at some point it is wrongly converted to char* and the wchar_t* again incorrectly.
As far I could debug there should be some issue in the handling of wxPAT_CHAR, wxPAT_WCHAR, maybe in wxprintf.h, as p->pad_str seems in fact a const char* instead of const wchar_t *

Anyway, I removed the --enable-utf8only, and there seems to be some other issue in Android itself (mbsrtowcs seems buggy, I thought is was resolved in android-ndk-r9d but likely it isn't), for example, dialogs appears empty without any text.

After some debugging, I removed HAVE_WCSRTOMBS and defined wxNEED_WX_MBSTOWCS and wxWCHAR_T_IS_WXCHAR32 (just in case, althought the last should be set automatically)

Now, it works correctly! (see the attachment).

This is the package updated:


Just in case, I'm commiting all this changes to:


I've solved the $ID$, EOL and other issues so it easier to read now.
It is not ready for merge yet as I have to do some cleanups an see how to detect the mbstowscs issue in configure, and then investigating an alternative to defining wxNEED_WX_MBSTOWCS in wxcrtbase.h similar to how MacOS was handled (note that it has changed in rev 75024 #15580: "Always use standard mbstowcs() and wcstombs() functions." as the ones in wx are not fully functional).

The proof of concept and instructions are here:


TL;DR

wxQt is working on Android! 

(at least the minimal proof-of-concept using qt5)

I don't have much more time to dedicate to this in the near term, but let me know if you need anything additional to evaluate my proposal. 
I hope this project could be accepted for gsoc2014, has been very interesting so far.

Best regard
wxQtAndroid_wxMbstowcs.png

Igor Korot

unread,
Mar 31, 2014, 1:38:15 AM3/31/14
to wx-...@googlegroups.com
Hi, Mariano,

On Sun, Mar 30, 2014 at 8:45 PM, Mariano Reingart <rein...@gmail.com> wrote:

I can see that you are doing tests on the emulator.
Do you have an actual device to test? (at least one Android phone/tablet)

Thank you.
> --
> To unsubscribe, send email to wx-dev+un...@googlegroups.com
> or visit http://groups.google.com/group/wx-dev
>

Mariano Reingart

unread,
Mar 31, 2014, 11:40:34 AM3/31/14
to wx-dev
On Mon, Mar 31, 2014 at 2:38 AM, Igor Korot <ikor...@gmail.com> wrote:
Hi, Mariano,

On Sun, Mar 30, 2014 at 8:45 PM, Mariano Reingart <rein...@gmail.com> wrote:

I can see that you are doing tests on the emulator.
Do you have an actual device to test? (at least one Android phone/tablet)



Yes, it does run on a real device!
In fact, it should run on any device with Android 2.3.3 or higher (with an ARMv5), as I've used the minimal API Level 10.
It could be compiled to ARMv7 and maybe others.
Althought I'm not using QtCreator to build the package (just used it to make the skeleton), the technique is the same, so it could run in all the Android platforms supported by Qt 5.2

Attached are screenshots of wxQt running on Android 4.0.3

This is an actual photo of the app installing in the tablet:


You can try it if you want, the complete apk with full debug symbols is at:


There shouldn't be required to install qt, just android sdk/ndk and extract solibs from the package and use the customized debug script:

 
Best regards,
wxQtAndroid_tablet2.png
wxQtAndroid_tablet1.png

Mariano Reingart

unread,
Apr 2, 2014, 1:50:40 AM4/2/14
to wx-dev
Update:

Attached is a more complete screenshot of the minimal sample app running under Android.
It includes a frame with some widgets (a panel with a textbox and buttons inside a sizer), handling some command events.
The basic code:


This are the full resolution screenshots for Android:




The screenshot for Ubuntu:


I've updated my wxQt branch with all the changes (including the latest about mbstowcs and wcstrombs):


The configure options (including flags and binaries used by qt):


The build instructions for the sample are in gsoc2014 repo linked above.
The app compiled and packaged:


I'll keep polishing it, testing and investigating other controls, comments are welcome ;-)
wxQtAndroid_minimal_widgets_50.png
Reply all
Reply to author
Forward
0 new messages