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?
Related
I am using pyqtdeploy to pack a much simple python script into Qt Project. Then I will try to compile it as .apk file. I consider the environment has been completely set up so far, including Android SDK, Android NDK, Qt, android studio, ant etc. A strange error always appears when running pyqtdeploy.
Here is my code:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel
class Main(QWidget):
def __init__(self):
super().__init__()
self.build_inter()
def build_inter(self):
self.lb = QLabel("Test", self)
self.lb.move(0, 0)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
w = Main()
sys.exit(app.exec_())
I intercepted a part of error information:
..\include/pyport.h:617:60: error: expected constructor, destructor, or type conversion before '(' token
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
^
..\include/fileutils.h:109:1: note: in expansion of macro 'PyAPI_FUNC'
PyAPI_FUNC(int) _Py_get_inheritable(int fd);
^
..\include/pyport.h:617:60: error: expected constructor, destructor, or type conversion before '(' token
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
^
..\include/fileutils.h:111:1: note: in expansion of macro 'PyAPI_FUNC'
PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
^
..\include/pyport.h:617:60: error: expected constructor, destructor, or type conversion before '(' token
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
^
..\include/fileutils.h:114:1: note: in expansion of macro 'PyAPI_FUNC'
PyAPI_FUNC(int) _Py_dup(int fd);
and the screenshot:
My config:
Have anyone encountered a similar problem? What am I supposed to do?
Thanks in advance!
I'm far from being an expert, but in the documentation it reads it does not make sense to check "run application" unless the target environment is equal to the source environment. From your windows it seems you are cross compiling from Windows to Android, thus I would try to omit the last parameter of "Additional build steps" ("run application"). You would then have to test it yourself from e.g. Android studio I guess. Hope it helps.
I am a beginner with C/C++ and the Android NDK, and I have a problem trying to create a native library. My code compiles using MinGW on CDT, but when I write the same code on a JNI file, there is an error.
My code is:
int n = 7;
int positions[n];
int final_order[n];
memcpy(positions, final_order,sizeof(final_order));
The plugin shows me:
Invalid arguments 'Candidates are: void * memcpy(void *, const void *, ?)'
This the header from MinGW on CDT:
_CRTIMP void* __cdecl __MINGW_NOTHROW memcpy (void*, const void*, size_t);
This the header from the Android NDK:
extern void* memcpy(void *, const void *, size_t);
There is a known indexing problem when using Eclipse to do NDK development.
Read about it here: https://code.google.com/p/android/issues/detail?id=33788
Near the bottom there is a reasonable workaround that I myself use:
What we want is to use the Android GCC toolchain but change the actual tools and modify the discovery options so that the include paths and symbols are correct.
Go into C/C++ Buid \ Tool Chain editor
Make sure Android GCC is the selected toolchain and Android Builder is the selected builder.
Click on "Select Tools"
Select "Allow all changes"
Remove the Android GCC Compiler
Add "GCC C Compiler" and "GCC C++ Compiler" so that we can index both c and cpp headers.
If you would look at "Paths and Symbols" you would see we have both GNU C and GNU C++ languages, but of course the built-in include paths are wrong. luckily there is a fix for that.
Go into C/C++ Build \ Discovery Options
Change Discovery profiles scope to "Configuration-wide"
Make sure the Discovery profile is using "AndroidPerProjectProfile" and make sure both checkboxes are checked.
I then have to manually add my own include directories and definies under Project Properties -> C/C++ General -> Paths and Symbols
It's worth noting that your code compiles fine. You can turn off indexing if you like, but if you still want the advantages of indexing you'll have to work around the issue.
Another workaround is:
to open the android native perspective,
to right-click on your project in the project navigator,
and to click on the index options to rebuild the indices.
I've got a problem when building android applications with OpenCV and JNI part in Eclipse.
The problem is than ndk-build runs normally for the project, but Eclipse shows errors (usually irrelevant to the code).
For example, I'm building one of the OpenCV4Android samples:
boris#boris-ubuntu:~/src/OpenCV-2.4.3-android-sdk/samples/tutorial-3-native$ ndk-build
Install : libnative_camera_r2.2.0.so => libs/armeabi-v7a/libnative_camera_r2.2.0.so
Install : libnative_camera_r2.3.3.so => libs/armeabi-v7a/libnative_camera_r2.3.3.so
Install : libnative_camera_r3.0.1.so => libs/armeabi-v7a/libnative_camera_r3.0.1.so
Install : libnative_camera_r4.0.0.so => libs/armeabi-v7a/libnative_camera_r4.0.0.so
Install : libnative_camera_r4.0.3.so => libs/armeabi-v7a/libnative_camera_r4.0.3.so
Install : libnative_camera_r4.1.1.so => libs/armeabi-v7a/libnative_camera_r4.1.1.so
Install : libnative_sample.so => libs/armeabi-v7a/libnative_sample.so
Install : libopencv_java.so => libs/armeabi-v7a/libopencv_java.so
It runs normally, but Eclipse shows errors:
'size_t' is ambiguous '
Candidates are:
Field 'pt' could not be resolved
Field 'pt' could not be resolved
Field 'x' could not be resolved
Field 'y' could not be resolved
Invalid arguments '
Candidates are:
void detect(const cv::Mat &, ? &, const cv::Mat &)
void detect(const ? &, ? &, const ? &)
The type 'cv::FastFeatureDetector' must implement the inherited pure virtual method 'cv::FeatureDetector::detectImpl'
And other error like this one in other projects. And also, the Eclipse intellisense (or how is it called properly :) is not working on .cpp files.
I've tried to clean the projects, delete the obj and lib folders, but no effect.
My system is ubuntu 12.04, OpenCV version is 2.4.3.
Thanks for any help!
Had same problem with you on ubuntu 12.04, OpenCV version is 2.4.3. exactly on the same example and I am using the eclipse-android bundle.
Here's what I did:
Update the NDK plugin using google repo, It is already installed but it can be updated.
Then I changed size_t to int and added a temp variable instead of going straight as the example goes. Here's the code:
Mat* pMatGr=(Mat*)addrGray;
Mat* pMatRgb=(Mat*)addrRgba;
vector<KeyPoint> v;
FastFeatureDetector detector(50);
detector.detect(*pMatGr, v);
for( int i = 0; i < v.size(); i++ )
{
KeyPoint tK = v[i];
circle(*pMatRgb, Point(tK.pt.x, tK.pt.y ), 10, Scalar(255,0,0,255));
}
It really is a weird bug, my guess is that it has something to do with eclipse debug mechanism not working properly.
Yea very strange bug. Am on Ubuntu 12.04 and OpenCV 2.4.5.
I got the same bug on 'OpenCV Tutorial 2 - Mixed Processing'
Managed to fix it without reinstalling Eclipse or NDK. Just deleted the sample project, then imported it again. Works fine now.
I am trying to get cocos2d-android (cocos2d-2.0-rc2-x-2.0.1) "Helloworld" sample to run under windows. I am using latest version of cygwin along side with android ndk r6, android sdk API 8. And I tried the manual here
after a lot of challenges I am down to this problem which I think is in linking the classes at compile time. when I try to run the *build_native.sh* script I get an error stating that in CCGL.h, PFNGLDELETEVERTEXARRAYSOESPROC which is defined as extern, does not name a type.
//declare here while define in CCEGLView_android.cpp
extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT;
extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT;
extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT;
'PFNGLDELETEVERTEXARRAYSOESPROC' is declared in CCEGLView.h.
#if CC_TEXTURE_ATLAS_USE_VAO
#include <EGL/egl.h>
PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0;
PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0;
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0;
#endif
I tried to add the header address to android.mk under jni directory, to LOCAL_C_INCLUDES, as suggested here,but there were no rules to make them. so can anybody help me with how to compile/link this, it would be much appreciated.
I had this problem, and using a higher version of NDK worked. Try to get the most recent version, reset the environment variables, and run build_native.sh again.
http://developer.android.com/tools/sdk/ndk/index.html
I am in a project on OpenGL in Linux FC16. We have been doing a lot of 3D and so far so good.
This month the company decided to port the whole system to OpenGL-ES.
I have installed the OpenGL ES as usual:
yum install make gcc mesa-libGLES-devel mesa-libEGL-devel
ref. http://code.google.com/p/opengles-book-samples/wiki/Instructions
On Eclipse IDE the ES was also included:
Project > Properties > C/C++ Build > Settings > GCC C Linker > Libraries > Libraries (-l)+:
EGL
GLES
Trying to run the compiler, it gives the error:
../src/esUtil.h:84:21: error: expected ‘)’ before ‘*’ token
../src/esUtil.h:85:21: error: expected ‘)’ before ‘*’ token
../src/esUtil.h:86:21: error: expected ‘)’ before ‘*’ token
which directs me to this:
/// Callbacks
void (ESCALLBACK *drawFunc) ( void* );
void (ESCALLBACK *keyFunc) ( void*, unsigned char, int, int );
void (ESCALLBACK *updateFunc) ( void*, float deltaTime );
ref. http://code.google.com/p/angleproject/source/browse/trunk/samples/gles2_book/Common/esUtil.h?r=486
I tried to put additional parenthesis, but it does not fixed it anyway. This is just driving me crazy.
Any suggestions or comments are highlight appreciated!
At the top of esUtil.h try:
#define __cdecl
See if it builds. If it does then you have a problem with __cdecl being a windows definition that gcc does not support.
I think a fix will be:
#define __cdecl __attribute__((__cdecl__))
PS: Cdecl is a Visual C extension that is not supported by gcc (I think).