11

When trying to run M-x Flymake-Mode in Emacs I get:

Flymake: Configuration error has occured while running (make -s -C ./CHK_SOURCES=helloworld_flymake.c SYNTAX_CHECK_MODE=1 check-syntax). Flymake will be switched OFF

I am invoking the command in a buffer called helloworld.c:

#include <stdio.h>

int main(void) {
  printf("Hello World");
  return 0;
}

And have a file called Makefile in the same directory:

helloworld: helloworld.c
 gcc helloworld.c -o helloworld

I'm running GNU Emacs 23.0.91.1 under Ubuntu 9.04.

Thanks in advance!

Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212

2 Answers2

19

Makefile' must contain thecheck-syntax' target. Append this to the Makefile:

check-syntax:
     gcc -o nul -S ${CHK_SOURCES}

Make sure you use a TAB to start the second line. Also there is a bug with flymake that makes you have to name the Makefile with a capital M. It won't work if you, say, call it "makefile." Watch out for that!

  • The problem with this method is gcc will not allow it to work if has more then one file. Anyway to get around this? gcc: fatal error: cannot specify -o with -c, -S or -E with multiple files compilation terminated. – Silverdev Feb 01 '14 at 06:21
  • One line: `check-syntax:; g++ -o nul -S ${CHK_SOURCES} --std=c++14; rm nul` – pank Nov 09 '16 at 16:20
1

Is this the actual content of your makefile? It looks like there is a space ' ' before the second line. This is supposed to be a tab:

helloworld: helloworld.c
 gcc helloworld.c -o helloworld

More like this:

helloworld: helloworld.c
    gcc helloworld.c -o helloworld

Keeping in mind, that the SO editor seems to have converted my tab character to spaces, so don't do that.

helloworld: helloworld.c
<press tab here>gcc helloworld.c -o helloworld
1800 INFORMATION
  • 131,367
  • 29
  • 160
  • 239
  • Yes, I'm using a tab, not a space. It compiles fine when I type "make" at the shell. –  Sep 06 '09 at 20:34