关闭

eclipes CDT : Creating a simple Standard C++ Project -- "Hello World on a Windows Platform"

标签: c++windowsmakefilefilecharacterbuild
791人阅读 评论(0) 收藏 举报
分类:
Creating a simple Standard C++ Project -- "Hello World on a Windows Platform"

This section will use an example to create the familiar "Hello World!" C++ program. First, ensure that you have the CDT installed within Eclipse, as described above. Open a C/C++ Perspective and complete the following steps:

  1. In the C/C++ Projects View right click and select "New Project ..."
  2. Select "C++" in the left pane and the select "Standard Make C++ Project"
  3. Enter a name for the new project and select Finish. Note: you can determine the "Build Settings" from this dialog, but we will do so later, in the build section.
  4. In the C/C++ Projects View right click and select "New" > "Simple" > "File". Name your file hello.cpp
  5. Repeat the previous step and name the second new file "makefile".
  6. Copy the following text into the "hello.cpp" file:
    #include <stdio.h>
    int main()
    {
    printf("Hello World/n");

    //block until user types something
    fgetc(stdin);
    return 0;
    }

    Now, save the file.

  7. Copy the following text into the "makefile" file:
    Remember that makefile requires that indented lines use a <tab> character and not spaces
    hello.exe : hello.o
    g++ -o hello.exe hello.o

    hello.o : hello.cpp
    g++ -c hello.cpp

    all : hello.exe
    clean :
    -rm hello.exe hello.o

    Now, save the file.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:206278次
    • 积分:3264
    • 等级:
    • 排名:第10393名
    • 原创:108篇
    • 转载:53篇
    • 译文:0篇
    • 评论:37条
    最新评论
    佛道玄学
    围棋
    学院