我是一只小小小小鸟

导航

 

用Eclipse的CDT,不能编译,应该有文件没搞全,不知到怎么弄,于是用vim。
先获得g++,gbd等编译工具

sudo apt-get install build-essential

 然后装vim

sudo apt-get install vim

关于vim,可以参看vim简明教程
http://hi.baidu.com/shuperjolly/blog/item/db43832f115fdb3e1f3089ff.html

 

我说点简单必要的:
进入文件:

vim hello.cpp

保存当前文件(w后面加文件名就是另存为了):

<ESC>:w

强制退出vim

<ESC>:q!

编译和执行

:!g++ hello.cpp -o hello
:
!./ hello

复制和粘帖(终端下)

<CTRL+SHIFT+C>
<CTRL
+SHIFT+V>

单词补全

<Ctrl+n> 下一个匹配项
<Ctrl
+p> 上一个匹配项

 

对vim进行些配置

sudo gedit ~/.vimrc

把这些加入

set linespace=4 set tabstop=4 set shiftwidth=4 set expandtab set autoindent set cindent set nocompatible set history=500 set ignorecase set nu

 具体可见上面的那篇博客里的说明。

 

 

 

 

网上还另外找了一个mingw,可以编译windows程序,拿了备用把
http://www.xxlinux.com/linux/article/accidence/install/20071226/13435.html

 
i586-mingw32msvc-g++(编译C++程序)

i586
-mingw32msvc-gcc(编译C程序)
#include

int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
MessageBox (NULL,
"Hello", "Hello Demo", MB_OK);
return (0);
}

实例:

i586-mingw32msvc-gcc hello.c -o hello.exe -mwindows

注:-mwindows指示其编译的是windows程序,若编译的是console(命令行)程序,则不需要这个参数。

 

posted on 2011-01-25 15:48  cloudygoose  阅读(1399)  评论(0)    收藏  举报