【问题标题】:Can't build Android/NDK project in Eclipse with CDT after converting it to c++ project将其转换为 c++ 项目后,无法在 Eclipse 中使用 CDT 构建 Android/NDK 项目
【发布时间】:2011-12-13 15:11:08
【问题描述】:

我尝试构建QCAR SDK 项目示例。这是一个Android+NDK项目。当我通过 shell 使用 ndk-build 时,它运行良好,但随后我使用 Eclipse CDT 将项目转换为 C++ 项目。现在我无法在 Eclipse 中构建它:

**** Build of configuration Default for project ImageTargets ****

make all 
make: *** No rule to make target `all'.  Stop.

**** Build Finished ****

这里是 Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := QCAR-prebuilt
LOCAL_SRC_FILES = ../../../build/lib/$(TARGET_ARCH_ABI)/libQCAR.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../build/include
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := ImageTargets

TARGET_PLATFORM := android-5

USE_OPENGL_ES_1_1 := false

ifeq ($(USE_OPENGL_ES_1_1), true)
    OPENGLES_LIB  := -lGLESv1_CM
    OPENGLES_DEF  := -DUSE_OPENGL_ES_1_1
else
    OPENGLES_LIB  := -lGLESv2
    OPENGLES_DEF  := -DUSE_OPENGL_ES_2_0
endif

LOCAL_CFLAGS := -Wno-write-strings $(OPENGLES_DEF)
LOCAL_LDLIBS := \
    -llog $(OPENGLES_LIB)
LOCAL_SHARED_LIBRARIES := QCAR-prebuilt
LOCAL_SRC_FILES := ImageTargets.cpp SampleUtils.cpp Texture.cpp
LOCAL_ARM_MODE := arm
include $(BUILD_SHARED_LIBRARY)

我尝试在this tutorial 之后创建自定义构建器,但没有任何帮助。 建设者名单:

环境:

Windows 7 32

GNU Make 3.82.90

g++ 3.4.4

android-ndk r6

日蚀靛蓝

将不胜感激任何帮助。谢谢。

【问题讨论】:

  • 这不是 C++ 项目,而是 Android 项目。删除 CDT 构建器并启用原生的。
  • 转换为 C++ 项目并不能使其成为“纯 C++ 项目”,它只会添加 C++ 代码辅助以及原生和 android 构建等功能。后一个是我的目标。

标签: android eclipse makefile java-native-interface android-ndk


【解决方案1】:

我记得我尝试过 fastcv 示例并且描述的技术有效。于是我浏览了一下,在项目的根目录下发现了另一个makefile。我已将它添加到 QCAR 示例中,现在它似乎可以工作了。 我是 makefile 的新手,但我认为关键在于将 'all' 定义为 'ndk-build':

#
# Determine host system and architecture from the environment
# (Borrowed from NDK makefile "init.mk"
#

HOST_OS := $(strip $(HOST_OS))
ifndef HOST_OS
    # On all modern variants of Windows (including Cygwin and Wine)
    # the OS environment variable is defined to 'Windows_NT'
    #
    # The value of PROCESSOR_ARCHITECTURE will be x86 or AMD64
    #
    ifeq ($(OS),Windows_NT)
        HOST_OS := windows
    else
        # For other systems, use the `uname` output
        UNAME := $(shell uname -s)
        ifneq (,$(findstring Linux,$(UNAME)))
            HOST_OS := linux
        endif
        ifneq (,$(findstring Darwin,$(UNAME)))
            HOST_OS := darwin
        endif
        # We should not be there, but just in case !
        ifneq (,$(findstring CYGWIN,$(UNAME)))
            HOST_OS := windows
        endif
        ifeq ($(HOST_OS),)
            $(error Unable to determine HOST_OS from uname -s: $(UNAME))
            $(error Please define HOST_OS in your environment.)
        endif
    endif
    $(info Host OS was auto-detected: $(HOST_OS))
else
    $(info Host OS from environment: $(HOST_OS))
endif

#
# Define function to fix path names to work with Make
#
ifeq ($(HOST_OS),windows)
    fixpath = $(shell cygpath $(subst \,/,$(1)))
else
    fixpath = $(1)
endif

# Fix working directory path for NDK tools
PWD := $(call fixpath,$(PWD))

# Fix Android NDK root path
ANDROID_NDK_ROOT := $(call fixpath,$(ANDROID_NDK_ROOT))

all:
    @$(ANDROID_NDK_ROOT)ndk-build 

clean:
    @$(ANDROID_NDK_ROOT)ndk-build clean

【讨论】:

    【解决方案2】:

    转到窗口->首选项->Android->NDK

    在“NDK 位置”文本框中添加 NDK 的路径(Windows 版本)(例如,C:\android-ndk-r6)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-23
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      • 2011-01-26
      • 1970-01-01
      • 2014-09-23
      • 1970-01-01
      相关资源
      最近更新 更多