Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #103352 > unrolled thread
| Started by | Alla _ <modelling.data@gmail.com> |
|---|---|
| First post | 2017-02-07 06:10 -0800 |
| Last post | 2017-02-07 19:02 +0100 |
| Articles | 20 on this page of 80 — 18 participants |
Back to article view | Back to comp.lang.c
How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 06:10 -0800
Re: How to compile several C files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-02-07 07:02 -0800
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-07 16:03 +0100
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-07 15:06 +0000
Re: How to compile several C files BartC <bc@freeuk.com> - 2017-02-07 15:14 +0000
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-07 16:02 +0000
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 15:42 +0000
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-07 16:19 +0000
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 16:40 +0000
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-07 17:16 +0000
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 10:19 +0100
Re: How to compile several C files "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-07 11:51 -0500
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 08:26 -0800
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 16:42 +0000
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 10:14 -0800
Re: How to compile several C files vitale.alla@gmail.com - 2017-02-16 09:49 -0800
Re: How to compile several C files Ian Collins <ian-news@hotmail.com> - 2017-02-08 17:35 +1300
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 10:28 +0100
Re: How to compile several C files Ian Collins <ian-news@hotmail.com> - 2017-02-08 22:43 +1300
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 11:29 +0100
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 10:14 +0100
Re: How to compile several C files James Kuyper <jameskuyper@verizon.net> - 2017-02-07 10:07 -0500
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 07:56 -0800
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 08:24 -0800
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-07 16:44 +0000
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 08:54 -0800
Re: How to compile several C files "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-07 12:20 -0500
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 10:05 -0800
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 18:27 +0000
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 18:40 +0000
Re: How to compile several C files Keith Thompson <kst-u@mib.org> - 2017-02-07 12:22 -0800
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 10:33 +0100
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-08 10:25 -0800
Re: How to compile several C files Keith Thompson <kst-u@mib.org> - 2017-02-07 08:58 -0800
Re: How to compile several C files "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-07 12:07 -0500
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 09:14 -0800
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 17:21 +0000
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 10:14 -0800
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 10:28 -0800
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 18:43 +0000
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 10:55 -0800
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-07 19:28 +0000
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-07 19:51 +0000
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 11:25 +0100
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-08 12:11 +0000
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 14:58 +0100
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-08 14:23 +0000
Re: How to compile several C files supercat@casperkitty.com - 2017-02-08 07:48 -0800
Re: How to compile several C files Richard Heathfield <rjh@cpax.org.uk> - 2017-02-08 16:09 +0000
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 17:23 +0100
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 15:01 +0000
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 17:22 +0100
Re: How to compile several C files Keith Thompson <kst-u@mib.org> - 2017-02-08 09:27 -0800
Re: How to compile several C files supercat@casperkitty.com - 2017-02-08 09:51 -0800
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 21:06 +0000
Re: How to compile several C files supercat@casperkitty.com - 2017-02-08 13:20 -0800
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 21:40 +0000
Re: How to compile several C files supercat@casperkitty.com - 2017-02-08 13:49 -0800
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 23:09 +0000
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 23:25 +0100
Re: How to compile several C files supercat@casperkitty.com - 2017-02-08 15:17 -0800
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-09 01:17 +0100
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 23:19 +0100
Re: How to compile several C files Keith Thompson <kst-u@mib.org> - 2017-02-08 16:44 -0800
Re: How to compile several C files Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-08 22:32 -0800
Re: How to compile several C files Robert Wessel <robertwessel2@yahoo.com> - 2017-02-09 04:03 -0600
Re: How to compile several C files Ian Collins <ian-news@hotmail.com> - 2017-02-10 07:52 +1300
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 12:12 +0000
Re: How to compile several C files BartC <bc@freeuk.com> - 2017-02-08 13:09 +0000
Re: How to compile several C files Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-02-08 05:14 -0800
Re: How to compile several C files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-08 15:32 +0000
Re: How to compile several C files David Brown <david.brown@hesbynett.no> - 2017-02-08 15:09 +0100
Re: How to compile several C files Keith Thompson <kst-u@mib.org> - 2017-02-07 09:22 -0800
Re: How to compile several C files Gareth Owen <gwowen@gmail.com> - 2017-02-07 18:29 +0000
Re: How to compile several C files bart4858@gmail.com - 2017-02-07 11:05 -0800
Re: How to compile several C files Keith Thompson <kst-u@mib.org> - 2017-02-07 12:26 -0800
Re: How to compile several C files Barry Schwarz <schwarzb@dqel.com> - 2017-02-07 08:34 -0800
Re: How to compile several C files Alla _ <modelling.data@gmail.com> - 2017-02-07 08:57 -0800
Re: How to compile several C files "James R. Kuyper" <jameskuyper@verizon.net> - 2017-02-07 12:29 -0500
Re: How to compile several C files Manfred <noname@invalid.add> - 2017-02-07 19:02 +0100
Page 1 of 4 [1] 2 3 4 Next page →
| From | Alla _ <modelling.data@gmail.com> |
|---|---|
| Date | 2017-02-07 06:10 -0800 |
| Subject | How to compile several C files |
| Message-ID | <ddcc4bba-8f05-4537-9deb-1d5c759602f5@googlegroups.com> |
Hello! I have a program, which I would like to separate into two C files, and two .h files. The non-separated version works, but it would be logically correct to separate it into two parts. Actually, I already have done so. When I tried to compile two parts, I got a cryptic message saying that there were some duplicates. Before digging deeper into that error message, I would like to found out if I correctly compile both files, and what are the rules. First file is named proforma.c; second one sql.c : (Richard, if you see this message, I have mysql table :D It looks so good :) Happy as a kid, although, of course, the code has to be reworked a lot, because it doesn't look good; also I do have a few things I have to work on and to change, and the more I look at it, the more I find; I hope to do all this later, when I am better at coding. But! I do have a table :)))))) ) (1) I include both header files in proforma.c and in sql.c (2) run in Terminal: gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags --libs` proforma.c sql.c -o Honestly, I have only once compiled two files, and have completely forgotten the process. Thank you very much!
[toc] | [next] | [standalone]
| From | Malcolm McLean <malcolm.mclean5@btinternet.com> |
|---|---|
| Date | 2017-02-07 07:02 -0800 |
| Message-ID | <4ae1c782-5bc5-4066-9b7b-110689c2c8d4@googlegroups.com> |
| In reply to | #103352 |
On Tuesday, February 7, 2017 at 2:10:50 PM UTC, Alla _ wrote: > > gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags --libs` proforma.c sql.c -o > > Honestly, I have only once compiled two files, and have completely > forgotten the process. > gcc *.c -lm ./a.out (I did have a policy of insisting that Baby X programs would compile with this command, unfortunately I had to break it).
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2017-02-07 16:03 +0100 |
| Message-ID | <o7cngv$ebp$1@dont-email.me> |
| In reply to | #103352 |
On 07/02/17 15:10, Alla _ wrote: > Hello! > > I have a program, which I would like to separate into two C files, > and two .h files. The non-separated version works, but it would > be logically correct to separate it into two parts. > Actually, I already have done so. When I tried to > compile two parts, I got a cryptic message saying that there were > some duplicates. Before digging deeper into that error message, > I would like to found out if I correctly compile both files, and what > are the rules. > First file is named proforma.c; second one sql.c : > > (Richard, if you see this message, I have mysql table :D It looks so > good :) Happy as a kid, although, of course, the code has to be > reworked a lot, because it doesn't look good; also I do have a > few things I have to work on and to change, and the more I look > at it, the more I find; I hope to do all this later, when I am better > at coding. But! I do have a table :)))))) ) > > (1) I include both header files in proforma.c and in sql.c > (2) run in Terminal: > gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags --libs` proforma.c sql.c -o > > Honestly, I have only once compiled two files, and have completely > forgotten the process. > > Thank you very much! > First, try with two /very/ simple files, with just one short function in each. Then you will be able to post the files, the command line, and the exact error message. Secondly, it looks like you have omitted part of the command line. "-o" needs to be followed by the name you want for your executable file.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-02-07 15:06 +0000 |
| Message-ID | <87a89yca76.fsf@bsb.me.uk> |
| In reply to | #103352 |
Alla _ <modelling.data@gmail.com> writes: > I have a program, which I would like to separate into two C files, > and two .h files. <snip> > (1) I include both header files in proforma.c and in sql.c That's a little odd. If they both the both .h files, why not use just one? The most common pattern in simple programs is that sql.c would need sql.h and the main program would need sql.h. It might also use its own, particularly if it is going to be part of a bigger program. Of course all such rule have exceptions so it's impossible to say without details. > (2) run in Terminal: > gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags --libs` > proforma.c sql.c -o You need a name after -o and you will usually have to put the libraries at the end: gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags` proforma.c \ sql.c `mysql_config --libs` -o program but even more usual is to compile separately and link. Most likely: gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags` -c sql.c gcc -Wall -Werror -Wextra -std=c99 -c proforma.c gcc -o program proforma.o sql.o `mysql_config --libs` but again, subject to details. Once I have two files, I write a makefile. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | BartC <bc@freeuk.com> |
|---|---|
| Date | 2017-02-07 15:14 +0000 |
| Message-ID | <o7co4o$h9u$1@dont-email.me> |
| In reply to | #103359 |
On 07/02/2017 15:06, Ben Bacarisse wrote: > Alla _ <modelling.data@gmail.com> writes: > >> I have a program, which I would like to separate into two C files, >> and two .h files. > <snip> >> (1) I include both header files in proforma.c and in sql.c > > That's a little odd. If they both the both .h files, why not use just > one? The most common pattern in simple programs is that sql.c would > need sql.h and the main program would need sql.h. It might also use its > own, particularly if it is going to be part of a bigger program. Of > course all such rule have exceptions so it's impossible to say without > details. > >> (2) run in Terminal: >> gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags --libs` >> proforma.c sql.c -o > > You need a name after -o and you will usually have to put the libraries > at the end: > > gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags` proforma.c \ > sql.c `mysql_config --libs` -o program > > but even more usual is to compile separately and link. Most likely: > > gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags` -c sql.c > gcc -Wall -Werror -Wextra -std=c99 -c proforma.c > gcc -o program proforma.o sql.o `mysql_config --libs` > > but again, subject to details. Once I have two files, I write a > makefile. You don't need to go that far. A very simple alternative is a file 'project' containing: -Wall # etc, usual set of options -o program file1.c file2.c then type gcc @project This will always compile all sources, but apparently gcc is so blindingly fast on anything that isn't Windows, that it shouldn't matter. It will anyway be faster than trying to learn about makefiles. -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-02-07 16:02 +0000 |
| Message-ID | <8737fqc7ku.fsf@bsb.me.uk> |
| In reply to | #103362 |
BartC <bc@freeuk.com> writes: > On 07/02/2017 15:06, Ben Bacarisse wrote: >> Alla _ <modelling.data@gmail.com> writes: >> >>> I have a program, which I would like to separate into two C files, >>> and two .h files. >> <snip> >>> (1) I include both header files in proforma.c and in sql.c >> >> That's a little odd. If they both the both .h files, why not use just >> one? The most common pattern in simple programs is that sql.c would >> need sql.h and the main program would need sql.h. It might also use its >> own, particularly if it is going to be part of a bigger program. Of >> course all such rule have exceptions so it's impossible to say without >> details. >> >>> (2) run in Terminal: >>> gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags --libs` >>> proforma.c sql.c -o >> >> You need a name after -o and you will usually have to put the libraries >> at the end: >> >> gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags` proforma.c \ >> sql.c `mysql_config --libs` -o program >> >> but even more usual is to compile separately and link. Most likely: >> >> gcc -Wall -Werror -Wextra -std=c99 `mysql_config --cflags` -c sql.c >> gcc -Wall -Werror -Wextra -std=c99 -c proforma.c >> gcc -o program proforma.o sql.o `mysql_config --libs` >> >> but again, subject to details. Once I have two files, I write a >> makefile. > > You don't need to go that far. A very simple alternative is a file > 'project' containing: > > -Wall # etc, usual set of options > -o program > file1.c > file2.c > > then type gcc @project The OP has flags derived from a command. They don't work in an @file argument to gcc. > This will always compile all sources, Yes. On *nix type systems, if compiling everything is OK and a makefile is "going too far", it's better just to put the command into a file and "source" it. I.e. put either the one long command or the three shorter ones into a file and use . ./file (You can even make it executable and just run it, but one step at a time.) <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-02-07 15:42 +0000 |
| Message-ID | <o7cpp9$o2l$1@dont-email.me> |
| In reply to | #103359 |
On 07/02/17 15:06, Ben Bacarisse wrote: > Once I have two files, I write a makefile. I'm slightly lazier than that. Once I have /one/ file, I write a makefile. To be more precise, I'm even lazier than /that/ - I run a program to write the makefile on my behalf: makegen foo > Makefile which generates a simple makefile for turning foo.c into foo (the executable file). (If I were lazier still, I would rewrite makegen to write everything to Makefile by default.) And before anyone asks, yes, I can feed multiple files to it (the first is taken as the executable output filename); yes, I can feed extra flags to it via -e=whatever; and yes, I can tell it about libraries using -lwhatever. I'm not saying it generates a /great/ makefile. But it does all that I require of it. -- Richard Heathfield Email: rjh at cpax dot org dot uk "Usenet is a strange place" - dmr 29 July 1999 Sig line 4 vacant - apply within
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-02-07 16:19 +0000 |
| Message-ID | <87wpd2as85.fsf@bsb.me.uk> |
| In reply to | #103369 |
Richard Heathfield <rjh@cpax.org.uk> writes:
> On 07/02/17 15:06, Ben Bacarisse wrote:
>> Once I have two files, I write a makefile.
>
> I'm slightly lazier than that. Once I have /one/ file, I write a
> makefile.
At a pinch, you can be even lazier when there is only one file because
you might be able to get away with no makefile at all because, in an
otherwise empty directory, "make x" will compile and link x.c (if it
exists).
For me, the next stage is to put (for example)
CFLAGS=-std=c99 -Wall -pedantic
into "makefile" and nothing else. That lets you "make x" and/or "make
x.o" with the right flags for any C files you have in that directory
(for different "x" of course). A very simple solution for quick
one-file tests.
> To be more precise, I'm even lazier than /that/ - I run a program to
> write the makefile on my behalf:
>
> makegen foo > Makefile
Since that is (I think) your own program, it is probably more helpful to
know about "gcc -MM *.c". This will write out the dependencies between
files.
To finish off a simple (GNU) makefile it helps to know one magic rule:
program: one.o two.o other.o
gcc -o $@ $^
where $@ means the target ("program") and $^ means the dependencies
("one.o two.o three.o"). You can write it out of course, but knowing $@
and $^ makes it the same rule every time.
<snip>
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-02-07 16:40 +0000 |
| Message-ID | <o7ct7f$7fk$1@dont-email.me> |
| In reply to | #103373 |
On 07/02/17 16:19, Ben Bacarisse wrote:
> Richard Heathfield <rjh@cpax.org.uk> writes:
>
>> On 07/02/17 15:06, Ben Bacarisse wrote:
>>> Once I have two files, I write a makefile.
>>
>> I'm slightly lazier than that. Once I have /one/ file, I write a
>> makefile.
>
> At a pinch, you can be even lazier when there is only one file because
> you might be able to get away with no makefile at all because, in an
> otherwise empty directory, "make x" will compile and link x.c (if it
> exists).
True, but makegen puts in all my favourite flags, so it does save me
some typing (and some remembering).
<snip>
> know about "gcc -MM *.c". This will write out the dependencies between
> files.
Thank you - I was unaware of that.
> To finish off a simple (GNU) makefile it helps to know one magic rule:
>
> program: one.o two.o other.o
> gcc -o $@ $^
>
> where $@ means the target ("program") and $^ means the dependencies
> ("one.o two.o three.o"). You can write it out of course, but knowing $@
> and $^ makes it the same rule every time.
Yep. I used to use that rule, but I could never remember it. I had to
keep looking it up, and in the end I chucked it in as a bad job. People
have curious blind spots, do they not?
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2017-02-07 17:16 +0000 |
| Message-ID | <87fujpc46k.fsf@bsb.me.uk> |
| In reply to | #103378 |
Richard Heathfield <rjh@cpax.org.uk> writes:
> On 07/02/17 16:19, Ben Bacarisse wrote:
<snip>
>> To finish off a simple (GNU) makefile it helps to know one magic rule:
>>
>> program: one.o two.o other.o
>> gcc -o $@ $^
>>
>> where $@ means the target ("program") and $^ means the dependencies
>> ("one.o two.o three.o"). You can write it out of course, but knowing $@
>> and $^ makes it the same rule every time.
>
> Yep. I used to use that rule, but I could never remember it. I had to
> keep looking it up, and in the end I chucked it in as a bad
> job. People have curious blind spots, do they not?
Yes, I find most of make's automatic variables totally unmemorable
(including those). I forced myself to learn those two (because they are
so useful) by inventing mnemonic meanings: the ^ points at what is means
and "at" refers to a place -- the place you writing the output. (It
worked for me is all I can say.)
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2017-02-08 10:19 +0100 |
| Message-ID | <o7enn8$leo$1@dont-email.me> |
| In reply to | #103388 |
On 07/02/17 18:16, Ben Bacarisse wrote:
> Richard Heathfield <rjh@cpax.org.uk> writes:
>
>> On 07/02/17 16:19, Ben Bacarisse wrote:
> <snip>
>>> To finish off a simple (GNU) makefile it helps to know one magic rule:
>>>
>>> program: one.o two.o other.o
>>> gcc -o $@ $^
>>>
>>> where $@ means the target ("program") and $^ means the dependencies
>>> ("one.o two.o three.o"). You can write it out of course, but knowing $@
>>> and $^ makes it the same rule every time.
>>
>> Yep. I used to use that rule, but I could never remember it. I had to
>> keep looking it up, and in the end I chucked it in as a bad
>> job. People have curious blind spots, do they not?
>
> Yes, I find most of make's automatic variables totally unmemorable
> (including those). I forced myself to learn those two (because they are
> so useful) by inventing mnemonic meanings: the ^ points at what is means
> and "at" refers to a place -- the place you writing the output. (It
> worked for me is all I can say.)
>
Much of make's syntax is unmemorable, IMHO. Getting a complex makefile
right with macros, sub-makes, etc., is not an easy job - debugging can
be a real pain. But once you have a good, general makefile, it can be
used again with just minor tweaking. I can't remember the last time I
wrote a Makefile from scratch - probably more than a decade ago.
[toc] | [prev] | [next] | [standalone]
| From | "James R. Kuyper" <jameskuyper@verizon.net> |
|---|---|
| Date | 2017-02-07 11:51 -0500 |
| Message-ID | <1b4c2de1-ef18-92e0-fc0c-2b01019465d2@verizon.net> |
| In reply to | #103373 |
On 02/07/2017 11:19 AM, Ben Bacarisse wrote: ... > For me, the next stage is to put (for example) > > CFLAGS=-std=c99 -Wall -pedantic > > into "makefile" and nothing else. On a unix-like system, you can achieve the same effect by setting the environment variable named "CFLAGS" to that value. make initializes it's own variable named CFLAGS, using the current value of that environment variable.
[toc] | [prev] | [next] | [standalone]
| From | Alla _ <modelling.data@gmail.com> |
|---|---|
| Date | 2017-02-07 08:26 -0800 |
| Message-ID | <6b3761ea-0c13-4b36-8b52-bf3f746d3c49@googlegroups.com> |
| In reply to | #103369 |
On Tuesday, February 7, 2017 at 6:42:22 PM UTC+3, Richard Heathfield wrote: > On 07/02/17 15:06, Ben Bacarisse wrote: > > Once I have two files, I write a makefile. > > I'm slightly lazier than that. Once I have /one/ file, I write a makefile. > > To be more precise, I'm even lazier than /that/ - I run a program to > write the makefile on my behalf: > > makegen foo > Makefile > > which generates a simple makefile for turning foo.c into foo (the > executable file). > > (If I were lazier still, I would rewrite makegen to write everything to > Makefile by default.) > > And before anyone asks, yes, I can feed multiple files to it (the first > is taken as the executable output filename); yes, I can feed extra flags > to it via -e=whatever; and yes, I can tell it about libraries using > -lwhatever. > > I'm not saying it generates a /great/ makefile. But it does all that I > require of it. > Will you teach me how to do that? Not now. Please, not now.
[toc] | [prev] | [next] | [standalone]
| From | Richard Heathfield <rjh@cpax.org.uk> |
|---|---|
| Date | 2017-02-07 16:42 +0000 |
| Message-ID | <o7ct9o$7fk$2@dont-email.me> |
| In reply to | #103375 |
On 07/02/17 16:26, Alla _ wrote: > On Tuesday, February 7, 2017 at 6:42:22 PM UTC+3, Richard Heathfield wrote: <snip> >> I'm not saying it generates a /great/ makefile. But it does all that I >> require of it. >> > Will you teach me how to do that? Not now. Please, not now. It's not hard. But yes. Just yell when you're ready. -- Richard Heathfield Email: rjh at cpax dot org dot uk "Usenet is a strange place" - dmr 29 July 1999 Sig line 4 vacant - apply within
[toc] | [prev] | [next] | [standalone]
| From | Alla _ <modelling.data@gmail.com> |
|---|---|
| Date | 2017-02-07 10:14 -0800 |
| Message-ID | <c2a51790-1687-41d2-a532-6ba1ad2d9c03@googlegroups.com> |
| In reply to | #103379 |
On Tuesday, February 7, 2017 at 7:42:18 PM UTC+3, Richard Heathfield wrote: > On 07/02/17 16:26, Alla _ wrote: > > On Tuesday, February 7, 2017 at 6:42:22 PM UTC+3, Richard Heathfield wrote: > > <snip> > > >> I'm not saying it generates a /great/ makefile. But it does all that I > >> require of it. > >> > > Will you teach me how to do that? Not now. Please, not now. > > It's not hard. But yes. Just yell when you're ready. Will do that vociferously )
[toc] | [prev] | [next] | [standalone]
| From | vitale.alla@gmail.com |
|---|---|
| Date | 2017-02-16 09:49 -0800 |
| Message-ID | <1db81925-c22c-4151-9207-ba1ff564b090@googlegroups.com> |
| In reply to | #103379 |
On Tuesday, February 7, 2017 at 7:42:18 PM UTC+3, Richard Heathfield wrote: > On 07/02/17 16:26, Alla _ wrote: > > On Tuesday, February 7, 2017 at 6:42:22 PM UTC+3, Richard Heathfield wrote: > > <snip> > > >> I'm not saying it generates a /great/ makefile. But it does all that I > >> require of it. > >> > > Will you teach me how to do that? Not now. Please, not now. > > It's not hard. But yes. Just yell when you're ready. Richard, will you, please? :) When it is convenient for you.
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2017-02-08 17:35 +1300 |
| Message-ID | <efvlh7F1d9uU7@mid.individual.net> |
| In reply to | #103369 |
On 02/ 8/17 04:42 AM, Richard Heathfield wrote: > On 07/02/17 15:06, Ben Bacarisse wrote: >> Once I have two files, I write a makefile. > > I'm slightly lazier than that. Once I have /one/ file, I write a makefile. I'm lazier still so I get my IDE to generate a makefile :) -- Ian
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2017-02-08 10:28 +0100 |
| Message-ID | <o7eo89$n1a$1@dont-email.me> |
| In reply to | #103429 |
On 08/02/17 05:35, Ian Collins wrote: > On 02/ 8/17 04:42 AM, Richard Heathfield wrote: >> On 07/02/17 15:06, Ben Bacarisse wrote: >>> Once I have two files, I write a makefile. >> >> I'm slightly lazier than that. Once I have /one/ file, I write a >> makefile. > > I'm lazier still so I get my IDE to generate a makefile :) > My experience is that IDE's are really slow at making their makefiles. If you've got an Eclipse project with a few directories and a bunch of C, C++ and H files in them, then doing a "rebuild" after changing a header file means Eclipse will first grind through all the C and C++ files doing (approximately) "gcc -MM" to figure out the dependencies to generate the makefile. Then it will do the full compilation on the files that actually need to be re-compiled. And while "gcc -MM" is a good deal faster than a normal compile, it adds up when the IDE does it for /all/ the project files. My makefile generates the dependency files when it needs to - and re-generates them when it needs to. So for quick re-builds after small changes, it is much faster than Eclipse's built-in project management. My brief experience with MSVS was no better here. But perhaps netbeans or other IDEs are not as inefficient as Eclipse in this regard. I also prefer a proper makefile because it is then independent from the IDE. If I need to re-open an old project (and my record is close to 20 years old) I have the compiler at hand, but I really hate having to install some ancient IDE just to do the build. It is also far easier to make a fix via ssh from a mobile phone when building is done my "make" and not "Tools | Build" in an IDE!
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2017-02-08 22:43 +1300 |
| Message-ID | <eg07h4F1d9uU8@mid.individual.net> |
| In reply to | #103437 |
On 02/ 8/17 10:28 PM, David Brown wrote: > On 08/02/17 05:35, Ian Collins wrote: >> On 02/ 8/17 04:42 AM, Richard Heathfield wrote: >>> On 07/02/17 15:06, Ben Bacarisse wrote: >>>> Once I have two files, I write a makefile. >>> >>> I'm slightly lazier than that. Once I have /one/ file, I write a >>> makefile. >> >> I'm lazier still so I get my IDE to generate a makefile :) >> > > My experience is that IDE's are really slow at making their makefiles. > If you've got an Eclipse project with a few directories and a bunch of > C, C++ and H files in them, then doing a "rebuild" after changing a > header file means Eclipse will first grind through all the C and C++ > files doing (approximately) "gcc -MM" to figure out the dependencies to > generate the makefile. Then it will do the full compilation on the > files that actually need to be re-compiled. And while "gcc -MM" is a > good deal faster than a normal compile, it adds up when the IDE does it > for /all/ the project files. One reason I prefer NetBeans to Eclipse! It generates nice, simple makefiles without any fuss. > My makefile generates the dependency files when it needs to - and > re-generates them when it needs to. So for quick re-builds after small > changes, it is much faster than Eclipse's built-in project management. As do NetBeans makefiles. > My brief experience with MSVS was no better here. But perhaps netbeans > or other IDEs are not as inefficient as Eclipse in this regard. Yep. > I also prefer a proper makefile because it is then independent from the > IDE. If I need to re-open an old project (and my record is close to 20 > years old) I have the compiler at hand, but I really hate having to > install some ancient IDE just to do the build. It is also far easier to > make a fix via ssh from a mobile phone when building is done my "make" > and not "Tools | Build" in an IDE! With NetBeans, you can do just that. -- Ian
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2017-02-08 11:29 +0100 |
| Message-ID | <o7errf$2i6$1@dont-email.me> |
| In reply to | #103439 |
On 08/02/17 10:43, Ian Collins wrote: > On 02/ 8/17 10:28 PM, David Brown wrote: >> On 08/02/17 05:35, Ian Collins wrote: >>> On 02/ 8/17 04:42 AM, Richard Heathfield wrote: >>>> On 07/02/17 15:06, Ben Bacarisse wrote: >>>>> Once I have two files, I write a makefile. >>>> >>>> I'm slightly lazier than that. Once I have /one/ file, I write a >>>> makefile. >>> >>> I'm lazier still so I get my IDE to generate a makefile :) >>> >> >> My experience is that IDE's are really slow at making their makefiles. >> If you've got an Eclipse project with a few directories and a bunch of >> C, C++ and H files in them, then doing a "rebuild" after changing a >> header file means Eclipse will first grind through all the C and C++ >> files doing (approximately) "gcc -MM" to figure out the dependencies to >> generate the makefile. Then it will do the full compilation on the >> files that actually need to be re-compiled. And while "gcc -MM" is a >> good deal faster than a normal compile, it adds up when the IDE does it >> for /all/ the project files. > > One reason I prefer NetBeans to Eclipse! It generates nice, simple > makefiles without any fuss. > >> My makefile generates the dependency files when it needs to - and >> re-generates them when it needs to. So for quick re-builds after small >> changes, it is much faster than Eclipse's built-in project management. > > As do NetBeans makefiles. > >> My brief experience with MSVS was no better here. But perhaps netbeans >> or other IDEs are not as inefficient as Eclipse in this regard. > > Yep. > >> I also prefer a proper makefile because it is then independent from the >> IDE. If I need to re-open an old project (and my record is close to 20 >> years old) I have the compiler at hand, but I really hate having to >> install some ancient IDE just to do the build. It is also far easier to >> make a fix via ssh from a mobile phone when building is done my "make" >> and not "Tools | Build" in an IDE! > > With NetBeans, you can do just that. > I will maybe try it sometime. The advantage of Eclipse for me is that every microcontroller vendor uses Eclipse except Atmel AVR (which is MSVS based) and Microchip (which use NetBeans). So when I want the vendor's debugger support, register viewing, and other goodies, it is all Eclipse. (I wonder if Microchip will redo AVR Studio as NetBeans now that they own Atmel? That would be nice - anything is better than a Windows-only solution.)
[toc] | [prev] | [next] | [standalone]
Page 1 of 4 [1] 2 3 4 Next page →
Back to top | Article view | comp.lang.c
csiph-web