I'm trying to get the Eventinjector project from pocketmagic.net found here.
This means working with a precoded jni library writen in C. My problem is that I get some build errors when I try to compile the native code. The error log is long and I believe all errors are the same, therefore I'll only post part of it.
jni/EventInjector.h:718:9: error: (near initialization for 'mt_tool_labels[0].value')
jni/EventInjector.h:719:9: error: 'MT_TOOL_PEN' undeclared here (not in a function)
jni/EventInjector.h:719:9: error: initializer element is not constant
jni/EventInjector.h:719:9: error: (near initialization for 'mt_tool_labels[1].value')
jni/EventInjector.h:720:9: error: 'MT_TOOL_MAX' undeclared here (not in a function)
jni/EventInjector.h:720:9: error: initializer element is not constant
jni/EventInjector.h:720:9: error: (near initialization for 'mt_tool_labels[2].value')
jni/EventInjector.c: In function 'debug':
jni/EventInjector.c:82:2: error: format not a string literal and no format arguments [- Werror=format-security]
cc1.exe: some warnings being treated as errors
make: *** [obj/local/armeabi/objs/EventInjector/EventInjector.o] Error 1
Going throught the comments under the blogpost I discovered that "Alessandro" had the same problem but had found a solution. (post 51) " I had the same issue and imported my own input.h version containing all the missing declarations."
This is the part of the .c file that generates most of the errors:
static struct label key_labels[] = {
LABEL(KEY_RESERVED),
LABEL(KEY_ESC),
LABEL(KEY_1),
LABEL(KEY_2),
LABEL(KEY_3),
LABEL(KEY_4),
LABEL(KEY_5),
LABEL(KEY_6),
LABEL(KEY_7),
LABEL(KEY_8),
LABEL(KEY_9),
LABEL(KEY_0),
LABEL(KEY_MINUS),
LABEL(KEY_EQUAL),
LABEL(KEY_BACKSPACE),
...
I have no experience in C, and don't know what he means. So my question is: how do I do this?
I have succesfully compiled other JNI libs, using NDK v9 and cygwin, so there should not be a problem with my settings and enviroment.
I had the same issue and imported my own input.h version containing all the missing declarations.
You can do same thing and replace your input.h (you can search for input.h with those undefine identifiers in linux kernel sources), but easier way is to remove lines containing undefined identifiers from EventInjector.h. Just comment all lines that highlighted red in eclipse, and it should work.
Related
We're trying to get BGFX to build for Android, following the guide here: https://github.com/Nodrev/bgfx-android-activity as recommended on the BGFX main site.
However, this repository was last updated 3+ years ago, and since then there have been major revisions to the Android NDK structure, meaning all of the library paths are all wrong. We've managed to make some progress, but keep getting stuck on the same error.
What we've tried so far:
Using various NDK versions from 17 to 25. NDK 21 seems to be the one before the big change in NDK structure but we consistently get an error at some point during the build with each NDK: 'alloca.h' file not found
Using NDK 25, we got various other errors due to incorrect paths, managed to get past those, but this just led us back to the above error.
Posting a message on the BGFX discussion board, no response.
We found a message here that appears to describe the problem we're having but the second solution does not work, with error:
error: use of undeclared identifier 'GL_PARAMETER_BUFFER_ARB' ...GL_CHECK(glBindBuffer(GL_PARAMETER_BUFFER_ARB, 0) );
and the first solution doesn't contain enough information to try to replicate it.
The main issue we're having is that it seems there is a variable sysroot which tells the build process where to look for headers and libraries, this points to --sysroot=$(ANDROID_NDK_ROOT)/platforms/android-32/arch-arm in the build script, which does not exist. Setting it to a platform that does exist, e.g. --sysroot=$(ANDROID_SDK_ROOT)/platforms/android-32/ got us as far as the alloc.h error above.
alloca.h is found in \AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include so we tried setting sysroot to $(ANDROID_NDK_X86)/sysroot/usr/
which led to the error:
\AppData\Local\Android\Sdk\ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64/sysroot/usr//include/linux/types.h:21:10: fatal error: 'asm/types.h' file not found
asm/types.h is found in a few places:
ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\aarch64-linux-android\asm ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\arm-linux-androideabi\asm ndk\25.1.8937393\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\i686-linux-android\asm
but changing sysroot to point to e.g. --sysroot=$(ANDROID_NDK_ARM)/sysroot/usr/include/arm-linux-androidabi gets us back to the alloca.h error again.
This is the error in full:
process_begin: CreateProcess(NULL, uname, ...) failed.
makefile:6: pipe: No error
C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe -R -C .build/projects/gmake-android-arm config=debug
make[1]: Entering directory '.../bgfx/.build/projects/gmake-android-arm'
"==== Building bx (debug) ===="
allocator.cpp
In file included from ../../../../bx/src/allocator.cpp:6:
In file included from ../../../../bx/include/bx/allocator.h:9:
../../../../bx/include/bx/bx.h:9:10: fatal error: 'alloca.h' file not found
#include <alloca.h> // alloca
^~~~~~~~~~
1 error generated.
make[2]: *** [bx.make:441: ../../android-arm/obj/Debug/bx/bx/src/allocator.o] Error 1
make[1]: *** [Makefile:17: bx] Error 2
make[1]: Leaving directory '.../bgfx/.build/projects/gmake-android-arm'
make: *** [makefile:69: android-arm-debug] Error 2
We've run out of ideas at this point, would greatly appreciate some help!
I'm trying to run a C++ project on Android. The following statement appears in one of the source files (part of a big project).
std::unordered_map <int, std::shared_ptr<Frame>, std::hash<int>, std::equal_to<int>,
Eigen::aligned_allocator< std::pair<const int, std::shared_ptr<Frame> > > > idToKeyFrame;
The NDK build complains the following
sysroot/usr/include/c++/v1/unordered_map:1684:5: error: static_assert failed due to requirement 'is_same<value_type, typename allocator_type::value_type>::value' "Invalid allocator::value_type"
I cannot spot what part of declaration is incompatible. Please help in fixing this error.
cplusplus.com reference
Update
When I modify the allocator (as suggested in comment by Marc) to Eigen::aligned_allocator<std::pair<int, std::shared_ptr<Frame>>> The error message remains the same but line number changes
sysroot/usr/include/c++/v1/unordered_map:854:5: error: static_assert failed due to requirement 'is_same<value_type, typename allocator_type::value_type>::value' "Invalid allocator::value_type"
Update++
According to this answer :
libstdc++ does not static_assert, libstdc++ ignores the exact type of the allocator and rebinds it to the container's value type.
and
Clang/libc++ are not forgiving
Yet another Update
I have been able to go past the error by commenting out the line in the source for unordered_map. This is a resort for now (until I get a solution).
I am compiling Android Kernel 3.18.
I am getting this error
drivers/built-in.o: In function `enable_extldo':
/home/vinay/customKernel/3.18/kernel_yu_msm8937/drivers/bluetooth/bluetooth-power.c:307: undefined reference to `cnss_get_platform_cap'
/home/vinay/customKernel/3.18/kernel_yu_msm8937/drivers/bluetooth/bluetooth-power.c:307:(.text+0x5c45bc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `cnss_get_platform_cap'
Makefile:951: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1
Here is the source code
I am using aarch64-linux-android-4.9 toolchain
I encountered the same problem when I tried to compile a kernel for a MI device.
First you can see the function cnss_get_platform_cap was declared in cnss.h which is located in include/net:
And you open this file you will find this function was declared as a extern one:
So it is only a declaration here, not a implement.
Then we have a dig where the function is, I used find command to find all cnss related driver files and I find this function was implemented in ./net/wireless/cnss/cnss_pci.c
As we can see, the function was here and it will be a exported symbol after compiling.
And you can log your compile process and you will find actually succeed to compile bluetooth-power.c
Just when the makefile link vmlinux it will be a problem. So here we are. I searched the log and I didn't find cnss_pci.c was ever compiled, only cnss_common.c was compiled, let's open the sub-makefile in net/wireless/cnss/
You will find you need to add a item in your defconfig file to compile cnss_pci.c which is 'CONFIG_CNSS_PCI=y'. I add it to my defconfig file in arch/arm64/configs/xxx_defconfig and I solved this.
I just tried to merge a vendor patch into a newer CAF kernel, and there are many many syntax errors even with auto merge.
As for the logic error and bugs, I don't know. A lot of things need to learn.
Hope you find your way out.
I am able to compile tcl8.6.1 source using GNU Makefile for X86 successfully. Also able cross compile for arm using Android standalone tool chain with make.
When I try to build the same tcl source using Android environment by writing my own Android.mk file and with "mm" command, i am seeing "error: expected ')' before '->' token" error. Detailed error log is given for reference. Please suggest how and where it can go wrong.
system/extras/work/tcl8.6.1/unix/../generic/tclOODecls.h:183:16: error: expected ')' before '->' token
(tclOOStubsPtr->tcl_NewObjectInstance) /* 13 */
^
system/extras/work/tcl8.6.1/unix/../generic/tclOO.c:1562:1: note: in expansion of macro 'Tcl_NewObjectInstance'
Tcl_NewObjectInstance(
^
system/extras/work/tcl8.6.1/unix/../generic/tclOODecls.h:157:16: error: expected ')' before '->' token
(tclOOStubsPtr->tcl_CopyObjectInstance) /* 0 */
^
system/extras/work/tcl8.6.1/unix/../generic/tclOO.c:1840:1: note: in expansion of macro 'Tcl_CopyObjectInstance'
Tcl_CopyObjectInstance(
^
make: Leaving directory `/local/mnt/workspace/Code/TAG_JUNE_15'
make failed to build some targets (38 seconds)
That file (tclOODecls.h) is an auto-generated C header file that describes the C Interface to the TclOO part of the Tcl API. The error indicates that something is not handling the tclOOStubsPtr token well, which is exceptionally strange; it should be a variable that is defined in the stub library. There's something horribly wrong, and given that you appear to be the only person with the problem, I'm guessing it is in your configuration or how you are using it.
I'm currently working on a project trying to get my Samsung Galaxy S2 to interface with the Arduino Mega ADK for Android and I'm getting a bunch of errors.
I've followed directions given here: http://stream.tellart.com/controlling-arduino-with-android/ to the letter. And I've tried running their examples
Specifically the "TapOn" Example (which should allow me to control an LED connected to Arduino from my Android). But each time I run it I get errors on both the processing code for the Android and the arduino code.
Arduino Errors:
AndriodAccessory has not been declaired
AndroidAccessory.cpp:38: error: 'AndroidAccessory' has not been declared
AndroidAccessory.cpp:43: error: ISO C++ forbids declaration of 'AndroidAccessory' with no type
AndroidAccessory.cpp: In function 'int AndroidAccessory(const char*, const char*, const char*, const char*, const char*, const char*)':
AndroidAccessory.cpp:43: error: only constructors take base initializers
AndroidAccessory.cpp: At global scope:
AndroidAccessory.cpp:54: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp: In function 'void powerOn()':
AndroidAccessory.cpp:56: error: 'max' was not declared in this scope
AndroidAccessory.cpp:57: error: 'delay' was not declared in this scope
AndroidAccessory.cpp: At global scope:
AndroidAccessory.cpp:60: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:60: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:61: error: expected ',' or ';' before '{' token
AndroidAccessory.cpp:71: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:71: error: variable or field 'sendString' declared void
AndroidAccessory.cpp:71: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:71: error: expected primary-expression before 'int'
AndroidAccessory.cpp:71: error: expected primary-expression before 'const'
AndroidAccessory.cpp:82: error: 'AndroidAccessory' is not a class or namespace
AndroidAccessory.cpp:82: error: 'byte' was not declared in this scope
AndroidAccessory.cpp:83: error: expected ',' or ';' before '{' token
Android/Processing Errors:
Error from inside Android tools
API<=15: Adding annotations.jar to the classpath.
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
No AIDL files to compile.
No RenderScript files to compile.
Generating resource IDs...
Generating BuildConfig class.
BUILD FAILED
C:\Users\Nate\Desktop\AndriodSDK\tools\ant\build.xml:705: The following error occurred while executing this line:
C:\Users\Nate\Desktop\AndriodSDK\tools\ant\build.xml:718: Compile failed; see the compiler error output for details.
I don't understand whats wrong and why I'm getting these errors when I haven't changed any of the code from the samples. Also I can write programs for the arduino and android independently of each other, and they work fine... I only get the errors when I want the two to communicate with each-other.
Looks like your code has no library to work with. For me that meant roaming the internet till I found the correct libraries. I would try the following:
Make sure you have the latest Arduino IDE
Download the libraries, probably this.
Although if you want just try the step by step here.