使用 arm-linux-gnueabi-g++ 交叉编译出来的的软件
编译命令
[Bash shell] 纯文本查看 复制代码 arm-linux-gnueabi-g++ -o helloworld ./HelloWorld.c -std=c++11 -static -g
Hello World.c代码
[C++] 纯文本查看 复制代码 #include <iostream>
#include <string.h>
using namespace std;
int main(){
cout<<"Hello World"<<endl;
for(int i=0;i<10;i++){
char* testchar=new char[100];
printf("%ld ",testchar);
strcat(testchar,"Hello World test char!");
cout<<testchar;
printf(" %ld\n",testchar);
delete[] testchar;
testchar=nullptr;
}
return 0;
}
在arm板上的情况
[Bash shell] 纯文本查看 复制代码 Hello World
868600 Hello World test char! 868600
868600 Hello World test char!Hello World test char! 868600
868600 Hello World test char!Hello World test char!Hello World test char! 868600
868600 Hello World test char!Hello World test char!Hello World test char!Hello World test char! 868600
868600 Hello World test char!Hello World test char!Hello World test char!Hello World test char!Hello World test char! 868600
*** Error in `helloworld': free(): invalid pointer: 0x000d40f8 ***
*** Error in `helloworld': malloc: top chunk is corrupt: 0x000d4160 ***
1003528 Hello World test char! 1003528
1003528 Hello World test char!Hello World test char! 1003528
1003528 Hello World test char!Hello World test char!Hello World test char! 1003528
1003528 Hello World test char!Hello World test char!Hello World test char!Hello World test char! 1003528
1003528 Hello World test char!Hello World test char!Hello World test char!Hello World test char!Hello World test char! 1003528
*** Error in `helloworld': free(): invalid pointer: 0x000f5008 ***
|