我尝试编译CImg for android。但编译时遇到了这样的错误。
是Application.mk的一部分 `
APP_STL := gnustl_static
NDK_TOOLCHAIN_VERSION=4.9
APP_CPPFLAGS +=-std=c++11
APP_ABI := armeabi armeabi-v7a
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_OPTIM := release
LOCAL_ARM_MODE := thumb
我收到了以下错误
/CImg.h: In member function 'cimg_library::CImg<typename cimg_library::cimg::last<T, int>::type>
cimg_library::CImg<T>::_get_select(cimg_library::CImgDisplay&, const char*, unsigned int, unsigned int*, int, int, int, bool, bool) const':
./CImg.h:38224:15: error: expected unqualified-id before numeric constant
_X = (int)X, _Y = (int)Y, _Z = (int)Z,
^
In file included /test.cpp:2069:
./CImg.h:38249:32: error: 'yf' was not declared in this scope
visu.draw_line(0,yf,visu.width() - 1,yf,foreground_color,0.7f,0xFF00FF00).
./CImg.h:38251:27: error: 'xf' was not declared in this scope
draw_line(xf,0,xf,visu.height() - 1,foreground_color,0.7f,0xFF00FF00).
./CImg.h:38254:32: error: 'zxf' was not declared in this scope
visu.draw_line(zxf,0,zxf,yM,foreground_color,0.7f,0xFF00FF00).
^
./CImg.h:38254:42: error: 'yM' was not declared in this scope
visu.draw_line(zxf,0,zxf,yM,foreground_color,0.7f,0xFF00FF00).
^
./CImg.h:38256:31: error: 'zyf' was not declared in this scope
draw_line(0,zyf,xM,zyf,foreground_color,0.7f,0xFF00FF00).
^
./CImg.h:38256:35: error: 'xM' was not declared in this scope
draw_line(0,zyf,xM,zyf,foreground_color,0.7f,0xFF00FF00).
为什么呢?如何解决?
答案 0 :(得分:0)
做得好,我自己解决了这个问题。 这个问题是由编译器造成的,哪一行代码无法定义太多变量。(ndk版本是r9d)
int a = 1, b = 2, c = 3, d =4, e = 5;
将此代码转换为多行。
int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
这解决了我的问题。