Jump to content
Sign in to follow this  

GCC doesn't find header file

Recommended Posts

I posted this in General a week or so ago but it didn't get much attention. I hope it is not spamming to repost it here. This should be the more appropriate place for it anyway.


I'm running GCC on Windows 7. I downloaded the newest version a few weeks ago and --version shows 4.7.0. I have a .h file and a .c file in the same directory. The .c file compiles fine but when I try to use #include "a.h" it doesn't find it. Adding -I or -I. to the command line doesn't help. If I use -I and give the full path it does find it. The only options I'm using are:


-std=gnu99 -Os -mmcu=msp430G2553 -I. -o temp_src.elf temp_src.c


The exact error is "fatal error: a.h: No such file or directory"


I am guessing that the way MingGW handles directories on Windows is somehow slightly different than on Linux/Unix and that this is causing a problem. Any ideas?

Share this post

Link to post
Share on other sites

No, this is only the second. Maybe a moderator could delete the other one? It seems GCC related stuff should be here anyway.


<edit: previous posting in General has been deleted>

Share this post

Link to post
Share on other sites

Are you running msp430-gcc or gcc? Where did you download it from?  Please paste the source files you are trying to compile?  Please paste the entire command line and its output here.
It is hard to help people when they don't provide all the information needed to figure out what their problem is.
-std=gnu99 -Os -mmcu=msp430G2553 -I. -o temp_src.elf temp_src.c
so .. if that is meant be used with msp430-gcc .. the mmcu arg is wrong, it is case sensitive
msp430-gcc -std=gnu99 -Os -mmcu=msp430g2553 -I. -o temp_src.elf temp_src.c
for example:

#include <msp430.h>
#include "b.h"
int main(void)
   P1DIR |= BIT0;
   while(1) {
void some_func(int a) {
  // do something here
  volatile int cnt = 10;
  do {
    P1OUT ^= BIT0;
 * a.h

#ifndef _A_H
#define _A_H
void some_func(int a);

$ msp430-gcc -v
Using built-in specs.
Reading specs from /home2/kimballr/opt/mspgcc_energia/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/lib/msp430mcu.spec
Target: msp430
Configured with: ../../gcc/configure --enable-languages=c,c++ --disable-nls --target=msp430 --prefix=/home/kimballr/opt/mspgcc_energia --with-pkgversion='MSPGCC 20120406 (With patches: sf3540953 sf3559978)'
Thread model: single
gcc version 4.6.3 20120301 (mspgcc LTS 20120406 unpatched) (MSPGCC 20120406 (With patches: sf3540953 sf3559978)) 

$ msp430-gcc -Wall -std=gnu99 -Os -mmcu=msp430g2553 -I. -o temp_src.elf temp_src.c
temp_src.c:2:15: fatal error: b.h: No such file or directory
compilation terminated.

Of course I introduced an error by including "b.h", however If I change that to a.h it works just fine.

You are more likely to get a response if you make it easier for us to see your problem and help you.


Share this post

Link to post
Share on other sites

A common problem with people using windows are paths that are too long. If you installed msp430-gcc in some c:\program files\some long assed\path\to the\top level\of gcc\ ... well gcc uses long paths and lots of ..\..\..\ includes for its stuff.  This leads to having filenames that exceed the max path length of win32.


You might want to install gcc in someplace like c:\msp430.


You might also want to use a short location for of your source files and try and avoid spaces in the name, 

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...