南方Linux论坛   首页 | 行业 | 下载 | Blog | 桌面应用 | 数据库 | 电子商务 | 文摘 | 网络服务 | 开源 | 系统管理 | 内核代码 | 教程

返回   南方Linux论坛 > Linux发行版分类讨论区 > Redhat/Fedora专题
注册账号 Blog 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记讨论区已读

发表新主题 回复
 
主题工具 显示模式
旧 2008-10-27, 04:07 AM   #1
TOM
级别:10 | 在线时长:143小时 | 升级还需:22小时级别:10 | 在线时长:143小时 | 升级还需:22小时级别:10 | 在线时长:143小时 | 升级还需:22小时级别:10 | 在线时长:143小时 | 升级还需:22小时
论坛义工
 
注册日期: 2006-07-05
帖子: 477
精华: 0
现金: 1632 金币
资产: 1632 金币
声望: 16 TOM 正向着好的方向发展
不错 Ubuntu 8.04 安装 C 与 C++ 编码器

If you are a developer you need C and C++ Compiler for your development work.In ubuntu you can install the build-essential for C and C++ compilers.

Install C and C++ Compilers in Ubuntu

sudo aptitude install build-essential

This will install all the required packages for C and C++ compilers

Testing C and C++ Programs

Compiling Your first C Programs

Now you need to open first.c file

sudo gedit first.c

add the following lines save and exit the file


http://www.ubuntugeek.com/images/c/1.PNG


Firstly compile the code using the following command

cc -c first.c

that would produce an object file you may need to add to the library.

then create an executable using the following command

cc -o first first.c

Now run this executable using the following command

./first

Output should show as follows

Hello, world

Compiling your first C++ program

If you want to run c++ program follow this procedure

g++ is the compiler that you must use.

you should use a .cpp file extension rather than a .c one

You need to create a file

sudo gedit first.cpp

add the following lines save and exit the file



http://www.ubuntugeek.com/images/c/2.PNG


Run your C++ Program using the following command

g++ first.cpp -o test

./test

Output should show as follows

Hello World!

此帖于 2008-10-27 04:19 AM 被 TOM 编辑.
TOM 当前离线  
回复时引用此帖
发表新主题 回复


当前查看此主题的会员: 1 (0 位会员和 1 位游客)
 
主题工具
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

论坛启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码


所有时间均为北京时间。现在的时间是 07:54 AM


vBulletin 3.6.8 Powered by 南方Linux联盟
版权所有 ©2004 - 2009, bbs.linuxunion.net