在Ubuntu下用Eclipse开发ARM多线程程序
来源:互联网 发布:迅雷emule监听端口 编辑:程序博客网 时间:2024/05/24 06:25
第1步:安装 Eclipse 开发环境
http://blog.csdn.net/ex_net/article/details/7251664
第2步:配置Eclipse 的arm开发环境
http://blog.csdn.net/ex_net/article/details/7251845
第3步:新建一个过程,配置好环境
敲入下面的代码
#include <pthread.h>#include <stdio.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
void *create(void *arg)
{
while(1)
{
printf("thread is Running ..... ");
sleep(5);
}
}
void *ReaderThread(void *arg)
{
while(1)
{
sleep(4);
printf("Read ID=\r\n");
}
}
int main(int argc, char *argv[])
{
pthread_t tidp;
int rc1,rc2;
rc1=pthread_create(&tidp,NULL,create,NULL);
if(rc1!=0)
{
printf("pthread_create is not created ... \r\n");
return -1;
}
printf("prthread_create is created... \r\n");
rc2=pthread_create(&tidp,NULL,ReaderThread,NULL);
if(rc2!=0)
{
printf("ReaderThread is not created ... \r\n");
return -1;
}
printf("ReaderThread is created... \r\n");
while(1)
{
printf("System is Runing...\r\n");
sleep(1);
}
return 0;
}
编译看看效果。
系统编译出错!
提示:undefined reference to `pthread_create'
原因是arm-linux-g++ 在默认编译情况下,不会加载线程库。
因此需要设置Eclipse
注意: 需要设置 ARM 和 Debug(X86)环境。
设置好后,再次编译看看
编译成功,没有错误!
下载到开发板,运行看看效果!
切换编译模式为DEBUG(x86)看看效果
左边是6410开发板上的程序效果,右边是X86的PC上效果!
酷吧!
C/C++的跨平台编程是不是很简单呢!
- 在Ubuntu下用Eclipse开发ARM多线程程序
- 在Ubuntu下用Eclipse开发ARM多线程程序
- ubuntu下使用eclipse c/c++开发arm linux程序
- Ubuntu下Eclipse搭建ARM开发环境
- Ubuntu下Eclipse搭建ARM开发环境
- Ubuntu下Eclipse搭建ARM开发环境
- Ubuntu下Eclipse搭建ARM开发环境
- 【Ubuntu手记】开发多线程程序时在eclipse中添加libpthread.a库
- ubuntu下的qt程序移植至ARM开发板
- 在Ubuntu下配置eclipse开发GTK+
- 在Ubuntu下配置eclipse开发GTK+
- 在Ubuntu下搭建eclipse开发环境
- eclipse开发&调试ARM程序
- 如何在ubuntu下搭建arm的集成开发环境
- 如何在Linux下用eclipse开发C/C++程序
- 如何在Linux下用eclipse开发C/C++程序
- 如何在Linux下用eclipse开发C/C++程序
- 在Windows下用Eclipse开发和运行Spark程序
- SecureCRT 常用技巧
- 想养一只猫
- 坚持理想与目标、并从小事慢慢做起
- hibernate知识
- 计算机核心期刊一览
- 在Ubuntu下用Eclipse开发ARM多线程程序
- 无题
- 有没有virtual的构造函数? 子类如何调用父类的构造函数? 用CWinApp派生类如何构造程序对象?
- linux命令缩写
- 【原】一步一步D3D_1.相关概念的简述(1.3_计算机图形学数学基础和图形变换)
- Eclipse 关联jdk源文件
- 解决namenode启动 **dfs/name is in an inconsistent state的问题
- DirectX Forum FAQ 重点部分摘译
- webkit浏览器捕获touch gestures的插件