Problems with includes when migrating to experimental gradle Android Studio 2.0+ - c

My problem goes beyond of what the title says so will give a background before the question. I've been experimenting issues since I updated from Android Studio 1.5 to 2.0 (now using 2.1.1 Stable, tried beta version as well)
Background
When I updated my Android Studio and opened c files in NDK y started receiving the following message:
This message appears even though I have already synced the project.
The compiler was working fine, as I could ignore modify things in c and it would still compile. Then I tried to add a new include of a file created by me which contains some settings and methods, the same file is included in other files working well. However, this time the compiler throws me the following error:
error: undefined reference to 'my_method'
Spent quite a while debugging but was unsuccessful, so decided to migrate to experimental gradle where this problem does not happen.
Here is what I'm using now:
- gradle-experimental:0.7.0
- wraper: gradle-2.10-all.zip
My gradle file is this:
apply plugin: 'com.android.model.application'
import org.apache.tools.ant.taskdefs.condition.Os
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig.with {
applicationId "com.domain.myapp"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 23
versionCode 1
versionName "1.0"
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
}
}
}
task runSwig(type: Exec, description: 'Run swig config') {
workingDir 'src/main'
commandLine 'cmd', '/c', 'swig.bat'
}
ndk {
moduleName "MyNativeModule"
//toolchain "clang"
}
sources.main {
jni {
source {
srcDir 'src/main/libs' //set .so files location to libs
srcDirs = [] //disable automatic ndk-build call
}
}
}
buildTypes {
debug {
debuggable true
ndk.with {
debuggable = true
}
versionNameSuffix "1.0"
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'org.litepal.android:core:1.2.1'
}
Now, when I run clean it finishes successfully, but..
Now the problem:
*I'm using a libusb library
When I try to build, I get the following errors:
-Error:(20, 20) config.h: No such file or directory
-Error:(33, 30) libkern/OSAtomic.h: No such file or directory
-Error:(29, 25) dev/usb/usb.h: No such file or directory
... many others like these
In the case of config.h in the library it's included like this:
#include <config.h>
so since I have that file in a parent directory in the library, I managed to make it work this way:
#include "../config.h>
On the other hand for the other files, I don't have the directories nor the files in the library so I cannot reference them. Besides, I see these files belong to MacOS when I google them.
With standard gradle this is not a problem as it compiles like a charm!
My questions are:
Why is this happening? is there some compilation flag I'm missing to ignore these files?
How can I fix this issue, what would be the best approach?
What I've already tried:
Update NDK from 11 to 12
Switch from stable Android Studio to Beta channel and back
Tried different gradle versions stable and experimental
As I'm getting familiar with NDK and C my question might be to obvios, any help will be much appreciated!
Update
I'm building libusb library as I made some changes to it. (with stable gradle this works fine except for the problem I described above, before the update I have been using this setup for a few months, everything working as expected)
My directory structure is as follows:
-jni
-jni/myUSB/libusb
Here are my Android.mk files so you see how I'm building them:
jni:
LOCAL_PATH := $(call my-dir)
ROOT_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
LOCAL_PATH := $(ROOT_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := myModuleName
LOCAL_CFLAGS := -O2 -ffast-math
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := \
jiw.cpp \
mainFile.c \
otherFile.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/
LOCAL_SHARED_LIBRARIES := myUSB
include $(BUILD_SHARED_LIBRARY)
myUSB:
LOCAL_PATH := $(call my-dir)
ROOTUSB_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
LOCAL_PATH := $(ROOTUSB_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := myUSB
LOCAL_CFLAGS := -O2 -ffast-math
LOCAL_LDLIBS := -llog -pthread
LOCAL_SRC_FILES := \
myUsbMainFile.c \
myUsbInterface.c \
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/
LOCAL_SHARED_LIBRARIES := android-usb
include $(BUILD_SHARED_LIBRARY)
libusb:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := android-usb
LOCAL_CFLAGS := -O2 -ffast-math
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := \
core.c \
descriptor.c \
io.c \
sync.c \
os/linux_usbfs.c \
os/threads_posix.c \
os/android_java.c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/ \
$(LOCAL_PATH)/os
include $(BUILD_SHARED_LIBRARY)

I can't see, where you connect libusb to your project. So, you probably have to link it manually. Here is an example, how to link libraries statically/dynamically in build.gradle.

Related

TensorFlow static C API library - how to link with 10 sub-dependencies?

I am trying to link with static C API version of the TensorFlow library.
I built the static library using the following commands:
// get the sources
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
// create a build directory
mkdir builddir
cd builddir
// build the lib using CMake
cmake -S ../tensorflow_src/tensorflow/lite/c -DTFLITE_C_BUILD_SHARED_LIBS:BOOL=OFF
cmake --build . -j
This builds the libtensorflow-lite.a. However, the libtensorflow-lite.a is not self-contained and has its own set of 10 dependencies, stated here in the CMake file:
# TensorFlow Lite dependencies.
find_package(absl REQUIRED)
find_package(eigen REQUIRED)
find_package(farmhash REQUIRED)
find_package(fft2d REQUIRED)
find_package(flatbuffers REQUIRED)
find_package(gemmlowp REQUIRED)
find_package(neon2sse REQUIRED)
find_package(clog REQUIRED)
find_package(cpuinfo REQUIRED) #CPUINFO is used by XNNPACK and RUY library
find_package(ruy REQUIRED)
The question is, how do I find out the .a names of the required sub-libraries?
I used find ./builddir -type f -name "*.a" to list the libraries built by CMake, and expected roughly 10 libs, but the actual list is too long:
./_deps/xnnpack-build/libXNNPACK.a
./_deps/ruy-build/ruy/libruy_pack_avx2_fma.a
./_deps/ruy-build/ruy/libruy_have_built_path_for_avx2_fma.a
./_deps/ruy-build/ruy/libruy_block_map.a
./_deps/ruy-build/ruy/libruy_system_aligned_alloc.a
./_deps/ruy-build/ruy/libruy_have_built_path_for_avx512.a
./_deps/ruy-build/ruy/profiler/libruy_profiler_instrumentation.a
./_deps/ruy-build/ruy/libruy_trmul.a
./_deps/ruy-build/ruy/libruy_cpuinfo.a
./_deps/ruy-build/ruy/libruy_blocking_counter.a
./_deps/ruy-build/ruy/libruy_pack_arm.a
./_deps/ruy-build/ruy/libruy_apply_multiplier.a
./_deps/ruy-build/ruy/libruy_kernel_avx2_fma.a
./_deps/ruy-build/ruy/libruy_prepacked_cache.a
./_deps/ruy-build/ruy/libruy_tune.a
./_deps/ruy-build/ruy/libruy_context_get_ctx.a
./_deps/ruy-build/ruy/libruy_have_built_path_for_avx.a
./_deps/ruy-build/ruy/libruy_ctx.a
./_deps/ruy-build/ruy/libruy_wait.a
./_deps/ruy-build/ruy/libruy_allocator.a
./_deps/ruy-build/ruy/libruy_context.a
./_deps/ruy-build/ruy/libruy_kernel_avx.a
./_deps/ruy-build/ruy/libruy_prepare_packed_matrices.a
./_deps/ruy-build/ruy/libruy_pack_avx512.a
./_deps/ruy-build/ruy/libruy_kernel_arm.a
./_deps/ruy-build/ruy/libruy_denormal.a
./_deps/ruy-build/ruy/libruy_kernel_avx512.a
./_deps/ruy-build/ruy/libruy_frontend.a
./_deps/ruy-build/ruy/libruy_pack_avx.a
./_deps/ruy-build/ruy/libruy_thread_pool.a
./_deps/flatbuffers-build/libflatbuffers.a
./_deps/fft2d-build/libfft2d_fftsg2d.a
./_deps/fft2d-build/libfft2d_fftsg.a
./_deps/farmhash-build/libfarmhash.a
./_deps/clog-build/libclog.a
./_deps/abseil-cpp-build/absl/synchronization/libabsl_graphcycles_internal.a
./_deps/abseil-cpp-build/absl/synchronization/libabsl_synchronization.a
./_deps/abseil-cpp-build/absl/strings/libabsl_strings.a
./_deps/abseil-cpp-build/absl/strings/libabsl_str_format_internal.a
./_deps/abseil-cpp-build/absl/strings/libabsl_cord.a
./_deps/abseil-cpp-build/absl/strings/libabsl_strings_internal.a
./_deps/abseil-cpp-build/absl/status/libabsl_status.a
./_deps/abseil-cpp-build/absl/hash/libabsl_city.a
./_deps/abseil-cpp-build/absl/hash/libabsl_wyhash.a
./_deps/abseil-cpp-build/absl/hash/libabsl_hash.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_reflection.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_program_name.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_internal.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_private_handle_accessor.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_marshalling.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag_internal.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_commandlineflag.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags_config.a
./_deps/abseil-cpp-build/absl/flags/libabsl_flags.a
./_deps/abseil-cpp-build/absl/numeric/libabsl_int128.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_symbolize.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_debugging_internal.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_demangle_internal.a
./_deps/abseil-cpp-build/absl/debugging/libabsl_stacktrace.a
./_deps/abseil-cpp-build/absl/base/libabsl_spinlock_wait.a
./_deps/abseil-cpp-build/absl/base/libabsl_raw_logging_internal.a
./_deps/abseil-cpp-build/absl/base/libabsl_malloc_internal.a
./_deps/abseil-cpp-build/absl/base/libabsl_throw_delegate.a
./_deps/abseil-cpp-build/absl/base/libabsl_exponential_biased.a
./_deps/abseil-cpp-build/absl/base/libabsl_base.a
./_deps/abseil-cpp-build/absl/base/libabsl_log_severity.a
./_deps/abseil-cpp-build/absl/time/libabsl_time_zone.a
./_deps/abseil-cpp-build/absl/time/libabsl_civil_time.a
./_deps/abseil-cpp-build/absl/time/libabsl_time.a
./_deps/abseil-cpp-build/absl/container/libabsl_hashtablez_sampler.a
./_deps/abseil-cpp-build/absl/container/libabsl_raw_hash_set.a
./_deps/abseil-cpp-build/absl/types/libabsl_bad_variant_access.a
./_deps/abseil-cpp-build/absl/types/libabsl_bad_optional_access.a
./_deps/cpuinfo-build/libcpuinfo.a
The state of the libs seems to be the following:
absl: 30 libraries found
eigen: OK, template library defined in the headers
farmhash: OK, 1 library found
fft2d: OK, 2 libraries found
flatbuffers: OK, 1 library found
gemmlowp: OK, headers only
neon2sse: OK, headers only
clog: OK, 1 library found
cpuinfo: OK, 1 library found
ruy: 30 libraries found
All in all, most libs are OK, either there is 1 lib to link with, or the libs are header-only. What remains to be the problem are:
absl
ruy
because they contain about 30 .a libs.
Not sure if I have to link with all of those? It would be very cumbersome, as my build system is Meson and I am using custom_target() to link with TensorFlow.
A year later, but I just went through this myself, so here goes my answer.
Based on my experience (using a makefile and without your -DTFLITE_C_BUILD_SHARED_LIBS:BOOL=OFF) a program that performs inference does not need to link to Abseil.
You need to link to all other libs you mentioned, except ruy_kernel_arm and ruy_pack_arm, assuming you're running your program on the x64 platform. (Annoyingly -DTFLITE_ENABLE_RUY=OFF is not respected when building TfLite, so you're stuck with Ruy)
Detailed steps:
Build TfLite:
mkdir ~/my_tflite_project
cd ~/my_tflite_project/
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
mkdir tflite_build_x64
cd tflite_build_x64/
cmake ../tensorflow_src/tensorflow/lite/
/* You may encounter two CMake messages:
-- The Fortran compiler identification is unknown
I believe a Fortran compiler is only necessary to build Fortran bindings for TfLite.
-- Could NOT find CLANG_FORMAT: Found unsuitable version "0.0", but required is exact version "9" (found CLANG_FORMAT_EXECUTABLE-NOTFOUND)
sudo apt install clang-format-9
Annoyingly you need clang-format-9, plain clang-format (version 13, the newest) won't do. */
cmake --build . -j 4
Relevant libs:
$ cd ~/my_tflite_project/tflite_build_x64
$ ls *.a
libtensorflow-lite.a
$ ls pthreadpool/*.a
pthreadpool/libpthreadpool.a
$ ls _deps/*/*.a
_deps/clog-build/libclog.a _deps/farmhash-build/libfarmhash.a _deps/fft2d-build/libfft2d_fftsg2d.a _deps/xnnpack-build/libXNNPACK.a
_deps/cpuinfo-build/libcpuinfo.a _deps/fft2d-build/libfft2d_fftsg.a _deps/flatbuffers-build/libflatbuffers.a
$ ls _deps/ruy-build/ruy/*.a
_deps/ruy-build/ruy/libruy_allocator.a _deps/ruy-build/ruy/libruy_ctx.a _deps/ruy-build/ruy/libruy_kernel_avx.a _deps/ruy-build/ruy/libruy_prepacked_cache.a
_deps/ruy-build/ruy/libruy_apply_multiplier.a _deps/ruy-build/ruy/libruy_denormal.a _deps/ruy-build/ruy/libruy_kernel_avx2_fma.a _deps/ruy-build/ruy/libruy_prepare_packed_matrices.a
_deps/ruy-build/ruy/libruy_block_map.a _deps/ruy-build/ruy/libruy_frontend.a _deps/ruy-build/ruy/libruy_kernel_avx512.a _deps/ruy-build/ruy/libruy_system_aligned_alloc.a
_deps/ruy-build/ruy/libruy_blocking_counter.a _deps/ruy-build/ruy/libruy_have_built_path_for_avx.a _deps/ruy-build/ruy/libruy_pack_arm.a _deps/ruy-build/ruy/libruy_thread_pool.a
_deps/ruy-build/ruy/libruy_context.a _deps/ruy-build/ruy/libruy_have_built_path_for_avx2_fma.a _deps/ruy-build/ruy/libruy_pack_avx.a _deps/ruy-build/ruy/libruy_trmul.a
_deps/ruy-build/ruy/libruy_context_get_ctx.a _deps/ruy-build/ruy/libruy_have_built_path_for_avx512.a _deps/ruy-build/ruy/libruy_pack_avx2_fma.a _deps/ruy-build/ruy/libruy_tune.a
_deps/ruy-build/ruy/libruy_cpuinfo.a _deps/ruy-build/ruy/libruy_kernel_arm.a _deps/ruy-build/ruy/libruy_pack_avx512.a _deps/ruy-build/ruy/libruy_wait.a
Construct MWE using TfLite:
$ cd ~/my_tflite_project
$ mkdir my_dev_x64
$ cd my_dev_x64/
/* Construct minimal.cpp and makefile below */
$ cat minimal.cpp
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include <iostream>
int main() {
std::unique_ptr<tflite::FlatBufferModel> model = tflite::FlatBufferModel::BuildFromFile("your_network_here.tflite");
tflite::ops::builtin::BuiltinOpResolver resolver;
std::cout "Done\n";
return EXIT_SUCCESS;
}
$ cat makefile
COMPILER := g++
LINKER := g++
CXX_FILES := minimal.cpp
OBJ_FILES := $(CXX_FILES:.cpp=.o)
EXE_FILE := app
INCLUDE_DIRS := -I../tensorflow_src -I../tflite_build_x64/flatbuffers/include
LIB_DIRS := \
-L../tflite_build_x64 \
-L../tflite_build_x64/_deps/fft2d-build \
-L../tflite_build_x64/_deps/flatbuffers-build \
-L../tflite_build_x64/_deps/ruy-build/ruy \
-L../tflite_build_x64/_deps/farmhash-build \
-L../tflite_build_x64/_deps/xnnpack-build \
-L../tflite_build_x64/_deps/cpuinfo-build \
-L../tflite_build_x64/_deps/clog-build \
-L../tflite_build_x64/pthreadpool
LIBS := \
-ltensorflow-lite \
-lfft2d_fftsg \
-lfft2d_fftsg2d \
-lflatbuffers \
-lruy_ctx \
-lruy_allocator \
-lruy_frontend \
-lruy_context_get_ctx \
-lruy_context \
-lruy_apply_multiplier \
-lruy_prepacked_cache \
-lruy_tune \
-lruy_cpuinfo \
-lruy_system_aligned_alloc \
-lruy_prepare_packed_matrices \
-lruy_trmul \
-lruy_block_map \
-lruy_denormal \
-lruy_thread_pool \
-lruy_blocking_counter \
-lruy_wait \
-lruy_kernel_avx \
-lruy_kernel_avx2_fma \
-lruy_kernel_avx512 \
-lruy_pack_avx \
-lruy_pack_avx2_fma \
-lruy_pack_avx512 \
-lruy_have_built_path_for_avx \
-lruy_have_built_path_for_avx2_fma \
-lruy_have_built_path_for_avx512 \
-lfarmhash \
-lXNNPACK \
-lpthreadpool \
-lcpuinfo \
-lclog
CXX_FLAGS := -Wall #-pedantic
LINK_FLAGS :=
#Do not print the output of the commands
.SILENT:
#Phony targets do not represent actual files, so files with the following names are ignored
.PHONY: clean depend
#Link object files to form an executable file
$(EXE_FILE): $(OBJ_FILES)
$(LINKER) $(LINK_FLAGS) $(OBJ_FILES) -o $(EXE_FILE) $(LIB_DIRS) $(LIBS)
#Compile cpp files to object files
%.o: %.cpp
$(COMPILER) $(CXX_FLAGS) $(INCLUDE_DIRS) -c $<
#Remove object files, executable, and possible linkinfo files
clean:
-rm -f $(OBJ_FILES) $(EXE_FILE)
#Generate dependency file
depend:
$(COMPILER) $(CXX_FLAGS) $(INCLUDE_DIRS) -MM $(CXX_FILES) > make.dep
#Include dependency file
-include make.dep
Build and run MWE:
$ cd ~/my_tflite_project/my_dev_x64
$ make
$ ./app
Done
Hopefully that helps you or some other poor fellow to get TfLite C++ working.

Cygwin shell not detected on Windows system

I am trying to compile a file using an ARM (RVCT 3.1) compiler.
The makefile looks something like this (pasting extract)
AS = armasm
LD = armlink
CC = armcc
TCC = armcc
#TCC = tcc
CPP = armcpp
TCPP = tcpp
AR = armar
NM = nm
ifeq ($(TERM),cygwin)
RM = rm
RM_OPT = -rf
else
RM = del
RM_OPT =
endif
# Standard CFLAGS
ENDIAN := --li
CFLAGS := -g -O2 -Otime --forceinline --cpu ARM7EJ-S $(ENDIAN) \
--apcs /interwork --fpu softvfp --fpmode ieee_fixed \
--bss_threshold=0 --split_sections \
--md --no_depend_system_headers --depend_format=unix
ASFLAGS := --keep -g --cpu ARM7EJ-S $(ENDIAN) \
--apcs /interwork \
--md
LINKFLAGS := --debug --remove --scatter $(BUILD).mem \
--map --symdefs $(BUILD).sym --keep SDK_Callback.o\(*\) \
--list linker.txt --info sizes,totals,veneers,unused \
--errors output.txt --entry SDK_Main \
--elf --output
ARFLAGS := -ru
when I run the make command I get an error like this
Assembling SDK_Callback.s......
armasm --keep -g --cpu ARM7EJ-S --li --apcs /interwork --md -o SDK_Callback.o SDK_Callback.s
make: *** No rule to make target `C:/Program', needed by `xxx_SDK.o'. Stop.
Generating scatter loading file.
make: del: Command not found
make: [makefile:140: clean] Error 127 (ignored)
my compiler is located at "C:\Program Files\ARM"
and I can even see that it is installed properly.
$ armcc --vsn
ARM/Thumb C/C++ Compiler, RVCT3.1 [Build 1055]
For support see http://www.arm.com/support/
Software supplied by: ARM Limited
based on ifeq ($(TERM),cygwin) condition, it should detect the shell to be cygwin (which I am using) and use rm- rf for delete operation and also follow the unix path and line endings. But looking at the errors looks like the makefile is still running under a windows shell (del is used instead of rm -rf)
Is there some configuration under cygwin that has changed or needs to be enabled for it to work as a unix shell?
I have already downloaded the whole 'devel' section of cygwin, just to be sure including 'make' and 'g++' options.
I have also included the cygwin path in the environment variables.
One more clue I have is, it used to work fine on my older system, I started seeing the problem after I switched to a new system and installed everything (cygwin, compiler) again.
Is this a cygwin problem? or the makefile?
Any help is appreciated thanks !
Update: I changed ifeq ($(TERM),cygwin) to ifeq ($(TERM),xterm) and it worked, looks like the terminal name was changed at some point of cygwin updates.

Beginner in writing makefile; checking my Makefile

I am trying to understand how to write my own makefile for small project, so I have a few questions
my project consists of src directory that contains main.c, file1.c, file2.c, header1.h, and finally header2.h these files use some library from non standard library that I have created and non standard header file, the library directory is located in usr/lib/pr__lib and the header directory is located in usr/include/lib
so I should create two makefile.am one will be located in src directory and the other one will be in root directory of the project the makefile.am of the src directory is as shown below:
program_NAME := PRDSL
bin_PROGRAMS = PRDSL_AutoProject
program_INCLUDE_DIRS := /usr/bin/PR__bin
program_LIBRARY_DIRS := /usr/lib/PR__lib
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
program_LIBRARIES := \
libprdependency \
libprdynarray_pic \
libprhistogram_pic \
libprlistofarrays \
libprlistofarrays_pic \
libprmalloc \
libvreo_wrapper_library
AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
AM_LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
PRDSL_AutoProject_SOURCES = \
main.c \
file1.c \
file2.c
depend :
makedepend --$(CFLAGS) --$(PRDSL_AutoProject_SOURCES)
all: $(program_NAME)
2nd makefile.am at the root directory is as shown below:
SUBDIRS = src
PRDSL_AutoProjectdocdir = ${prefix}/doc/PRDSL_AutoProject
PRDSL_AutoProjectdoc_DATA = \
README\
COPYING\
AUTHORS\
ChangeLog\
INSTALL\
NEWS
INTLTOOL_FILES = intltool-extract.in \
intltool-merge.in \
intltool-update.in
EXTRA_DIST = $(PRDSL_AutoProjectdoc_DATA) \
$(INTLTOOL_FILES)
DISTCLEANFILES = intltool-extract \
intltool-merge \
intltool-update \
po/.intltool-merge-cache
# Remove doc directory on uninstall
uninstall-local:
-rm -r $(PRDSL_AutoProjectdocdir)
but I get the below errors and warnings while I was running automake command:
src/Makefile.am:20: error: 'program_LIBRARIES' is used but 'programdir' is undefined
src/Makefile.am:18: warning: 'CFLAGS' is a user variable, you should not override it;
src/Makefile.am:18: use 'AM_CFLAGS' instead
src/Makefile.am:43: error: AM_LDFLAGS must be set with '=' before using '+='
could any one review it and help me?
For src/Makefile.am:43: error: AM_LDFLAGS must be set with '=' before using '+=' see my answer to your previous question.
Yes, the following lines are telling you to use AM_CFLAGS instead of CFLAGS because, as the error indicates, CFLAGS is a user-specified value and you should leave it alone.
src/Makefile.am:18: warning: 'CFLAGS' is a user variable, you should not override it;
src/Makefile.am:18: use 'AM_CFLAGS' instead
I believe, though I am far from certain, that the reason you are getting src/Makefile.am:20: error: 'program_LIBRARIES' is used but 'programdir' is undefined is because you are using a variable program_LIBRARIES that the autotools believe is a variable they should be using but that you are not using in that way and are instead using in the loop which sets the value for AM_LDFLAGS. As such, and assuming I am correct, if you rename that to not follow the autotool variable naming scheme I believe that error will go away.

Eclipse CDT error: "Symbol 'XXX' could not be resolved"

I have an embedded C project that builds and runs just fine using make on the console, but Eclipse CDT is giving me errors.
In main.c, this function uses a macro, APP_BUTTON_INIT:
static void buttons_init(void)
{
static app_button_cfg_t buttons[] =
{
{SIGNAL_ALERT_BUTTON, false, NRF_GPIO_PIN_NOPULL, button_event_handler},
{BONDMNGR_DELETE_BUTTON_PIN_NO, false, NRF_GPIO_PIN_NOPULL, NULL}
};
APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, false);
}
The APP_BUTTON_INIT macro is defined in app_button.h like this:
#define APP_BUTTON_INIT(BUTTONS, BUTTON_COUNT, DETECTION_DELAY, USE_SCHEDULER) \
do \
{ \
uint32_t ERR_CODE = app_button_init((BUTTONS), \
(BUTTON_COUNT), \
(DETECTION_DELAY), \
(USE_SCHEDULER) ? app_button_evt_schedule : NULL); \
APP_ERROR_CHECK(ERR_CODE); \
} while (0)
The error is
Symbol 'app_button_evt_schedule' could not be resolved
But that function is defined further down in the very same header file, app_button.h:
static __INLINE uint32_t app_button_evt_schedule(app_button_handler_t button_handler,
uint8_t pin_no)
{
app_button_event_t buttons_event;
buttons_event.button_handler = button_handler;
buttons_event.pin_no = pin_no;
return app_sched_event_put(&buttons_event, sizeof(buttons_event), app_button_evt_get);
}
I've tried Project right click -> Index -> Rebuild and Freshen all files, no joy. I'm using Eclipse Kepler SR1 with CDT 8.2.1. Why can't Eclipse see this function?
The first operation of the Makefile is this (this works):
mkdir _build
"/Users/Eliot/dev/gcc-arm/bin/arm-none-eabi-gcc" -DNRF51822_QFAA_CA -mcpu=cortex-m0 -mthumb -mabi=aapcs -DNRF51 -DBOARD_NRF6310 -DNRF51822_QFAA_CA --std=gnu99 -Wall -Werror -mfloat-abi=soft -DDEBUG -g3 -O0 -I"/Users/Eliot/dev/nrf51822/Include/ble" -I"/Users/Eliot/dev/nrf51822/Include/ble/softdevice" -I"/Users/Eliot/dev/nrf51822/Include/app_common" -I"/Users/Eliot/dev/nrf51822/Include/ble/ble_services" -I"../" -I"/Users/Eliot/dev/nrf51822/Include" -I"/Users/Eliot/dev/nrf51822/Include/gcc" -I"/Users/Eliot/dev/nrf51822/Include/ext_sensors" -M ../main.c -MF "_build/main.d" -MT _build/main.o
Screenshots for my CDT project config for includes, symbols and the tool chain are here:
https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_includes.png
https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_symbols.png
https://dl.dropboxusercontent.com/u/12173473/screenshot_cdt_toolchain.png
I'm not using a toolchain because my project started out as the sample CDT project from the hardware manufacturer (Nordic Semiconductor) and that project also had no toolchain configured. To be honest, I doubt CDT is finding the right gcc executable.
Your Eclipse project must reflect the same behavior as your makefile.
Match the output of make (i.e. the calls to gcc or whatever compiler and linker you are using) with your Eclipse project settings at Properties > C/C++ Build > Settings. I would start looking at the include paths (-I) and the defined symbols (-D), and then at the other flags.
Unfortunately, Eclipse is not very clever in importing projects from makefiles, nor at resolving compiler and linker settings from external build tools.
Running around without a proper toolchain configured in Eclipse was the problem. For ARM development using cross gcc, this Eclipse plugin fixed my problem and looks promising in general. It gives you Eclipse project settings for the whole toolchain and means you can ditch your makefiles.
http://gnuarmeclipse.github.io

How to compile a custom folder structure with ndk-build?

I have the next folder structure:
On $My_Eclipse_Project
jni/Android.mk
jni/Application.mk
jni/main.cpp
lib/
On $My_Library_Project
src/
include/
Android.mk
$My_Eclipse_Project/jni/main.cpp is a basic makefile whom call the source to compile, following the instructions from $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)
The problem is, $My_Library_Project>Android.mk don't detect the folder structure what is waiting, because my source is on src folder, don't at jni folder. I get:
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
How could i compile the code at $My_Library_Project from $My_Eclipse_Project, and copy the library generated on $My_Eclipse_Project>lib/armeabi, to be used by main.cpp?
Thanks in advance.
2 Options. You can define $NDK_PROJECT_PATH = /your_ndk_path, Makefile auto detect the path and use it to compile, or add a enviroment var with name $NDK_PROJECT_PATH and value /your_ndk_path.

Resources