Android dirent.h opendir() 不会编译



我目前无法编译 dirent.h 函数,如 opendir()。我做了什么?我确定我有这个工作。

Android_Utils.cpp:

#include <dirent.h>
void Test1237( void )
{
    struct DIR *dir = opendir( "blah" );
}

我的 Android.mk 文件:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SDL2-prebuilt
LOCAL_SRC_FILES := /work/SDL2/lib-android/$(TARGET_ARCH_ABI)/libSDL2.so
include $(PREBUILT_SHARED_LIBRARY)
# --------------------------------------------------------------------------------------------------
JNI_LIBPATH := /work/TT/android-TT/jniLibs
include $(CLEAR_VARS)
LOCAL_MODULE := libfreetype2
LOCAL_SRC_FILES := /work/FreeType2/Android/$(TARGET_ARCH_ABI)/libfreetype2-static.a
include $(PREBUILT_STATIC_LIBRARY)

# --------------------------------------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := main
SDL_PATH := /work/SDL2-2.0.4
GLM_PATH := /work/glm
GLM_NDK_PATH1 := /Android/android-ndk-r9d/platforms/android-14/arch-arm/usr/include
GLM_NDK_PATH2 := /Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.4.3/include
GLM_NDK_PATH3 := /Android/android-ndk-r9d/cxx-stl/gnu-libstdc++/4.4.3/libs/armeabi-v7a/include
TT_PATH := /work/TT
TT_INCLUDES := $(TT_PATH) 
LOCAL_C_INCLUDES := $(TT_INCLUDES) $(SDL_PATH)/include $(GLM_NDK_PATH1) $(GLM_NDK_PATH2) $(GLM_NDK_PATH3) $(GLM_PATH) $(FT2_INCLUDES)
MY_CFLAGS     := -DANDROID_PDS -mfloat-abi=softfp -mfpu=neon
ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), armeabi-v7a x86))
    LOCAL_CFLAGS := -DHAVE_NEON=1 $(MY_CFLAGS) -Wno-write-strings -Wno-trigraphs
    LOCAL_CPPFLAGS := -Wno-conversion-null -fno-permissive
    LOCAL_ARM_MODE := arm
    LOCAL_ARM_NEON := true
endif
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c 
    $(TT_PATH)/Android_Utils.cpp 
    $(TT_PATH)/main.cpp
LOCAL_SHARED_LIBRARIES := SDL2-prebuilt
LOCAL_STATIC_LIBRARIES := libfreetype2 
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog -lm
include $(BUILD_SHARED_LIBRARY)

输出:

SparkbookPro:jni admin$ ndk-build
[armeabi-v7a] Install        : libSDL2.so => libs/armeabi-v7a/libSDL2.so
[armeabi-v7a] Compile arm    : main <= SDL_android_main.c
[armeabi-v7a] Compile++ arm  : main <= Android_Utils.cpp
/work/TT/Android_Utils.cpp: In function 'void Test1237()':
/work/TT/Android_Utils.cpp:12:39: error: 'opendir' was not declared in this scope

啊哈!我的包含路径中有一个本地的dirent.h副本,因此不包括标准副本。

相关内容

  • 没有找到相关文章

最新更新