如何使用ndk-build编译自定义文件夹结构?

时间:2012-02-29 14:22:00

标签: linker android-ndk shared-libraries

我有下一个文件夹结构:


On $ My_Eclipse_Project

  • JNI / Android.mk
  • JNI / Application.mk
  • JNI / main.cpp中
  • LIB /

On $ My_Library_Project

  • 的src /
  • 包括/
  • Android.mk

$ My_Eclipse_Project / jni / main.cpp是一个基本的makefile,它按照$ My_Library_Project / Android.mk的说明调用源代码进行编译

    # NOTE:
$(warning Compiling Android.mk from sample_cameraview_activity)

# This path
LOCAL_PATH := $(call my-dir)
$(warning Local path: $(LOCAL_PATH))

# GNU var
include $(CLEAR_VARS)

# Include extra library
include $(mylibrary_INCLUDE)/../Android.mk

# Add openCV

# Add in .bashrc enviroment var
include $(OPENCV_SHARE_MK)/OpenCV.mk

LOCAL_ARM_NEON := true

# Local libraries

LOCAL_LDLIBS += -llog -lGLESv1_CM

# Name library

LOCAL_MODULE    := camView

# Local SRC

LOCAL_SRC_FILES := main.cpp

# Shared library

include $(BUILD_SHARED_LIBRARY)

问题是,$ My_Library_Project> Android.mk没有检测到文件夹结构在等什么,因为我的源是在src文件夹上,不要在jni文件夹中。我明白了:

Android NDK: Could not find application project directory !    
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it. 

如何从$ My_Eclipse_Project编译$ My_Library_Project中的代码,并复制$ my_Eclipse_Project> lib / armeabi上生成的库,以供main.cpp使用?

提前致谢。

1 个答案:

答案 0 :(得分:4)

2个选项。您可以定义$ NDK_PROJECT_PATH = / your_ndk_path,Makefile自动检测路径并使用它进行编译,或者添加名为$ NDK_PROJECT_PATH和value / your_ndk_path的环境变量。