Why can't g++ find iostream.h?

后端 未结 3 608
醉酒成梦
醉酒成梦 2020-11-27 20:06

I\'m trying to understand how to compile C++ programs from the command line using g++ and (eventually) Clang on Ubuntu.

I found a webpage which explains MakeFiles an

3条回答
  •  情话喂你
    2020-11-27 20:41

    Another related issue that wasn't mentioned here, so I will include it for anyone's future reference, is from the command line the compiler needs the environment path variable updated to find the location of the c++ header files. In windows you can just update the path environment using the 'advanced system properties' GUI and add the location of the c++ include files. This will update the PATH environment variable in Windows cmd & Cygwin automatically upon restarting the shell.

    To update your PATH from Linux or the Cygwin shell type... PATH=$PATH:/your_path_here Example:PATH=$PATH:/cygdrive/c/cygwin/lib/gcc/i686-pc-mingw32/4.7.3/include/c++ Also a good idea to add just the include directory as well: PATH=$PATH:/cygdrive/c/cygwin/lib/gcc/i686-pc-mingw32/4.7.3/include/ ...or check the proper directories for the location of your installation's include files, I recommend installing mingw for use with Cygwin, which is envoked with g++.

    To install additional needed packages in Cygwin re-run the Cygwin install utility & check install from Internet to add packages from web repositories and add mingw-gcc-g++ & mingw-binutils. To compile: g++ hello.cpp -o hello

    If using the gcc utility instead compile with the command: gcc hello.cpp -o hello -lstdc++ ... to get your executable.

    As long as you have either gcc or mingw installed and the path to the c++ include files is in your path environment variable, the commands will work.

提交回复
热议问题