0
\$\begingroup\$

I have successfully compiled SDL for Android using the example, which uses C. Is it possible to use C++ too?

I am trying to port a C++ game which uses SDL 2 to Android.

If it is possible, how can I do this?

\$\endgroup\$
1
\$\begingroup\$

The principles are exactly the same:

  1. you write your game in c++
  2. create the cmake files to compile your project
  3. hit ndk_build

In general ndk_build can compile both c and c++, so it doesn't really matter which one you choose. I've actually only used SDL2 bundled with c++ code and it compiles perfectly.

\$\endgroup\$
  • \$\begingroup\$ Did you compile SDL itself in C and added C++ code? Or did you compile both in C++? \$\endgroup\$ – Z0q Oct 12 '16 at 10:06
  • \$\begingroup\$ SDL2 comes with a cmakefile. I just added that library in my own cmake using "$(call import-module, SDL)" \$\endgroup\$ – Ali1S232 Oct 12 '16 at 10:13
  • 1
    \$\begingroup\$ by the way there is no indicator in cmake file to tell whether the project is written in c or c++, except file extensions. you can take a look at my complete cmake file if it helps. \$\endgroup\$ – Ali1S232 Oct 12 '16 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.