Hey! raylib forum is closing!

After a year with not much movement in the forum I decided to close it.

The cost of maintaining the hosting is a bit high for the usage of the platform, updating the forum and managing it is also a bit cumbersome and the truth is that I'm already trying to maintain multiple other networks pretty more active than this forum.

I'll recommend you to move to the other raylib networks:

- For a forum style, use Reddit: https://www.reddit.com/r/raylib/
- For direct messaging and questions, use Discord: https://discord.gg/VkzNHUE
- To report issues, use GitHub: https://github.com/raysan5/raylib

- Also, remember you can contact me personally on Twitter: https://twitter.com/raysan5 or directly by mail to ray[at]raylib.com

If you feel generous, you can also contribute to the project on my Patreon: https://www.patreon.com/raylib

Thanks to you all for joining the project and help to improve it with your questions. Keep it up! :)

Best Regards,

Ray

PD. Closing will be effective by October 31th.

C++ On Android

joejoe
edited January 7 in General Discussions
Hello everyone and thank you Ray for making this great library.
Everything works great with C on Android, but I cannot get the apk to work with C++ on android.
I managed to get it to make the apk but it crashes on launch. Same source game1.c and my includes works fine on desktop. I compiled with g++ and used these flags:

GP = $(ANDROID_TOOLCHAIN)/bin/arm-linux-androideabi-g++
added my header only includes to INCLUDE_PATHS
..

# Compile native_app_glue code as static library: obj/libnative_app_glue.a
compile_native_app_glue:
$(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
$(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o

# Compile project code into a shared library: lib/lib$(PROJECT_LIBRARY_NAME).so
compile_project_code: $(OBJS)
$(GP) -std=gnu++14 -o $(PROJECT_BUILD_PATH)/lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)

# Compile all .c files required into object (.o) files
# NOTE: Those files will be linked into a shared library
$(PROJECT_BUILD_PATH)/obj/%.o:%.c
$(GP) -std=gnu++14 -c $^ -o $@ $(INCLUDE_PATHS) $(CFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot
By the way the templates\advance_game\Makefile.Android did not work for me in the latest dev branch.
It works if i copy/replace it with templates\simple_game\Makefile.Android wich works fine.

Also would be nice to add after install section to avoid extra clicks :)
install:
$(ANDROID_PLATFORM_TOOLS)/adb shell monkey -p com.$(APP_COMPANY_NAME).$(APP_PRODUCT_NAME) 1

Comments

  • Hi joe! Welcome to the forum!

    I need to check it more carefully but g++ support on Android NDK is being deprecated (I think it has some issues), they are moving to clang compiler.

    Also, if using github raylib develop branch, LOT of things have changed and it could be not stable...

    I'll try to review it this week and let you know.
  • Thanks. I'm learning c/c++ along with raylib please excuse my ignorance :smile:
  • joejoe
    edited January 9
    IT WORKS NOW! I used the wrong flag to make the toolchain! I used -stl-libc++:
    python make_standalone_toolchain.py --arch arm --api 16 --stl=libc++ --install-dir=ndk_toolchain_arm_api16_libc++

    I got it working with gnustl :
    python make_standalone_toolchain.py --arch arm --api 16 --stl=gnustl --install-dir=ndk_toolchain_arm_api16_gnustl

    I read gnustl is default. I should have left it out from the start! Working setting below:

    ..

    CXXFLAGS = -std=c++14 -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16
    CXXFLAGS += -ffunction-sections -funwind-tables -fstack-protector-strong -fPIC
    CXXFLAGS += -Wall -Wa,--noexecstack -Wformat -Werror=format-security -no-canonical-prefixes
    CXXFLAGS += -DANDROID -DPLATFORM_ANDROID -D__ANDROID_API__=16

    ..

    # Generate target objects list from PROJECT_SOURCE_FILES
    OBJS = $(patsubst %.cpp, $(PROJECT_BUILD_PATH)/obj/%.o, $(PROJECT_SOURCE_FILES))

    ..

    compile_native_app_glue:
    $(CC) -c $(RAYLIB_PATH)/src/external/android/native_app_glue/android_native_app_glue.c -o $(PROJECT_BUILD_PATH)/obj/native_app_glue.o $(CFLAGS)
    $(AR) rcs $(PROJECT_BUILD_PATH)/obj/libnative_app_glue.a $(PROJECT_BUILD_PATH)/obj/native_app_glue.o

    compile_project_code: $(OBJS)
    $(GP) -o $(PROJECT_BUILD_PATH)/lib/armeabi-v7a/lib$(PROJECT_LIBRARY_NAME).so $(OBJS) -shared $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS)

    $(PROJECT_BUILD_PATH)/obj/%.o:%.cpp
    $(GP) -c $^ -o $@ $(INCLUDE_PATHS) $(CXXFLAGS) --sysroot=$(ANDROID_TOOLCHAIN)/sysroot

  • Hi joe!

    Glad to read you manage to get it working! That's amazing! :smiley:

    Please, keep me updated with your progress!

    Ray
Sign In or Register to comment.