How to debug c++ makefile projects


First I want to say I am hugely impressed with c9, thank you for the hard work that went into this.

I created a simple c++ test project with a makefile that build a linux binary out of two source files.

LIBS=-lmgl -lGL -lpng

all: main

%: draw_util.o
g++ -std=c++11 < -o @ draw_util.o $(LIBS)

g++ -std=c++11 -c $(LIBS)

%: %.c
gcc < -o @

I can run ‘make’ in bash to compile, or, I can compile via new build target I made that invokes make. However, debugging is not possible because the C++ runner is designed around a single cc file. Is there a C++ Runner designed for larger scale projects you can share?

It seems right now the C++ support is limited to a one-file project with no makefile. The “hello world” c++ sample project has an unused Makefile in it, so seems someone is working on this support.

Beginner - C project - trouble compiling - Main.c:(.text+0xa): undefined reference to

you can edit the runner to call your makefile instead of g++ tricky part is to pass -ggdb3 -o0 to g++ when compiling for debugging.


Thanks Harutyun, will make custom runner. Are there plans to support multiple-file c++ projects in the future?


Is there a common way of compiling c++ projects?
Currently the only plan we have is to make it easier to create runners.


Using make with makefiles is common enough, I think most teams either use make, or they have some custom system and they maintain make files for compatibility.
I used to work for a game company, we built games for Playstation3, Xbox360 and PC simultaneously and had to use linux for PS3 build and windows for Xbox360 and PC with makefiles and visual studio project files respectively.

I think supporting these 3 common tasks would get us a long way:

  1. Compile existing file (but do not try to link, since no main() exists and libraries are missing)
  2. Compile and link whole project (make Makefile)
  3. Compile & run project (with or without debugger)

LIB dependency support is missing now, and the runners alone are not a good solution (you’d have to hard code library names into the build rule).

For TDD teams running unit tests is also quite important. Lib dependencies are also a problem here, but running from bash will work fine.

Suggestion is rebuild the “hello world” example with a makefile and a build rule to trigger that makefile and correctly pass symbols to gdb. Generic makefiles are common, ie: