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).
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 try to the same simple code, that which one is in the Android(4.2.2) and another one is in the Ubuntu(15.04), but with a similar code I get error in the Ubuntu. Also in the Android works very well, but in the Ubuntu even does not compiling.
initialize without / = / syntax and uses / ( ) / syntax
code :
int i(1); /// ok
char c('a'); /// ok
float f(4.444); /// ok
double d(4.34343433434); /// ok
char* cs("stack over flow"); /// ok
char I[]("stack over flow"); /// can not initialize by g++ in Ubuntu
in Android (c4droid):
in Ubuntu (code block):
both of them use the g++ compiler
g++ (Ubuntu 4.9.2-10ubuntu13) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
In standard c++ built-in arrays cannot be constructed with constructor-like call. You should use {} brackets instead. It's very similar to templates. Non-type template arguments can't be deduced from constructors (just like any template arguments)
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 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 downloaded android source from source.android.com and followed the instruction to setup build environment on MAC OS X, Everything went fine except when i run make it gives me following error
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=darwin
HOST_BUILD_TYPE=release
BUILD_ID=ITL41D
============================================
host C++: aapt <= frameworks/base/tools/aapt/AaptAssets.cpp
frameworks/base/tools/aapt/AaptAssets.cpp:2161:38: warning: unused parameter 'bundle' [-Wunused-parameter]
AaptAssets::slurpResourceZip(Bundle* bundle, const char* filename)
^
In file included from frameworks/base/tools/aapt/AaptAssets.cpp:5:
In file included from frameworks/base/tools/aapt/AaptAssets.h:10:
In file included from frameworks/base/include/utils/AssetManager.h:25:
frameworks/base/include/utils/KeyedVector.h:193:17: error: use of undeclared identifier 'indexOfKey'
ssize_t i = indexOfKey(key);
^
this->
frameworks/base/tools/aapt/AaptAssets.h:446:46: note: in instantiation of member function 'android::DefaultKeyedVector<android::String8, android::sp<AaptSymbols> >::valueFor' requested here
sp<AaptSymbols> sym = mNestedSymbols.valueFor(name);
^
frameworks/base/include/utils/KeyedVector.h:66:29: note: must qualify identifier to find this declaration in dependent base class
ssize_t indexOfKey(const KEY& key) const;
^
1 warning and 1 error generated.
make: *** [out/host/darwin-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1
I just started in android so do not have any clue, any small help also would be appreciated
Just to expand on Pete's answer, in case anyone really wants to know:
The indexOfKey is defined in DefaultKeyVector's parent class, KeyedVector. For class templates, a function call is resolved during compile-time, not during run-time. The error happens because at the point indexOfKey is called, the compiler wouldn't know where that template function might be located. Here is how the base and derived classes look like:
template <typename KEY, typename VALUE>
class KeyedVector
{
...
ssize_t indexOfKey(const KEY& key) const;
...
template <typename KEY, typename VALUE>
class DefaultKeyedVector : public KeyedVector<KEY, VALUE>
{
...
And the offending call:
template<typename KEY, typename VALUE> inline
const VALUE& DefaultKeyedVector<KEY,VALUE>::valueFor(const KEY& key) const {
ssize_t i = indexOfKey(key);
...
Most likely, using the older MacOS SDK compiler (or other compilers) works because it was probably just guessing the function exists in some base class, instead of failing. However, that is not standard behavior.
More info from this clang entry, and from the C++ FAQ.
I finally figured out the problem.
There's an error in the sourcecode of frameworks/base/include/utils/KeyedVector.h:193
Some of the member functions require Scope resolution operator "this->" to build the android source on MAC OS X Lion with xcode 4.3.x and on gcc version 4.9.2 (Debian 4.9.2-10).
Without scope resolution operator compiler will not be able to identify the existence of the function.
Open frameworks/base/include/utils/KeyedVector.h
Change the line 193 from:
ssize_t i = indexOfKey(key);
to
ssize_t i = this->indexOfKey(key);
and Android 4.0.1 compiles.
To build ICS on newer GCC versions, you must apply these patches:
https://groups.google.com/forum/#!msg/android-building/2EwtWQTqjdI/fbZlzXErscwJ
I faced this problem several times when building Browser for Android 4.0.3 with make -j Browser on MAC OS X 10.8.4. I dont have any problem with Android 4.2.1.
So my solution is
make CC=gcc CXX=g++ -j Browser
Hope it helps