Jiangtang's profile技止于此BlogListsNetwork Tools Help

Blog


    4/4/2007

    Windows下运用Linux工具(一):G++/Cyguns

    想到要一个C++编译器,只是要运行一些C++程序,犯不着装吓人的集成开发环境如VC之类,就在Arthur H. Lee的主页上找了一个G++的Windows版,Cyguns,安装以后占的硬盘才37M多一些。安装以后记得设置环境变量,不过比Java简单多了:重要的是找到二进制文件bin的文件地址,按折默认的安装路径,我的bin文件在"C:\cygnus\cygwin-b20\H-i586-cygwin32\bin",找到

    “我的电脑”——“属性”——“高级”——“环境变量”——“系统变量”——“Path”

    如果没有“Path”,就创建一个。如果以前设置过别的Path,就在它的末尾先加一个分号,接着把bin的文件路径填上如:

    ;C:\cygnus\cygwin-b20\H-i586-cygwin32\bin

    以后就可以用记事本写程序,在控制台编译并运行了。比如写一个"Hello World":

    // hello.cpp

    #include <iostream>
    using namespace std;

    int main() {
    cout << "Hello World!";
    return 0;
    }

    把这个文件取名为hello.cpp, 并存于如"E:\cpp"。一个组合快捷键“开始+R”,打开“运行”,在命令栏敲入cmd,就来到控制台,类似于doc的那种界面。你可以通过两步来到制定的E:\cpp文件夹:

    1. 敲入 e:   回车,这样就会看到E:\>,光标在这里跳跃;
    2. 敲入 cd cpp,回车,这样就会看到E:\cpp>,敲入dir来查看文件夹,你就会看到我们将要处理的hello.cpp;
    3. 接下来就是编译hello.cpp,敲入   g++ -g hello.cpp -o hello -lm
    4. 如果程序没有问题,E:\cpp下面应该出现一个hello.exe的可执行文件;
    5. 接着在控制台敲入hello,回车,屏幕就会打印一条Hello World!

    就这么简单。

    Comments (3)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    No namewrote:
    您需要二手液晶显示屏废旧液晶屏么?我们是不折不扣的二手液晶屏、旧液晶屏大批发商,长期大量供应可再利用的旧液晶屏。我公司提供的各种尺寸的二手液晶屏, 不同厚薄如笔记本屏,均已经过我们严格的分类,检验,测试流程。请访问协力液晶屏www.sceondhandlcd.com[ghejdbgjhcbfeha]
    Nov. 21
    Nov. 9
    Nov. 3

    Trackbacks

    The trackback URL for this entry is:
    http://johnthu.spaces.live.com/blog/cns!2053CD511E6D5B1E!144.trak
    Weblogs that reference this entry
    • None