Linux下C和C++开发基础
Linux下C和C++开发基础
基本编程概念
n 编程语言:C 、C++
n 编译(compile):源文件(.c)->目标文件(.o)
n 连接(link):目标文件(.o)->可执行文件
n 库(library):静态连接库(.a)、动态连接库(.so)
Linux下开发工具
n编辑器:vi、emacs、窗口编辑器
n编译器:GCC
n调试器:GDB
n可执行文件工具:Binutils
n连接器:ld
n汇编程序:as
n库管理工具:ar
n可执行文件符号管理:nm
n显示可执行文件信息:objdump
简单程序示例(C语言):
n hello.c
/***************************
C代码
#i nclude <stdio.h>
int main(int argc,char **argv)
{
printf("HelloWorld!\n");
return 0;
}
/***************************
n编译方法:gcc –o hello hello.c
n运行方法:./hello
简单程序示例(C++语言):
#i nclude <stdio.h>
int main(int argc,char **argv)
{
printf("HelloWorld!\n");
return 0;
}
/***************************
n编译方法:gcc –o hello hello.c
n运行方法:./hello
简单程序示例(C++语言):
n hello.cpp
/*******************************
C代码
#i nclude <iostream>
using namespace std;
int main(int argc,char **argv)
{
cout << "Hello World!“ << endl;
return 0;
}
#i nclude <iostream>
using namespace std;
int main(int argc,char **argv)
{
cout << "Hello World!“ << endl;
return 0;
}
/*******************************
n 编译方法:g++ –o hello hello.cpp
n 运行方法:./hello
GCC编译器
n GNU平台下主流编译器
n目前最新稳定版4.0
n官方网站:http://gcc.gnu.org
n支持编译语言:C、C++、Objective-C、
Objective-C++、Java、Fortran、Ada
n跨平台支持:支持几乎所有主流操作系统,如
Linux、UNIX、Windows等。支持多种硬件平
台,如X86、ARM、PPC、MIPS等
n交叉编译
相关文档:
1.CPU&进程
1.1 top命令
top - 20:07:00 up 186 days, 3:47, 3 users, load average: 0.01, 0.02, 0.00
Tasks: 82 total, 1 running, 80 sleeping, 1 stopped, 0 zombie
Cpu(s): 3.7% us, 0.0% sy, 0.0% ni, ......
linux目录架构
/ 根目录
/bin 常用的命令 binary file 的目錄
/boot 存放系统启动时必须读取的档案,包括核心 (kernel) 在内
/boot/grub/menu.lst GRUB设置
......
http://public0821.javaeye.com/blog/423941
C++调用JAVA主要用到了SUN公司的JNI技术, JNI是Java Native Interface的 缩写。从Java 1.1开始,Java Native Interface (JNI)标准成为java平台的一部分,它允许Java代码和其他语言写的代码进行交互。相关资料见http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/jniTOC.htm ......
C字符串处理函数的实现(Linux)
#include <stddef.h>
char * ___strtok = NULL;
char * strcpy(char * dest,const char *src)
{
char *tmp = dest;
while ((*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
}
char * strncpy(char * des ......