Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/126.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NDK构建中的错误 我试图用Android中的一些旧C++代码构建一个WrpW.< /P>_Android_C++_C_Android Ndk - Fatal编程技术网

NDK构建中的错误 我试图用Android中的一些旧C++代码构建一个WrpW.< /P>

NDK构建中的错误 我试图用Android中的一些旧C++代码构建一个WrpW.< /P>,android,c++,c,android-ndk,Android,C++,C,Android Ndk,编译时,将显示以下错误: In file included from /usr/local/android/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_algobase.h:61:0, from /usr/local/android/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree

编译时,将显示以下错误:

In file included from /usr/local/android/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_algobase.h:61:0,
                 from /usr/local/android/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree.h:63,
                 from /usr/local/android/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/map:60,
                 from /home/vocalize/source/xxxxxxxxxxxxxxxxxxxxx/Lxxxxxxx.h:9,
                 from /home/vocalize/source/xxxxxxxxxxxxxxxxx/jni/cxxx_wrap.c:3:
/usr/local/android/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/functexcept.h:43:1: error: unknown type name 'namespace'
/usr/local/android/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/functexcept.h:44:1: error: expected ',' or ';' before '{' token
我正在使用以下Makefile.mk

include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(MY_LIB_DIR)include

LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_CFLAGS += -DANDROID_NDK

LOCAL_PATH := $(BASE_PATH)
LOCAL_MODULE := cxxxx_lib

LOCAL_SRC_FILES := cxxxx_wrap.c

LOCAL_STATIC_LIBRARIES := my_lib
LOCAL_LDLIBS := -llog 

include $(BUILD_SHARED_LIBRARY) 

<>我能做些什么来修复这些错误?

< p> C++ c+.h文件被包含在<代码> cxxxBrase.c>代码>中,这是.c文件。编译器使用源文件的扩展名来检测语言。因此,它假设为C,并被C++特定的语法所束缚

将cxxx_wrap.c重命名为.cpp或.cxx。或者用
\ifdef\uu cplusplus/#endif
环绕
\include“lxxxx.h”
行。或强制C++编译,指定<代码> -x C++ >代码>编译器选项。< /P> 一旦这样做,请确保cxxx_wrap中的所有JNI方法都是用JNIEXPORT声明的,或者用
extern“C”{}
包围的。否则,Java运行时将找不到它们


记录:将.h文件重命名为.HPP不会有帮助。

如果可能的话,请放一些cxxx.pReal.c文件的代码。你可以在下面的步骤中说明你是如何解决这个问题的吗?因为在我的例子中,C文件有一些会导致C++错误的行。那么我还有什么选择呢?如果你有正确的C++但是错误的C,那么重新命名源文件,以拥有.CPP扩展名。