Reducing complexity for starting a project

D

dataangel

After spending a lot of time writing code in other languages,
returning to C++ and starting a new project has been painful. It seems
in order to get anything done you need to #include, add linker
parameters, create a makefile, and update that makefile everytime you
add new files. I realize that _sometimes_ you want to #include a
header but potentially link against different object files, but for me
and I think most people making desktop applications that's pretty
rare. What I'd like to do is something like:

#include <SDL/sdl.h>

And my linker flags would be automatically updated to link SDL.
Additionally, my project would be a single folder, and any *.cpp files
I had inside or in subfolders would just get compiled when I typed
"make," without me having to write any sort of "Makefile" whatsoever.
I don't need anymore flexibility in my build system. I just want
linker flags to be inferred and for my makefile to automatically
update for new files, without having to commit to a bloated IDE (I
like emacs).

Are there any tools like this?

Thanks

Joe
 
I

Ian Collins

dataangel said:
After spending a lot of time writing code in other languages,
returning to C++ and starting a new project has been painful. It seems
in order to get anything done you need to #include, add linker
parameters, create a makefile, and update that makefile everytime you
add new files. I realize that _sometimes_ you want to #include a
header but potentially link against different object files, but for me
and I think most people making desktop applications that's pretty
rare. What I'd like to do is something like:

#include <SDL/sdl.h>

And my linker flags would be automatically updated to link SDL.
Additionally, my project would be a single folder, and any *.cpp files
I had inside or in subfolders would just get compiled when I typed
"make," without me having to write any sort of "Makefile" whatsoever.
I don't need anymore flexibility in my build system. I just want
linker flags to be inferred and for my makefile to automatically
update for new files, without having to commit to a bloated IDE (I
like emacs).
You only have to set these things up once, probably in less time that it
took to compose this message! That's the purpose of tools like Make and
Ant.
 
D

dataangel

It's still a pain over other languages, and I'm still going to have to
update the Makefile every time I decide to split code into another
file, which happens a lot at the beginning of a project. We're
programmers, we're lazy and like efficient solutions ;)
 
I

Ian Collins

dataangel wrote:

Please don't top-post...
It's still a pain over other languages, and I'm still going to have to
update the Makefile every time I decide to split code into another
file, which happens a lot at the beginning of a project. We're
programmers, we're lazy and like efficient solutions ;)
That's why they give us IDEs...

Joking aside, refactoring a makefile or build script is just part of the
development process. It's the price we pay for flexibility and the lack
of dependence on an interpreter/VM the knows where to find things.
 
G

Gianni Mariani

dataangel wrote:
....
Are there any tools like this?

MakeXS does somthing like this but it's not perfect.

At the moment MakeXS uses GNU make and m4. The idea behind MakeXS is
that simply putting a .cpp file in an appropriate directory will make
the Right™ things happen.

It also automatically works our the root of the tree, the include
directories, libs etc etc. You can go to any directory and type "make"
and everything in that folder and below is built. It supports "release"
and "debug" (work) builds - bulding of unit tests, running of unit
tests, 64 bit vs 32 bit builds, doxygen builds and easily allows
environment variable overrides or even developer specific configuration.

The latest version can be found with the Austria C++ "alpha".
http://netcabletv.org/public_releases/

I don't know how well other tools like cmake, Jam etc work. I used
cmake on one project and I was not totally happy with its win32 support.
Although MakeXS requires cygwin so it's not much better.

The learning curve is steep but short.
 
G

Gianni Mariani

Ian Collins wrote:
....
Joking aside, refactoring a makefile or build script is just part of the
development process. It's the price we pay for flexibility and the lack
of dependence on an interpreter/VM the knows where to find things.

make is the assembler of build tools. you can build an awful lot on top
of make that reduces the maintenance of trivial things like the OP is
alluding to.

MakeXS does alot with GNU make but much more can be done to eliminate
virtually all trivial work.
 
D

Daniel Kraft

dataangel said:
After spending a lot of time writing code in other languages,
returning to C++ and starting a new project has been painful. It seems
in order to get anything done you need to #include, add linker
parameters, create a makefile, and update that makefile everytime you
add new files. I realize that _sometimes_ you want to #include a
header but potentially link against different object files, but for me
and I think most people making desktop applications that's pretty
rare. What I'd like to do is something like:

#include <SDL/sdl.h>

And my linker flags would be automatically updated to link SDL.
Additionally, my project would be a single folder, and any *.cpp files
I had inside or in subfolders would just get compiled when I typed
"make," without me having to write any sort of "Makefile" whatsoever.
I don't need anymore flexibility in my build system. I just want
linker flags to be inferred and for my makefile to automatically
update for new files, without having to commit to a bloated IDE (I
like emacs).

Are there any tools like this?

What you can do, at least for the cpp-stuff, is to direct your Makefile
to use *any* cpp files inside your source-tree:

CPPs = $(shell find . -name \*.cpp)

Yours,
Daniel
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

What you can do, at least for the cpp-stuff, is to direct your Makefile
to use *any* cpp files inside your source-tree:

CPPs = $(shell find . -name \*.cpp)

For smaller projects a makefile might not even be necessary, just doing
'g++ -o myapp *.cpp' might work. And as others have pointed out, if you
use an IDE there might be tools to automatically build the program for
you, either by generating a makefile or by not using one at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,293
Messages
2,571,505
Members
48,192
Latest member
LinwoodFol

Latest Threads

Top