[opensuse] need help with simple Makefile - no rule to make target (huh?)
Guys, For the little programming I do, I always just type the gcc command for each file. But... I've got a project that was growing and it uses gsl for some file and not for others so I thought I would experiment with a basic Makefile. I'm talking *simple*. However, on my first go, I'm getting that darn: make: *** No rule to make target `tst_isolv.c', needed by `tst_isolv.o'. Stop. error. The 2 object makefile I'm experimenting with is: CC = gcc CFLAGS = -Wall -lm -lgsl -lgslcblas OBJECTS = isolv_state.o tst_isolv.o tstim : $(OBJECTS) $(CC) -o tstim $(OBJECTS) $(CFLAGS) isolv_state.o : isolv_state.c isolv_state.h $(CC) -c isolv_state.c tst_isolv.o : tst_isolv.c isolv_state.h $(CC) -c tst_isolv.c clean: rm -f tstim isolv_state.o tst_isolv.o All the files are in the current directory and yes the recipes are preceded by 'tab' characters: 22:50 alchemy:~/dev/prg/ccpp/lib/gsl> ls -1 isolv_state.c isolv_state.h isolv_state.o Makefile tst-isolv.c tst-isolv.o Running make gives: 22:54 alchemy:~/dev/prg/ccpp/lib/gsl> make make: *** No rule to make target `tst_isolv.c', needed by `tst_isolv.o'. Stop. Huh? Why is it looking for a target to make tst_isolv.c'? Why doesn't it just do what I told it to and use 'gcc -c tst_isolv.c'? I know the issue is some 'forest for the trees' thing that I'm completely missing... So help a brother out -- what's the trick? -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 2010-11-01 at 23:04 -0500, David C. Rankin wrote:
tst_isolv.o : tst_isolv.c isolv_state.h $(CC) -c tst_isolv.c
I'm late for bed and too sleepy, I can easily be wrong. After a quick compare with one simple makefile of mine, I think you have an unneeded space before the colon... Dunno. :-?
Huh? Why is it looking for a target to make tst_isolv.c'? Why doesn't it just do what I told it to and use 'gcc -c tst_isolv.c'?
I saw that error in my first makefiles, too, years ago, but I don't remember why it was. If it is as simple as the space... tell me :-) - -- Cheers, Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) iEYEARECAAYFAkzPj+MACgkQtTMYHG2NR9WMfgCgivJRzlQ8GhAy7IiCh0knG/1q 6yIAni/xqNSmuQmvmwNZ4q4tqF/j7f4u =nonN -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 11/01/2010 11:13 PM, Carlos E. R. wrote:
On Monday, 2010-11-01 at 23:04 -0500, David C. Rankin wrote:
tst_isolv.o : tst_isolv.c isolv_state.h $(CC) -c tst_isolv.c
I'm late for bed and too sleepy, I can easily be wrong. After a quick compare with one simple makefile of mine, I think you have an unneeded space before the colon... Dunno. :-?
Huh? Why is it looking for a target to make tst_isolv.c'? Why doesn't it just do what I told it to and use 'gcc -c tst_isolv.c'?
I saw that error in my first makefiles, too, years ago, but I don't remember why it was. If it is as simple as the space... tell me :-)
-- Cheers, Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar)
Ah... you be sleepy my friend :p http://www.gnu.org/software/make/manual/make.html#Simple-Makefile Unless the GNU make manual is wrong, the extra space is fine. I removed the additional space before the colon anyway - no change. Go get some rest. This will certainly wait until Carlos is well rested :-) -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday 02 November 2010 05:35:54 David C. Rankin wrote:
On 11/01/2010 11:13 PM, Carlos E. R. wrote:
On Monday, 2010-11-01 at 23:04 -0500, David C. Rankin wrote:
tst_isolv.o : tst_isolv.c isolv_state.h
$(CC) -c tst_isolv.c
I'm late for bed and too sleepy, I can easily be wrong. After a quick compare with one simple makefile of mine, I think you have an unneeded space before the colon... Dunno. :-?
Huh? Why is it looking for a target to make tst_isolv.c'? Why doesn't it
just do what I told it to and use 'gcc -c tst_isolv.c'?
I saw that error in my first makefiles, too, years ago, but I don't remember why it was. If it is as simple as the space... tell me :-)
-- Cheers,
Carlos E. R. (from 11.2 x86_64 "Emerald" at Telcontar)
Ah... you be sleepy my friend :p
http://www.gnu.org/software/make/manual/make.html#Simple-Makefile
Unless the GNU make manual is wrong, the extra space is fine. I removed the additional space before the colon anyway - no change. Go get some rest. This will certainly wait until Carlos is well rested :-)
Hi David, Please, check the file names: tst_isolv.c versus tst-isolv.c Regards, Erwin -- Erwin Lam (erwinlam@dds.nl) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 11/01/2010 11:55 PM, Erwin Lam wrote:
Hi David,
Please, check the file names: tst_isolv.c versus tst-isolv.c
Regards, Erwin
Thanks Erwin, That's pretty much the kind of screw-up I'm capable of .. but all the underscores are consistent. It has to be something totally basic that I'm just missing or some caveat that I have run across in the make manual. With only 2 files involved and one header that is common between them -- it's hard to figure out what I've screwed up, but I'm sure when I find out, I'll be in for a good chuckle... -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 11/01/2010 11:55 PM, Erwin Lam wrote:
Hi David,
Please, check the file names: tst_isolv.c versus tst-isolv.c
Regards, Erwin
I knew it, I knew it! ... and I am in for a good chuckle. Thanks for helping me see the light :) -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 11/02/2010 12:03 AM, David C. Rankin wrote:
On 11/01/2010 11:55 PM, Erwin Lam wrote:
Hi David,
Please, check the file names: tst_isolv.c versus tst-isolv.c
Regards, Erwin
I knew it, I knew it! ... and I am in for a good chuckle. Thanks for helping me see the light :)
00:05 alchemy:~/dev/prg/ccpp/lib/gsl> make gcc -c tst_isolv.c gcc -o tstim isolv_state.o tst_isolv.o -Wall -lm -lgsl -lgslcblas 00:05 alchemy:~/dev/prg/ccpp/lib/gsl> ./tstim using brent method iter [ lower, upper] root err err(est) 1 [2.5375500, 6.2831853] 2.5375500 +0.3014820 3.7456353 2 [2.5375500, 2.5947800] 2.5947800 +0.3587120 0.0572300 3 [2.5899517, 2.5947800] 2.5899517 +0.3538838 0.0048283 4 [2.5899580, 2.5947800] 2.5899580 +0.3538900 0.0048220 5 [2.5899580, 2.5947800] 2.5899580 +0.3538900 0.0048220 Converged: 6 [2.5899580, 2.5899580] 2.5899580 +0.3538900 0.0000000 The Eccentric Anomaly for M=2.53755 and e=0.1 is: 2.5899580 success :p -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
El 02/11/10 02:07, David C. Rankin escribió:
On 11/02/2010 12:03 AM, David C. Rankin wrote:
On 11/01/2010 11:55 PM, Erwin Lam wrote:
Hi David,
Please, check the file names: tst_isolv.c versus tst-isolv.c
Regards, Erwin
I knew it, I knew it! ... and I am in for a good chuckle. Thanks for helping me see the light :)
00:05 alchemy:~/dev/prg/ccpp/lib/gsl> make gcc -c tst_isolv.c gcc -o tstim isolv_state.o tst_isolv.o -Wall -lm -lgsl -lgslcblas
You really want gcc -Wall $(rpm --eval %optflags) <objects> <libraries> -o <output> Do not include libs in CFLAGS. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 11/02/2010 11:37 AM, Cristian Rodríguez wrote:
Do not include libs in CFLAGS.
Oh no, I didn't want that, I just hadn't gotten to the part of the make manual that said don't do it yet :) DNH got me straightened out on that one. Thanks for your follow-up Christian. The first stumbling block I had to get over was -- learning how to spell :p -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hello, On Mon, 01 Nov 2010, David C. Rankin wrote: [..]
CC = gcc
ok.
CFLAGS = -Wall -lm -lgsl -lgslcblas
*blam* Don't put libs (i.e. -lfoo) into CFLAGS, use LIBS and/or LDFLAGS. CFLAGS := -O2 -Wall -W -Wno-unused LDFLAGS := -Wl,-as-needed LIBS := -lgslcblas -lgsl -lm (don't libs have to be named on a use-first-implementation-after basis? Anyway, with -as-needed, the linker (ld) _will_ tell you ;)
OBJECTS = isolv_state.o tst_isolv.o
ok.
tstim : $(OBJECTS) $(CC) -o tstim $(OBJECTS) $(CFLAGS)
isolv_state.o : isolv_state.c isolv_state.h $(CC) -c isolv_state.c
tst_isolv.o : tst_isolv.c isolv_state.h $(CC) -c tst_isolv.c
You should avoid such explicit rules. They're a pain to maintain! Either use the builtin rule (and add dependencies as needed), or spell the deps out. And/or define your custom "pattern" rule. ==== UNTESTED ==== CC := gcc CFLAGS := -O2 CFLAGS += -Wall -W -Wno-unused # [..] CCLD := $(CC) LDFLAGS := -Wl,-as-needed # ### debug linking process: # LDFLAGS += -Wl,-t LIBS := -lgslcblas -lgsl -lm # [..] tstim: $(OBJECTS) $(CCLD) $(LDFLAGS) -o $@ $^ $(LIBS) %.o: %.c: $(CC) $(CFLAGS) -o $@ $< isolv_state.o: isolv_state.h tst_isolv.o: isolv_state.h ==== Or something like that (as I don't know how gcc specific some of those options are, I use ":="). You could use "?=" or "=" to cater for other compilers, but you'd have to be sure about defaults you add to CFLAGS and LDFLAGS etc. pp. You might have to use :: instead of the simple : there. Or just generate the deps to those *.h files (gcc -M...). HTH, -dnh, with eyelids barely staying open ... but liking 'make' a lot for solving dependencies ;) -- The rest of the time you want to carefully slice open their scrotum, extract their testicles, still attached, dip them in egg batter, roll them in italian bread crumbs, and fry them with a little olive oil. Then you make the little bastard cut them off and eat 'em. -- random, in the Monastery -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 11/02/2010 01:17 AM, David Haller wrote:
HTH, -dnh, with eyelids barely staying open ... but liking 'make' a lot for solving dependencies ;)
It does -- a lot. Thankfully the linking didn't bite me here. Instead it was just a normal 'I-Dee-ten-T' error (or in all caps.... ID10T error). The LDFLAGS and LIBS didn't pop-up in the 'basic makefile howto', but I really like the 'as needed' option. As usual, you are light years ahead here, but I'll mess with the options and see if I can't add another tool or two to my toolbox :p Thanks David. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
* David C. Rankin (drankinatty@suddenlinkmail.com) [20101102 19:34]:
As usual, you are light years ahead here, but I'll mess with the options and see if I can't add another tool or two to my toolbox :p
Like using automake, autoconf and possibly libtool? :-) Philipp -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (6)
-
Carlos E. R.
-
Cristian Rodríguez
-
David C. Rankin
-
David Haller
-
Erwin Lam
-
Philipp Thomas