Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8687423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:06:43+00:00 2026-06-12T23:06:43+00:00

g++ gives me errors of the form: foo.cc:<line>:<column>: fatal error: <bar>: No such file

  • 0

g++ gives me errors of the form:

foo.cc:<line>:<column>: fatal error: <bar>: No such file or directory
compilation terminated.

It is the same when compiling C-programs with gcc.

Why is that?


Please note: This question has been asked many times before, but each time it was specific to the askers situation. This question’s purpose is to have a question that others can be closed as duplicates of, once and for all; a FAQ.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:06:44+00:00Added an answer on June 12, 2026 at 11:06 pm

    Your compiler just tried to compile the file named foo.cc. Upon hitting line number line, the compiler finds:

    #include "bar"
    

    or

    #include <bar>
    

    The compiler then tries to find that file. For this, it uses a set of directories to look into, but within this set, there is no file bar. For an explanation of the difference between the versions of the include statement look here.

    How to tell the compiler where to find it

    g++ has an option -I. It lets you add include search paths to the command line. Imagine that your file bar is in a folder named frobnicate, relative to foo.cc (assume you are compiling from the directory where foo.cc is located):

    g++ -Ifrobnicate foo.cc
    

    You can add more include-paths; each you give is relative to the current directory. Microsoft’s compiler has a correlating option /I that works in the same way, or in Visual Studio, the folders can be set in the Property Pages of the Project, under Configuration Properties->C/C++->General->Additional Include Directories.

    Now imagine you have multiple version of bar in different folders, given:


    // A/bar
    #include<string>
    std::string which() { return "A/bar"; }
    

    // B/bar
    #include<string>
    std::string which() { return "B/bar"; }
    

    // C/bar
    #include<string>
    std::string which() { return "C/bar"; }
    

    // foo.cc
    #include "bar"
    #include <iostream>
    
    int main () {
        std::cout << which() << std::endl;
    }
    

    The priority with #include "bar" is leftmost:

    $ g++ -IA -IB -IC foo.cc
    $ ./a.out
    A/bar
    

    As you see, when the compiler started looking through A/, B/ and C/, it stopped at the first or leftmost hit.

    This is true of both forms, include <> and incude "".

    Difference between #include <bar> and #include "bar"

    Usually, the #include <xxx> makes it look into system folders first, the #include "xxx" makes it look into the current or custom folders first.

    E.g.:

    Imagine you have the following files in your project folder:

    list
    main.cc
    

    with main.cc:

    #include "list"
    ....
    

    For this, your compiler will #include the file list in your project folder, because it currently compiles main.cc and there is that file list in the current folder.

    But with main.cc:

    #include <list>
    ....
    

    and then g++ main.cc, your compiler will look into the system folders first, and because <list> is a standard header, it will #include the file named list that comes with your C++ platform as part of the standard library.

    This is all a bit simplified, but should give you the basic idea.

    Details on <>/""-priorities and -I

    According to the gcc-documentation, the priority for include <> is, on a “normal Unix system”, as follows:

     /usr/local/include
     libdir/gcc/target/version/include
     /usr/target/include
     /usr/include
    

    For C++ programs, it will also look in /usr/include/c++/version, first. In the above, target is the canonical name of the system GCC was configured to compile code for; […].

    The documentation also states:

    You can add to this list with the -Idir command line option. All the directories named by -I are searched, in left-to-right order, before the default directories. The only exception is when dir is already searched by default. In this case, the option is ignored and the search order for system directories remains unchanged.

    To continue our #include<list> / #include"list" example (same code):

    g++ -I. main.cc
    

    and

    #include<list>
    int main () { std::list<int> l; }
    

    and indeed, the -I. prioritizes the folder . over the system includes and we get a compiler error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Django the {{ form.field.errors }} gives the validation error for a field. But
The command $ make all gives errors such as rm: cannot remove '.lambda': No
Is there a way to give a form a special error rendering function in
This function declaration gives me errors: ostream& operator<<(ostream& os, hand& obj); The errors are:
When I am using subfig package in latex, it gives some errors: Package subfig
Hi While I am trying to upload application it gives me this errors Please
I'm having a char(4) FK reltionship, and it gives me lots of errors when
This function gives error: function RefreshGrid(){ window.location.href=Form_ElameMamoreBazdid.aspx; }
the second function gives error C2803 http://msdn.microsoft.com/en-us/library/zy7kx46x%28VS.80%29.aspx : 'operator ,' must have at least
I have following asp.net code but it gives error when I change dropdown selected

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.