LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Very novice question (https://www.linuxquestions.org/questions/programming-9/very-novice-question-413136/)

BobNutfield 02-08-2006 03:09 PM

Very novice question
 
Hi everyone

I am in the very beginnings of teaching myself to program in C++. I have tried to use a graphical editor/compilor called Geanie. When I compile my practice programs everythings seems to go fine. However, when I attempt to build with "make" I get an error:

error: no target for "make all" unsuccessful build

I know to most of you this is an irratatingly simple question, but as I am trying to do this simply from books, these little nagging things hold me back. Would someone be kind enough to explain this error to me and tell me how to avoid it and build the practice programs so that they are executable?

Any help appreciated.

Bob

rshaw 02-08-2006 03:24 PM

you don't really need 'make' to run them locally. do they run as ./yourfilename from the terminal?

BobNutfield 02-08-2006 03:30 PM

Yes, they do. I am able to output the practice programs fine. I suppose I am trying to learn to use the graphical compilers (like KDevelop) as well as the language itself. I also want to be able to run them by just typing in the filename without ./myfile. I was able to do this once in Eclipse, but can't really remember how I did it.

Thank you for your response. Any extra help from experienced programers is appreciated.

Bob

Mara 02-08-2006 04:24 PM

An error line
Code:

error: no target for "make all" unsuccessful build
can have many reasons. It'd be a good idea to look into the Makefile. My guess is that it was generated to run the normal build not by using simple 'make', but make with a parameter.

bigearsbilly 02-09-2006 03:29 AM

if you have a simple C/C++ program,
e.g: "hello.c"

simply typing make hello will compile and link as you would expect.

When you are making, I take it it's in a GUI. Obviously this is simply
calling make all and expecting a makefile.

Here's a simple makefile that should work for you. (assuming you have makedepend installed)
Put it in the project directory and call it "Makefile".

If you cut and paste and the makefile has errors, it may be because the indented lines
MUST be indented with TAB characters. This is essential.

Code:

# ---------------------------------
# Standard makefile for standalone
# C files (not multifile projects)
# e.g. makes 'func.c' with:
#
#  cc -c func.c -o func.o
#  cc    func.o -o func
#
#  end up with 'func'
#               
#
# using the built-in rules for
# simple single source programs
#
#      recursive make, creates the includes first
#      then does the targets
#
#      first call cannot find the include files
#      so they are made as targets, then all
#      target invokes make again
# --------------------------

INCLUDEFILE=files.mk
DEPENDFILE=depend.mk
TARGETS=$(CFILES:.c=)

all:
 $(MAKE) $(TARGETS)
 rm $(INCLUDEFILE)
 rm $(DEPENDFILE)


$(DEPENDFILE):
 touch $@
 makedepend -f $@ *.c

$(INCLUDEFILE):
 echo CFILES = *.c > $@

include $(INCLUDEFILE)
include $(DEPENDFILE)


BobNutfield 02-09-2006 03:40 PM

Thank you very much for the help...I have copied this and made note of your instructions. I need more study to properly use this information, but you have helped a lot. Learning this on my own with no classroom or instructor training is a little more difficult than I thought.

Thanks again

Bob

xhi 02-09-2006 10:07 PM

look in the build menu and try the option 'run automake and friends' and see if you can build after that..

bigearsbilly 02-10-2006 02:59 AM

no probs bob.
it's not difficult, there's just a lot to learn and you can only
assimilate at a certain rate. You'll get there, just be patient!

make is a particularly arcane tool. very useful and powerful but also
incredibly, infuriatingly, confusingly annoying at times.
It took me quite a while to get my head round it.


All times are GMT -5. The time now is 10:32 AM.