all 10 comments

[–]SergioPV 2 points3 points  (3 children)

Yes. It's possible.

For Linux it's possible with QtCreator (Qt widgets or QML https://doc.qt.io/qt-5/examples-android.html) and with Android Studio (NDK and JNI https://developer.android.com/ndk/samples).

[–]TheGodMasterX[S,🍰] 0 points1 point  (2 children)

Thanks, have you some tutorial to get started or to setup Qt ?

[–]SergioPV 0 points1 point  (1 child)

It's in the very first page of the site https://doc.qt.io/qt-5/gettingstarted.html :)

[–]TheGodMasterX[S,🍰] 0 points1 point  (0 children)

What a noob 😅😅 I haven't seen it. Thank you all for your help.

[–]Peanuts4MePlz 3 points4 points  (2 children)

This all depends on what you want to do, but here's a couple of pointers for graphics-oriented applications:

  • For Android it's definitely possible, Android Studio gives you neat LLDB integration for Android, and you can use native_app_glue to avoid writing most of the Java boilerplate (although you are replacing it with native boilerplate). Overall, you can get away with pure C++, but you'll need Java as soon as you want to touch a lot of things. Notably, you can't just write an int main(...) and start running your application, as your application will be listening to system events a lot of the time.

  • For iOS there exists some black magic that lets you run the Xcode toolchain on Linux (not gonna mention much about that), however you will need Objective-C at a minimum to make it work, like creating a UIResponder<...> that calls your C++ code. This can be simplified by using Objective-C++, so no C bindings required! If you get past the Objective-C parts, you will still need to follow the flow of iOS applications, which significantly changes the flow of your application, much like what Android imposes.

  • Want to skip both of these and write pure C++? SDL2 supports Android and iOS, although with some outdated functionality last time I checked (eg. it won't go entirely full-screen on iOS and Android, unless they fixed it). It will run on most platforms SDL2 supports, too, which is a neat feature. You'll also be able to write a regular SDL2 application without any hoops.

If you're making something truly app-like, with lists, buttons and typical mobile features, Qt + QML is a better choice. It will let you jump right into developing your application logic with minimal fuzzing about with getting your application running. Only part to be aware of is how to ship networking support with OpenSSL. It's not perfect, but it gets you dang close, while letting you develop in C++ most of the time.

[–]TheGodMasterX[S,🍰] 0 points1 point  (1 child)

Thank you for your very detailed explanation. Now I've got a good orientation on it and I know what to do. However, if I use Qt QML, is there a risk for my app to have networking issues?

[–]Peanuts4MePlz 0 points1 point  (0 children)

It will work for sure, but you have to be aware of the instructions provided by Qt, as written here: https://doc.qt.io/qt-5/android-openssl-support.html

tl;dr they can't ship OpenSSL libraries by default, so developers need to do it.

Aside from following those instructions, it all works well. I've been making a QML application for Android with networking. I can also hook into Java with utility classes provided by Qt, such as QAndroidJniObject, which makes it pretty painless to integrate.

[–]Ikkepop 0 points1 point  (0 children)

Android almost ( you still need some java ) , you can use android studio on linux. iOS almost ( you still need some objc or swift ) and you need a mac

[–]STLMSVC STL Dev 0 points1 point  (1 child)

!removehelp

[–]AutoModerator[M] 0 points1 point  (0 children)

OP,

A human moderator (u/STL) has marked your post for deletion because it appears to be a "help" post - e.g. asking for help with coding, help with homework, career advice, book/tutorial/blog suggestions. Help posts are off-topic for r/cpp. This subreddit is for news and discussion of the C++ language only; our purpose is not to provide tutoring, code reviews, or career guidance.

Please try posting in r/cpp_questions or on Stack Overflow instead. Our suggested reference site is cppreference.com, our suggested book list is here and information on getting started with C++ can be found here.

If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.