ndk-build does not find header files in example code

1,780 views
Skip to first unread message

Seth Tucker

unread,
Jan 16, 2016, 12:34:28 PM1/16/16
to android-ndk
Hi,
   I'm trying to get the eclipse tool-chain working because I need to work on the NDK. So for it's going terribly. After a lot of effort I was able to get the SDK compiling and running, but the NDK has a problem that I am totally unable to resolve. 

Every time I try to build the hello-jni example app, Eclipse throws a "can't find string.h no such file or directory." error. That's a standard header file, so I have no idea where the compiler typically looks for it, and I have no idea where the configuration for NDK build is buried, or why it's broken. I am on Ubuntu 15.10, using eclipse 4.5.1.  Any ideas?

If not, can anyone share a working ndk configuration? Downloading the latest versions of everything didn't seem to be very helpful for me.

Thanks!

GameCodingNinja

unread,
Jan 17, 2016, 1:59:12 PM1/17/16
to android-ndk
Yeah, it's a pain to get everything working at first. Perhaps my settings might shed some light on what you might be missing. I believe you have to specify that you want to use STL. There's a few options like stlport_static or gnustl_static.

Application.mk
# Uncomment this if you're using STL in your project
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
# APP_STL := stlport_static
# APP_ABI := armeabi armeabi-v7a x86
APP_STL
:= gnustl_static
APP_ABI
:= armeabi-v7a
# Needed for debugging
APP_PLATFORM
:= android-10


Android.mk
LOCAL_PATH := $(call my-dir)

include $
(CLEAR_VARS)

LOCAL_MODULE
:= template

SDL_PATH
:= ../SDL
ASCRIPT_PATH
:= $(LOCAL_PATH)/../angelscript

LOCAL_C_INCLUDES
:= \
    $
(SDL_PATH)/include \
    $
(LOCAL_PATH)/library \
    $
(LOCAL_PATH)/../boost \
    $
(ASCRIPT_PATH)/add_on

LOCAL_EXPORT_C_INCLUDES
:= $(LOCAL_C_INCLUDES)

LOCAL_CXXFLAGS
:= -std=gnu++11 -fexceptions

LOCAL_SRC_FILES
:= \
    $
(SDL_PATH)/src/main/android/SDL_android_main.c \
    $
(subst $(LOCAL_PATH)/,, \
    $
(wildcard $(LOCAL_PATH)/source/game/*.cpp) \
    $(wildcard $(LOCAL_PATH)/source/smartGUI/*.cpp) \
    $(wildcard $(LOCAL_PATH)/source/state/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/gui/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/objectdata/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/system/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/managers/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/physics/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/2d/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/common/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/utilities/*.cpp) \
    $(wildcard $(LOCAL_PATH)/library/soil/*.c) \
    $(wildcard $(LOCAL_PATH)/library/script/*.cpp))

LOCAL_SHARED_LIBRARIES := SDL2 SDL2_mixer Box2D angelscript

LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid

include $(BUILD_SHARED_LIBRARY)

Also

Alex Cohn

unread,
Jan 17, 2016, 1:59:52 PM1/17/16
to android-ndk
Maybe this SO article will be relevant for you: http://stackoverflow.com/a/16891713/192373

Seth Tucker

unread,
Jan 26, 2016, 2:46:38 PM1/26/16
to android-ndk
I tried explicitly specifying that with the APP_STL := gnustl_static command.

The thing is, this is just the most basic example app, so if this isn't working, so it really only needs to find string.h. I can see string.h in the NDK directory, but it fails even when I run ndk-build from the command line. Nothing I have done helps at all. I think it may not be worth trying to deal with. If it's this much trouble with a simple example, I don't think it's going to be practical to work with an sdk.

Thanks,
Seth

GameCodingNinja

unread,
Jan 26, 2016, 4:56:39 PM1/26/16
to android-ndk
Have you tried these includes?

#include <string>
#include <cstring>

You may not be able to include string.h specifically. What is it you are trying to accomplish? Perhaps you can find similar string related calls under the above includes?
Reply all
Reply to author
Forward
0 new messages