Thread: Gcc compiler not finding header files

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    120

    Gcc compiler not finding header files

    I dont know if this is the right place to post this but...

    Basicaly, i cant compile a simple program like:
    Code:
    #include <stdio.h>
    
    int main() {
    	printf("Hello world");
    }
    using the Mingws gcc c compiler, it just says that:
    main.c:1: No include path in which to find stdio.h

    i even tried to reinstall mingw with only the gcc compiler, but same error.

    i can use a c++ compiler to compile it, but i really need the c compiler atm :\
    any sugestions?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    You likely have an bad MinGW GCC installation.
    What folder/path is the MinGW installation in?
    Does the file "stdio.h" exist under that path in a sub-folder?

    NOTE: If you have multiple MinGW GCC installed; you MUST not have one installed in X:\mingw for any drive letter in place of X.

    Tim S.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    120
    Quote Originally Posted by stahta01 View Post
    You likely have an bad MinGW GCC installation.
    What folder/path is the MinGW installation in?
    Does the file "stdio.h" exist under that path in a sub-folder?

    NOTE: If you have multiple MinGW GCC installed; you MUST not have one installed in X:\mingw for any drive letter in place of X.
    My path is D:\utils\mingw32
    Its unlikely that i have a bad install of mingw, as i tried reinstaling it 2 times already ( and i also tried on the d:\mingw path)
    and yes, stdio.h exists in the mingw/include folder :\

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Open an Command prompt (cmd.exe)
    Type in the following command; what version do you have?
    Code:
    gcc -v
    Mine is
    Code:
    gcc version 4.4.1 (TDM-2 mingw32)
    What does this return?

    Code:
    gcc -print-search-dirs
    My result is this; the mingw base folder is "c:\greenapps\mingw_gcc4_4x_sjlj_tdm"

    Code:
    install: c:\greenapps\mingw_gcc4_4x_sjlj_tdm\bin\../lib/gcc/mingw32/4.4.1/
    programs: =c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../libexec/gcc/mingw32/4.4.1/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../libexec/gcc/;/usr/libexec/gcc/mingw32/4.4.1/;/usr/libexec/gcc/mingw32/;/usr/lib/gcc/mingw32/4.4.1/;/usr/lib/gcc/mingw32/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/mingw32/4.4.1/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/
    libraries: =c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/mingw32/4.4.1/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/;/usr/lib/gcc/mingw32/4.4.1/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/lib/mingw32/4.4.1/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/lib/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/mingw32/4.4.1/../../../mingw32/4.4.1/;c:/greenapps/mingw_gcc4_4x_sjlj_tdm/bin/../lib/gcc/mingw32/4.4.1/../../../;/mingw/lib/mingw32/4.4.1/;/mingw/lib/
    Note: The "install:" part is the important part for solving this problem.

    Tim S.
    Last edited by stahta01; 07-08-2011 at 10:24 AM.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by shiroaisu View Post
    ( and i also tried on the d:\mingw path)
    Delete or rename the folder MinGW on the D drive or delete all other MinGW installations.

    Tim S.

  6. #6
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Try adding the include search path to directory. You could do this by
    Code:
    gcc -B <directory>
    This will be included to the list of search paths which the compiler will look for.

    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Gee... did anyone happen to notice all those "wrong way" slashes in there?

    Unless MinGw does something internally to fix them, that's not going to work on any windows install...

    (Since I know this will come up... Yes, Win Vista and 7 will correct slashes for the UI elements of it's own browsers, but no version will fix broken environment variables)

  8. #8
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Except of course, every Windows version (including MS-DOS) will correct forwards to backwards when passed to any file opening functions. Until they get there, it's just aesthetics. The only time it matters is if you call the Nt* file functions yourself, and no sane person not writing a driver does that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler not finding my function
    By pilotmm in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2010, 04:43 PM
  2. Finding header file's contents
    By Else in forum C++ Programming
    Replies: 1
    Last Post: 03-05-2009, 07:22 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Help With finding a compiler
    By macman in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-15-2005, 08:15 AM
  5. include library header in header files
    By Raison in forum C++ Programming
    Replies: 6
    Last Post: 09-27-2004, 02:50 AM