Results 1 to 15 of 15

Thread: Error while trying to build android app. #error Bionic header ctype.h...

  1. #1
    Join Date
    Jul 2015
    Posts
    7
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Android

    Default Error while trying to build android app. #error Bionic header ctype.h...

    Hi, I have some very useful app that calculates some water/steam properties (engineering stuff). Now I thought I might just build it for android and run it on my android phone so I don't have to take my laptop with me all the time.

    But it doesn't build. It fails with the error:
    Qt Code:
    1. #error Bionic header ctype.h does not define either _U nor _CTYPE_U
    To copy to clipboard, switch view to plain text mode 
    .

    Now I'm suspecting this might have something to do with the gnu scientific library, because this app needs to link to it (and another lib called freesteam). It runs fine when I choose the desktop option from the debug menu.

    I've checked online and the qt documentation but I didn't find anything that kinda lists all the steps I need to follow to make an app run on android if any other libraries are needed.

    Some additional info. I'm using Qt5.4/qtcreator in a Linux Mint x64 machine.
    I know (at least I think) that Qt5.4 is setup correctly because I can build/run programs, that do not need additional libraries, on my android device.

    Here's my .pro file. Maybe it gives any clues about what I'm doing wrong.

    Qt Code:
    1. TEMPLATE = app
    2.  
    3. QT += qml quick
    4.  
    5. SOURCES += main.cpp \
    6. mysteamclass.cpp
    7.  
    8. RESOURCES += qml.qrc
    9.  
    10. # Additional import path used to resolve QML modules in Qt Creator's code model
    11. QML_IMPORT_PATH =
    12.  
    13. # Default rules for deployment.
    14. include(deployment.pri)
    15.  
    16. DISTFILES +=
    17.  
    18. HEADERS += \
    19. mysteamclass.h
    20. #--------------------------------ME= C++11 AND LIBRARIES-----------------#
    21.  
    22. CONFIG+=c++11
    23.  
    24.  
    25. INCLUDEPATH += /usr/local/include
    26. INCLUDEPATH += /usr/local/freesteam
    27.  
    28. DEPENDPATH += /usr/local/include
    29.  
    30.  
    31. LIBS += -L/usr/local/include/
    32.  
    33. LIBS += -L/usr/local/include -lgsl
    34.  
    35. LIBS += -L/usr/local/include -libfreesteam
    36. LIBS += -L/usr/local/include -lgslcblas
    37.  
    38. LIBS+= -L/usr/lib/freesteam
    39.  
    40.  
    41.  
    42. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../usr/lib/release/ -lfreesteam
    43. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../usr/lib/debug/ -lfreesteam
    44. else:unix: LIBS += -L$$PWD/../../../../usr/lib/ -lfreesteam
    45.  
    46. INCLUDEPATH += $$PWD/../../../../usr/include
    47. DEPENDPATH += $$PWD/../../../../usr/include
    To copy to clipboard, switch view to plain text mode 


    Thank you for your time.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    That doesn't look related to Qt.
    The error complains about a difference in the C standard library that Android uses (Bionic)

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    hackree (30th July 2015)

  4. #3
    Join Date
    Jul 2015
    Posts
    7
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Android

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    Thanks for answering.

    Can you point me in the right direction? What exactly should I be looking for ?

    I've searched google a lot but the only thing that seemed related to this error was a thread in another website that, basically, said the op there shouldn't have those include libraries in the .pro file and then linked to a git repository that had some sort of tutorial. But that was clearly for more advanced users and I couldn't follow along.

    Thanks again.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    First you need to find out where this error comes from, which file the compiler is trying to comile when it hits this.

    Cheers,
    _

  6. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    The current bionic code certainly defines the macro:
    https://android.googlesource.com/pla...nclude/ctype.h
    Perhaps an earlier version does not or the consumer code complaining is in error.

  7. The following user says thank you to ChrisW67 for this useful post:

    hackree (30th July 2015)

  8. #6
    Join Date
    Jul 2015
    Posts
    7
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Android

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    Quote Originally Posted by ChrisW67 View Post
    The current bionic code certainly defines the macro:
    https://android.googlesource.com/pla...nclude/ctype.h
    Perhaps an earlier version does not or the consumer code complaining is in error.
    So what exactly is this bionic? Any ideas on how I could tackle this problem?

    I'm pretty lost right now. Google hasn't spit out anything useful or I'm not searching in the right way.

    Thanks for the answer.

  9. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    As I said, find the location of the error.

    The error message is just the "end" of the stack, find out where the file that had this error message was included from.

    Cheers,
    _

  10. The following user says thank you to anda_skoa for this useful post:

    hackree (31st July 2015)

  11. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    Bionic is a collection of C, math, dynamic linker, and C++ libraries and a linker application for Android.
    https://android.googlesource.com/platform/bionic/

  12. The following user says thank you to ChrisW67 for this useful post:

    hackree (31st July 2015)

  13. #9
    Join Date
    Jul 2015
    Posts
    7
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Android

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    Quote Originally Posted by anda_skoa View Post
    As I said, find the location of the error.

    The error message is just the "end" of the stack, find out where the file that had this error message was included from.

    Cheers,
    _
    I tried to follow the error, even before asking here, but I couldn't make any sense out of it. I'm not a real programmer so maybe I'm sounding stupid but when I followed the (bionic) error I was sent somewhere in a header file called ctype_base.h. Here's a snippet of the code around where the error.
    Qt Code:
    1. // ISO C++ 14882: 22.1 Locales
    2. //
    3.  
    4. // Information as gleaned from /usr/include/ctype.h, for solaris2.5.1
    5.  
    6. // Support for Solaris 2.5.1
    7.  
    8. #if defined (__ANDROID__)
    9. #if !defined(_U)
    10. #if !defined(_CTYPE_U)
    11. #error Bionic header ctype.h does not define either _U nor _CTYPE_U
    12. #endif
    13. #define _U _CTYPE_U
    14. #define _L _CTYPE_L
    15. #define _N _CTYPE_N
    16. #define _S _CTYPE_S
    17. #define _P _CTYPE_P
    18. #define _C _CTYPE_C
    19. #define _X _CTYPE_X
    20. #define _B _CTYPE_B
    21. #endif
    22. #endif /* __ANDROID__ */
    23.  
    24. namespace std _GLIBCXX_VISIBILITY(default)
    25. {
    26. _GLIBCXX_BEGIN_NAMESPACE_VERSION
    To copy to clipboard, switch view to plain text mode 


    I'm very new to qt so I hadn't seen those before but when I clicked the yellow exclamation mark button, some lines popped up before the error. Maybe that's where the error is caused.

    /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/locale_facets.h:41: In file included from /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/locale_facets.h:41:0,

    /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_ios.h:37: from /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/basic_ios.h:37,

    /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ios:44: from /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ios:44,

    /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ostream:38: from /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/ostream:38,

    /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:39: from /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:39,

    /home/ihaaaaa/QtProjects/freesteam/main.cpp:8: from ../freesteam/main.cpp:8:


    There also a bunch of other errors after the actual error. All of the type:

    /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/bits/ctype_base.h:62: error: '_CTYPE_U' was not declared in this scope
    static const mask upper = _U;
    ^
    /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/bits/ctype_base.h:63: error: '_CTYPE_L' was not declared in this scope
    static const mask lower = _L;
    ^

    Would you please have a look at it? Maybe you would understand what exactly is wrong.

    Thank you.

  14. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    [QUOTE=hackree;280347]/opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:39: from /opt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/iostream:39,

    /home/ihaaaaa/QtProjects/freesteam/main.cpp:8: from ../freesteam/main.cpp:8:[/Iquote]

    So you are including some standard header there in line 8 of main.cpp?

    If yes, check if the error also happens in a minimal project without Qt. If so you might want to ask on an Android forum instead,

    Cheers,
    _

  15. The following user says thank you to anda_skoa for this useful post:

    hackree (1st August 2015)

  16. #11
    Join Date
    Jul 2015
    Posts
    7
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Android

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    I've tried that. If I remove any link to C++ or anything outside QML it (the UI) compiles and runs well. Also if I try to run it as a desktop app it works. From digging around the internet I found something suggesting that the compiler is including a header from the system when it should be using one from the android ndk.

    Had no luck on finding a solution yet though.

    Thanks.

  17. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    Are you able to build, deploy, and run a simple "Hello world!" program that uses iostream for Android using your build environment?

    Your pro file does indeed include a bunch of folders for your native environment: all includes and libraries should be coming from the NDK. It also contains what looks like the wrong name for the freesteam library. Try this cut down version
    Qt Code:
    1. TEMPLATE = app
    2. QT += qml quick
    3. SOURCES += main.cpp \
    4. mysteamclass.cpp
    5. RESOURCES += qml.qrc
    6. # Additional import path used to resolve QML modules in Qt Creator's code model
    7. QML_IMPORT_PATH =
    8. # Default rules for deployment.
    9. include(deployment.pri)
    10. HEADERS += \
    11. mysteamclass.h
    12. #--------------------------------ME= C++11 AND LIBRARIES-----------------#
    13.  
    14. CONFIG+=c++11
    15. LIBS += -lgsl
    16. LIBS += -lfreesteam
    17. LIBS += -lgslcblas
    To copy to clipboard, switch view to plain text mode 

    I am assuming the the three libs have been built with the cross-compiler and installed in the NDK default library path.

  18. The following user says thank you to ChrisW67 for this useful post:

    hackree (1st August 2015)

  19. #13
    Join Date
    Jul 2015
    Posts
    7
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Android

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    Quote Originally Posted by ChrisW67 View Post
    Are you able to build, deploy, and run a simple "Hello world!" program that uses iostream for Android using your build environment?

    Your pro file does indeed include a bunch of folders for your native environment: all includes and libraries should be coming from the NDK. It also contains what looks like the wrong name for the freesteam library.
    Well, I can build and run simple programs but I have to admit that I don't know what exactly an iostream for android is.

    I am assuming the the three libs have been built with the cross-compiler and installed in the NDK default library path.
    When I installed them I just used the ./run like command from the terminal so I'm assuming the weren't built with a cross compiler! And for sure they're not in the default library path of the NDK.

    Going after what you said, it pretty much looks like I'm hopeless huh?

    Thank you very much.

  20. #14
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    If you do not have the freesteam/gsl library built for the Android target you will not get to the finish line. The linker will need these to build a working Android app even if we got past the prsent compilation-stage errors.

    It looks like you need quite a few pieces to achieve that.

  21. The following user says thank you to ChrisW67 for this useful post:

    hackree (2nd August 2015)

  22. #15
    Join Date
    Jul 2015
    Posts
    7
    Thanks
    7
    Qt products
    Qt5
    Platforms
    Unix/X11 Android

    Default Re: Error while trying to build android app. #error Bionic header ctype.h...

    Quote Originally Posted by ChrisW67 View Post
    If you do not have the freesteam/gsl library built for the Android target you will not get to the finish line. The linker will need these to build a working Android app even if we got past the prsent compilation-stage errors.

    It looks like you need quite a few pieces to achieve that.
    That's what I figured.

    It seems like I heavily underestimated the complexity that hides behind the code once deploy everywhere phrase. I couldn't even manage to deploy and create a (desktop)package for this app, let alone make it work on android.

    This may be because I'm fairly new to linux but still. In visual studio it was way easier creating executable files and distributing them. Not cross platform but still very easy to do.

    Seems like this has to wait until I find some time to dig deeper in qt and the whole things like writing .pro and make files, cmake, qmake, library cross compilations and all that stuff.

    Maybe we'll chat again sometime in the upcoming future, when I get stuck, again.

    Thank you for your time.

Similar Threads

  1. qt for android 5.5 some error
    By xiaoxiangyu in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2015, 22:15
  2. Android: Error while building/deploying project
    By JeanC in forum Installation and Deployment
    Replies: 1
    Last Post: 21st June 2015, 21:18
  3. Building error qt android
    By dmcyster@gmail.com in forum Newbie
    Replies: 1
    Last Post: 8th May 2015, 15:55
  4. Qt 5.1 for Android error
    By Baso in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th July 2013, 10:47
  5. qt5.1 create a android test app met a error
    By tsuibin in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th July 2013, 07:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.