您的位置:首页 > 编程语言 > C语言/C++

ubuntu 8.04 C/C++开发环境搭建

2008-10-22 14:33 681 查看
 

初学Linux,留下印记。
1. 也许一两条命令就可以完成,

sudo apt-cdrom add 加入CD源
sudo apt-get update 或 sudo aptitude update 更新源列表
sudo apt-get install build-essential 或 sudo aptitude install build-essential 安装开发包
gcc -v 查看编译器版本
 

2. 写一个C语言程序hello.c测试一下:
$ vim hello.c
#include <stdio.h>
int main()
{
printf("hello ubuntu!/n");
return 0;
}
 
:wq 命令保存退出
 
$ gcc -o hello hello.c
$ ./hello
运行结果: 
hello ubuntu!

 

 

3. 切换到root用户 (可选)
sudo passwd root 设置root口令
su root 切换root用户

4. 数学库
如果 #include <math.h> 在gcc编译时需要加入 -lm 选项,如:
gcc -o abc abc.c -lm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息