如何配置包含路径和使用标准库与gcc编译器? [英] How configure include path and use standard library with gcc compiler?

查看:347
本文介绍了如何配置包含路径和使用标准库与gcc编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个主题是几次,但我不能得到满意的答案。

  C:\Users\Krzysiek> gcc test.c 
test.c:3:20:fatal错误:iostream:没有这样的文件或目录
编译终止。

这是我尝试做的

  #include< iostream> 
using namespace std;

int main()
{
cout< 你好,世界!;
return 0;
}

使用include的简单程序



我听说过LIBRARY_PATH。所以我已经决定了。仍然这样的错误我有。

解决方案

GCC提供包装器调用其各种编译器。




  • 您正在使用 gcc ,这是针对C的(因此不会包含或链接C ++标准库;

    使用 g ++ ,用于C ++。




使用C ++源文件的常规扩展,它是 .cc .cxx 。 cpp


I know this topic was few times there, but I can't get satisfactory answer.

C:\Users\Krzysiek>gcc test.c
test.c:3:20: fatal error: iostream: No such file or directory
compilation terminated.

This is what I try to do

#include <iostream>
using namespace std;

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

Simple program with "include"

I've heard of LIBRARY_PATH. So I've setted that. Still this same error I have.

解决方案

GCC provides wrappers around calling its various compilers.

  • You are using gcc, which is for C (and consequently will not include or link the C++ standard library; the compiler would go on to complain about the rest of your code, too, since it's not valid C);

  • Use g++, which is for C++.

Also try to use a conventional extension for C++ source files, which is .cc, .cxx or .cpp.

这篇关于如何配置包含路径和使用标准库与gcc编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆