code4app

测试文件test.cpp

#include <iostream>
using namespace std;

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

1.安装c++编译环境,确保在命令行下输入g++ test.cpp 能正确生成二进制文件

i. 安装xcode, 在appstore可以下到。此时g++可以用,但是iostream,stdio.h等文件统统没有,因为相关命令行工具没有安装完成(坑爹!!)!

ii. 安装完整的g++命令行工具

Xcode->open developer tool-> More developer tools...

此时会跳转到apple网站上,下载最新版本的Command Line Tools(OS X XXXXX) for Xcode, 安装

OS X的名称,在苹果->about this mac上可以查到os的版本号,然后根据版本号去google它叫什么名字,俺们10.9.3叫Mavericks)

安装完成后,/usr/include下将出现各种熟悉的头文件如stdio.h以及一个目录c++

此时命令行执行g++ test.cpp, 所有报错消失,终于可以成功编过了

 

2. 安装eclipse,官网下载

 

3.安装cdt:

在eclipse ->Help->Install New Softerware.

在最上的url中输入cdt的下载url,http://download.eclipse.org/tools/cdt/releases/juno,

出现CDT Main Features和CDT Optional Features,点开,选定自己需要安装的项,安装

重启eclips,在File ->New->下出现C/C++ Project, CDT安装完成

 

4.设置CDT

在eclipse下,Project->Properties->C/C++ General->Paths and Symbols

GNU C  设为/usr/include

GNU C++ 设为/usr/include/c++/版本号

 

5重启eclips,新建一个c++工程,加入以上测试文件,build,run,大功告成!

 

分类:

技术点:

相关文章:

  • 2021-09-28
  • 2021-05-03
  • 2021-09-16
  • 2021-10-25
  • 2021-08-03
  • 2021-06-10
  • 2021-09-09
猜你喜欢
  • 2021-07-31
  • 2022-01-21
  • 2022-01-01
  • 2021-06-23
  • 2021-10-05
  • 2021-12-05
  • 2021-08-08
相关资源
相似解决方案