Objective
To generate the hash of a image file. I am using pHash library for this task. pHash library has below method used for generating the image hash.
int ph_dct_imagehash(const char* file,ulong64 &hash);
Datatype ulong64 is not present in android stdint.h. Due to which I am getting "cannot resolve type ulong64" error.
Please help how I can use ulong64 in c file in Android.
Can I use some third party library for this task?
Do we have any way around to fix this error?
This type is specific to pHash, and it is defined inside pHash.h by the following snippet:
#if defined( _MSC_VER) || defined(_BORLANDC_)
typedef unsigned _uint64 ulong64;
typedef signed _int64 long64;
#else
typedef unsigned long long ulong64;
typedef signed long long long64;
#endif
To use this type, just #include <pHash.h>.
Related
First off, my app has a file named Android.hpp. This is part of the tmxlite library. Compiling tmxlite on windows works fine. However, when I move the code to android studio and compile it (with the NDK), I get an error.
Android.hpp:
/*********************************************************************
Matt Marchant 2016
http://trederia.blogspot.com
tmxlite - Zlib license.
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but
is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
*********************************************************************/
#ifndef ANDROID_INC_HPP_
#define ANDROID_INC_HPP_
#ifdef __ANDROID__
#include <string>
#include <sstream>
#include <cstdlib>
namespace std
{
template <typename T>
std::string to_string(T value)
{
std::ostringstream os;
os << value;
return os.str();
}
}
#define STOI(str) std::strtol(str.c_str(), 0, 10)
#else
#define STOI(str) std::stoi(str)
#endif // __ANDROID__
#endif // ANDROID_INC_HPP_
The error:
In file included from E:\max\android_libs\tmxliteOG\tmxlite\src\FreeFuncs.cpp:28:
In file included from E:\max\android_libs\tmxliteOG\tmxlite\include\tmxlite\FreeFuncs.hpp:54:
E:\max\android_libs\tmxliteOG\tmxlite\include\tmxlite\detail\Android.hpp:37:11: error: expected '{'
Why is this happening? I was under the impression that this was how namespaces were supposed to be declared and I don't see what is wrong with it. I mean, I didn't even write the code :-).
help is greatly appreciated.
Im trying to build an Ubuntu Touch tree, based on an Aosp tree I already correctly built.
It fails with this error
CAPEWrapper.cpp:16: error: undefined reference to '__xlog_buf_printf'
this is the header that file includes
#include "CAPEWrapper.h"
which on cascade includes
#include <cutils/xlog.h>
which in turn defines
#if defined(__cplusplus)
extern "C" {
#endif
int __xlog_buf_printf(int bufid, const struct xlog_record *rec, ...);
#if defined(__cplusplus)
}
#endif
I suspect that my g++ doesn't set __cplusplus macro. Could it be a realistic scenario with this kind of error? If this could be the problem, should I need to specify a standard implementation with "stdc=something" to solve it?
Any other idea is welcome.
Make sure that your project is linking libcutils, and that it's linking it in the correct order (i.e. that -lcutils appears in the linker command line after any module that depends on it).
In the end, I found that the modules was listed inside a macro called LOCAL_WHOLE_STATIC_LIBRARIES, that in Android environment passes its content to the --whole-archive flag of GCC linker.
I start using OpenCV library for Android and want to build the examples supplied with the OpenCV sdk library for Android. In particular, I build "Face Detection" OpenCV sample.
While the project itself builds fine, in Eclipse I see the following error:
Multiple markers at this line
- Symbol 'NULL' could not be resolved
- Invalid arguments ' Candidates are: const char * GetStringUTFChars(_jstring *, unsigned char *) '
in the following string of the file jni/DetectionBasedTracker_jni.cpp:
const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL);
I already added all necessary paths but I still see this error. Any suggestions?
I've just installed the NDK onto Eclipse, but I'm having some trouble with something..
Here's the code:
#include <jni.h>
#include <stdlib.h>
#include <stdio.h>
void deleteFile(const char *fileName) {
remove(fileName);
}
void writeFile(const char *fileName, byte array) {
}
But something is going wrong.. I got this error:
jni/[projectName].cpp:9:38: error: 'byte' has not been declared
byte couldn't be resolved! which is a big problem because I absolutely need that type.. I have to use it to write data into a file!
I've followed a lot of tutorials, I also tried to import all of my MinGW libraries with no success.
byte isn't a standard C or C++ type ... It may be a typedef in a non-standard header file. Where have you seen code with that type ? May be you would like to use const unsigned char * ?
I know that Visual Studio define BYTE type:
typedef unsigned char BYTE; // 8-bit unsigned entity.
typedef BYTE * PBYTE; // Pointer to BYTE.
But this is not standard. And it is "BYTE", not "byte".
'byte' doesn't exist in standard C or C++, if all your code depends on , use 'jbyte' instead, it is defined in this header, and maps to an 8-bit unsigned integer type.
Alternatively, you could define 'byte' with a typedef as in:
typedef unsigned char byte;
And ensure this is used/parsed by all your sources (e.g. put it in a shared header).
A slightly more correct way to do it is:
#include <inttypes.h>
typedef uint8_t byte;
It will be equivalent on all supported Android platforms, but requires an additional include.
(Technically, 'char' can be more than 8 bits on some really odd platforms, but none of them are ever going to be targetted by Android).
I am writing a wrapper to use some functions of crypto.
I build crypto lib from openssl-android with Android-NDK. Now i have the libcrypto.so that i need, but i donĀ“t know how to link it with my wrapper.
My project tree is like this
(proj root)
|
|->(src)
|->(src)-> com.package
|->(src)-> com.package->NativeCipher.java
|
|->(jni)
|->(jni)->Android.mk
|->(jni)->NativeCipher.c
NativeCipher.java
public class NativeCipher {
static {
System.loadLibrary("crypto");
System.loadLibrary("NativeCipher");
}
public static native byte[] AESEncrypt(byte[] in, byte[] key);
}
NativeCipher.c
#include <string.h>
#include <jni.h>
#include <aes.h>
jbyteArray Java_com_package_NativeCipher_AESEncrypt(JNIEnv* env, jobject this, jbyteArray in, jbyteArray key)
{
// All my code here
}
I need to use the functions of #include that crypto provides.
However, i don't know what to do with the .so files that NDK generates and how to make the Android.mk file to build.
Thanks in advance, i tried to be as specific as posible.
Native libraries go to the libs/armeabi or libs/armeabi-v7a of your Android project. You might want to rename the OpenSSL library though, because the system already has a libcrypto.so. As for your own JNI wrapper, just take the shared library sample from the NDK and modify to use your own files.