User forums > Using Code::Blocks

Custom Makefile: How to build one module.obj from module.cpp ?

(1/2) > >>

JoJo:
Hi, I am new to C::B and am tying to import a project with a custom Makefile.

When I have a source module like "module.cpp", the command to build the respective object file would be to issue "make module.obj". How can I get there?

As far as I can see, Project->Build Commands->Make command support

$make
$makefile
$target
$file

For the "Compile single file" I entered

"$make -f $makefile $file.obj"

But when I hit "Build file" for a source.cpp, C::B issues

g++ [options]  -c source.cpp -o obj/Debug/source.o

but nowhere in my Makefile there is such a thing like "obj/Debug", and the options are different from the ones used with "make source.obj". So C::B is still using its own build scheme even though I used custom Makefile.

If $file the correct command to get the basename (without path or extendion) of a file?

Please help me.

stahta01:
Project -> Properties...

Tab: Project Setting
Is there a Checkmark on "This is an custom makefile"
What did you change the makefile name to?

Tim S.

JoJo:
> Is there a Checkmark on "This is an custom makefile"

Yes.

> What did you change the makefile name to?

Makefile is named "Makefile", I never changed that.

stahta01:
Post the full build log in code tags.
Edit: In your case build file results of the build log would likely be correct.

Tim S.

stahta01:
Is the Makefile and the CB Project file in the same folder?
If not, then I normally create an Makefile in the CB Project folder that calls the other makefile.

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version