android.mk sdl构建错误

时间:2015-08-16 21:01:57

标签: android c++ c android.mk

我已经查看了一些关于编写android.mk文件的问题,以及" make:* 没有规则来制作.o" *所需的目标.c *他们都围绕着错字,我不认为我有。

这是一个使用我的CMake构建脚本构建的SDL项目,但我无法让android.mk为我工作。

这是cmake中的项目设置

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(blp)
#set(CMAKE_MACOSX_RPATH 1)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

FIND_PACKAGE(SDL2 REQUIRED)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})

INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/source/core_math")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/source/utils/time_utils")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/source/utils/resource_utils")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/source/ren_opengl")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/source/core_engine")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/source/components/renderable2d")

INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/source/glm/vec3.hpp")

FIND_PACKAGE(SDL2 REQUIRED)
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})

FIND_PACKAGE(SDL2_IMAGE)
INCLUDE_DIRECTORIES(${SDL2_IMAGE_INCLUDE_DIR})

ADD_SUBDIRECTORY(source)
ADD_SUBDIRECTORY(project)

SET(SRC_FILES main.c)
SET(EXTERNAL_TARGET_LIBS ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY})
SET(COMPONENTS renderable2d)
SET(INTERNAL_TARGET_LIBS core_math time_utils resource_utils ren_opengl)

SET(TARGET_LIBS ${INTERNAL_TARGET_LIBS} ${EXTERNAL_TARGET_LIBS} ${COMPONENTS})

FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin/resources/)

项目子文件夹是我可以创建不同项目并重用我创建的源动态库的地方。

在源代码中,你可以看到我有一堆创建的动态库。最后是动态库和一个导入所有这些的.h和.c类,然后我在项目中导入一个.h文件以使用库。

现在进入我的android.mk文件,它还不是很完整,但这是我遇到麻烦的地方。

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := main

SDL_PATH := ../SDL

LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src/utils/time_utils/

# Add your application source files here...
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
                 utils/time_utils.c \
//removing the above line, core_engine.c throws an import error
//adding the above line I get the error listed at the bottom
                 core_engine/core_engine.c \
                 project.c


LOCAL_SHARED_LIBRARIES := SDL2

LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog

include $(BUILD_SHARED_LIBRARY)

make: *** No rule to make target `/Users/blubee/SDL/android-project/jni/src/time_utils/time_utils.c', needed by `/Users/blubee/SDL/android-project/obj/local/armeabi/objs/main/time_utils/time_utils.o'.  Stop.

每个lib都在它自己的文件夹中,就像这个项目源代码树一样

source/components/renderable2d/renderable2d.c /.h
source/core_engine/core_engine.c /.h
source/core_math/mat4_scalar/mat4_scalar.c /.h
source/core_math/vec3_scalar/vec3_scalar.c /.h
source/..
etc...

它可能是一个构建或者我在android.mk文件夹中定义源文件的顺序,我不确定。有什么建议?我还确保我的环境变量或android.mk的源文件中没有拼写错误或额外空格

1 个答案:

答案 0 :(得分:0)

似乎android.mk对标题包含的顺序要比cmake更敏感。

我将我的项目简化为一个main.c,其中包含#include" SDL.h"并且构建得很好。

我将从那里开始学习android.mk,虽然它与cmake类似,但它更挑剔。