实例化stl映射时android应用程序崩溃 [英] android application crashes when instantiating stl map

查看:95
本文介绍了实例化stl映射时android应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用我在android应用程序中用c ++编写的库,并且该库因非法指令错误而崩溃.我开始注释掉部分代码,直到除了成员变量(stl向量和映射)外什么都没有.所以我尝试直接调用除了创建地图外什么都不做的函数,当我这样做时,android studio中的调试器停止在地图的构造函数中.如果我删除地图并执行其他操作,例如从资产文件夹中读取一些文件,并将其内容作为字符串返回给Java接口,则它可以正常工作.我有办法继续使用c ++映射,因为似乎android c ++运行时实现在这里出错了吗?

I have been trying to use a library I wrote in c++ in an android application and its been crashing with illegal instruction error. I started commenting out parts of the code until nothing was left but member variables which are a stl vector and map. So I try and directly call function that does nothing but create a map and when i did this the debugger in android studio stopped inside the constructor of the map. If i remove the map and do anything else like read some files from asset folder and return their content as a string to java interface it works. Is there a way for me to continue using c++ maps because it seems that the android c++ runtime implementation is at fault here?

日志猫

A/libc:致命信号4(SIGILL),代码2,故障加法器0x7f795a502e89,在tid 585中

A/libc: Fatal signal 4 (SIGILL), code 2, fault addr 0x7f795a502e89 in tid 585

崩溃消息

SIGILL(信号SIGILL:非法指令操作数)

SIGILL (signal SIGILL: illegal instruction operand)

jni代码

extern "C"
JNIEXPORT void JNICALL
Java_com_hasebou_MainActivity_test(JNIEnv *env, jobject instance){

std::map<int,int> hello;
}

Java中的

声明

public native void test();

推荐答案

结果表明启用avx指令会导致此问题,因为android仅支持SSE

Turns out enabling avx instructions caused the problem because android only supports SSE

这篇关于实例化stl映射时android应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆