Codebench and Makefiles

6 posts / 0 new
Last post
cha05e90
cha05e90's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2011-02-07 20:22
Codebench and Makefiles

After fiddeling around with some single source files I decided to put all the #includes, prototypes and defines into a new header file. Codebench did the obvious and wrote a new Makefile (and a new project file as well). After that I were not able to compile anything. After some investigation I found the following:

My old (working!) Makefile for the single source file looked like this:

  1. $(BIN): $(OBJ)
  2. # Debug builds require the -g or -gstabs option in CFLAGS
  3. # You may also need to move the LDFLAGS variable depending on the contents
  4. $(CC) $(OBJ) $(LIBS) -o $(BIN) $(CFLAGS) $(LDFLAGS)
  5. strip $(BIN) -o $(BIN)
  6.  
  7. Example.o: Example.c
  8. $(CC) -c Example.c -o Example.o $(CFLAGS)

The new generated Makefile for one source and one header file looked like this:

  1. $(BIN): $(OBJ)
  2. # Debug builds require the -g or -gstabs option in CFLAGS
  3. # You may also need to move the LDFLAGS variable depending on the contents
  4. $(CC) -o $(BIN).debug $(OBJ) $(LDFLAGS) $(LIBS)
  5. strip $(BIN).debug -o $(BIN)
  6.  
  7. Example.o: Example.c header.h
  8. $(CC) -c Example.c -o Example.o $(CFLAGS)

It doesn't compile, because the "$(CFLAGS)" is missing in the "$(BIN):" part of the new makefile. Further I never specified to do a "Example.debug" binary ("$(BIN).debug").

Any idea where this comes from? AFAIK Codebench uses a standard "make -f" call, but I really don't know where this omitting (or including) of $(CFLAGS) and the binary naming with a ".debug" is controlled...

Rigo
Rigo's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2011-01-24 21:55
I'd hazzard a guess

I'd hazzard a guess here:
http://codebench.co.uk/docs/projectinfo.html#compiler

Specifically the "Include debug symbols" part.

And the CFLAGS variable is not needed, because they are compiler flags, and the "BIN" rule is actually a job for the linker.
Giving the actual error from the make would be a much better way to covey any potential problem.

Simon

cha05e90
cha05e90's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2011-02-07 20:22
Hello Simon! Thanks for that

Hello Simon!

Thanks for that very useful hint about the linker vs. compiler switches. I had accidentally put the usual "-lauto" etc. into the compiler switches instead of the linker section. So now it compiles just nice, BUT - I still get two executables: one with ".debug" extension and one normal, which seems to be the "stripped" version of the debug exe. Is this the normal Makefile and executable output?

BTW: My settings window doesn't show the contents of your linked window (no "Include Debug Symbols" here...Codebench v0.23)?!?

X1000|II/G4|440ep|2000/060|2000/040|1000

Rigo
Rigo's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2011-01-24 21:55
Hmmm, well that oversight wil

Hmmm, well that oversight wil be fixed in the next public version.

It is normal practice to create an executable compiled with debug symbols that is useful for debugging during development. This is then "stripped" to create a release executable. All the makefile is doing is automating that for you, nothing to worry about.

Simon

cha05e90
cha05e90's picture
Offline
Last seen: 6 years 1 month ago
Joined: 2011-02-07 20:22
Excellent, thanks for that

Excellent, thanks for that answer!

X1000|II/G4|440ep|2000/060|2000/040|1000

hypex
hypex's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-09-09 16:20
I'm looking forward to the

I'm looking forward to the new version. I tried to use CodeBench to create a makefile from a fairly large set of sources. But all it does is slowly add the sources (this is an X1000) and then crash leaving me with a blank makefile.

Perhaps less annoying is the bug where I add sources for a new project and the build icon is ghosted out.

Log in or register to post comments