1

I have a remote, cross build and I would like to manually take the gcc command line from the makefile build, and use it to setup the Eclipse CDT project file with include paths and preprocessor definitions. How can I do this?

Simon
  • 563
  • 1
  • 6
  • 11

1 Answers1

2

The usual way to do this is using the Build Output Parser.

  • Create a Makefile project
  • Enable the Build Output Parser in Project Properties | C/C++ General | Preprocessor Include Paths, Macros etc. | Providers tab (in might already be enabled).

    • Configure it if necessary (e.g. the "Compiler command pattern" may need to be adjusted to match your cross-compiler's name.)
  • Make sure you can build the project from within Eclipse. If necessary, configure the make target name and invocation directory in Project Properties | C/C++ Build.

  • Invoke the build from within Eclipse.

    • The Build Output Parser will run automatically at the end of the build, parse the compiler commands in the build output, and configure the project's include paths and preprocessor defines based on the commands.

Note: for this to work, the build output needs to actually contain the raw compiler commands. Sometimes, e.g. with CMake-generated makefiles, it doesn't by default but there is an option to enable it - if so, be sure that the "Build command" specified in Project Properties | C/C++Build contains that option.

HighCommander4
  • 50,428
  • 24
  • 122
  • 194
  • Thanks HighCommand - this is indeed the right way to do this for a local build. In my situation I build remotely on a different machine over ssh, so the paths used in Eclipse have a different prefix from those appearing in the build output. Can the build output parser handle this? Is there a way for me to cut and paste a single gcc command line into the build output parser and have it set up the includes and defines? – Simon Jul 31 '17 at 11:33
  • 1
    @Simon The paths of files don't matter, but it's important that the build output parser recognize the compiler command. Being able to customize the "compiler command pattern" should help with that. – HighCommander4 Jul 31 '17 at 15:14
  • 1
    @Simon You could write a dummy makefile that just echoes the command line in question. – HighCommander4 Jul 31 '17 at 15:16