user468311
user468311

Reputation:

Can't build Android/NDK project in Eclipse with CDT after converting it to c++ project

I try to build QCAR SDK project sample. It's an Android+NDK project. When I used ndk-build via shell it worked fine, but then I converted project to C++ project using Eclipse CDT. Now I can't build it in Eclipse:

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

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

**** Build Finished ****

Here's 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)

I tried to create custom builder following this tutorial but nothing helped. List of builders: enter image description here

Environment:

Windows 7 32

GNU Make 3.82.90

g++ 3.4.4

android-ndk r6

Eclipse Indigo

Will appreciate any help. Thanks.

Upvotes: 0

Views: 4139

Answers (2)

Ravi
Ravi

Reputation: 487

Go to Window->Preferences->Android->NDK

In "NDK Location" text box add path to NDK(Windows version) (For instance, C:\android-ndk-r6)

Upvotes: 1

user468311
user468311

Reputation:

I remembered that I tried fastcv samples and described technique worked. So I browsed it and found another makefile in the root of the project. I've added it to the QCAR sample and now it seems to work. I'm new to makefiles, but I think that the key is in defining 'all' as '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

Upvotes: 1

Related Questions