我正在使用C接口(interface),当我包含“ml.h”时运行ndk-build时,出现以下错误:
In file included from /Users/user/android-ndk-r7c/sources/cxx-stl/gnu-libstdc++/include/bits/stl_algobase.h:61,
from /Users/user/android-ndk-r7c/sources/cxx-stl/gnu-libstdc++/include/bits/stl_tree.h:62,
from /Users/user/android-ndk-r7c/sources/cxx-stl/gnu-libstdc++/include/map:60,
from /Users/user/android-opencv/OpenCV-2.3.1/share/OpenCV/../../include/opencv2/ml/ml.hpp:2022,
from /Users/user/android-opencv/OpenCV-2.3.1/share/OpenCV/../../include/opencv/ml.h:46,
from /Users/user/CarSafe/jni/blink_detection.c:7:
/Users/user/android-ndk-r7c/sources/cxx-stl/gnu-libstdc++/include/cstddef:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
如果我将“ml.h”的包含注释掉,它可以正常运行。
问题是我想在我的C代码中使用opencv svm库。我究竟做错了什么?还是应该将其编译为C++代码并在C++中使用ml.hpp header 。这适用于项目中的其他代码。
最佳答案
仔细查看输出的最后一行:
/Users/user/android-ndk-r7c/sources/cxx-stl/gnu-libstdc++/include/cstddef:51: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
根据您在问题中所写的内容,您似乎正在尝试使用C编译器来使用C++标准库来编译代码。
另外,尽管我对OpenCV不熟悉,但我假设您应该能够将代码编译为C++,并且仍然包含“ml.h”。 C++ header 并不总是使用* .hpp扩展名。