Gcc with pipe


 
Thread Tools Search this Thread
Top Forums Programming Gcc with pipe
# 1  
Old 01-05-2011
Gcc with pipe

I want to compile all files in my directory i wrote
find *.c | gcc -o * *.c
but it dosent work Smilie Help pliz
# 2  
Old 01-05-2011
Well, if every is a main:
Code:
#!/usr/bin/ksh
 
for f in *.c
do
 gcc -o ${f%.c} $f
done

If they are all subroutines but one with a main, use this:
Code:
gcc -c *.c
ar all.a *.o
gcc -o my_name all.a

Not sure at all about the ar command line being correct, just a hint. Subroutine order in a *.a is not important like on a cc/link, so linking from all.a always works. Since it is an ar from scratch, you want the anti-quadratic option!

Last edited by DGPickett; 01-07-2011 at 02:16 PM..
# 3  
Old 01-05-2011
Quote:
Originally Posted by rzili
I want to compile all files in my directory i wrote
find *.c | gcc -o * *.c
but it dosent work Smilie Help pliz
Does gcc even take piped input? I don't think I've ever seen any compiler used that way.

What are you trying to accomplish? Compile a bunch of C files into one executable? There's an even simpler way than the examples DGPickett provided:

Code:
gcc *.c -o yourBinaryFileName

The "*.c" argument is expanded by your shell to every file in your current directory that ends in ".c", no matter what it begins with (as long as it doesn't start with a "." character, anyway), and the "-o" argument tells gcc that the next argument is the name of the file it's to use to write its output to.
# 4  
Old 01-06-2011
Quote:
Originally Posted by rzili
I want to compile all files in my directory i wrote
find *.c | gcc -o * *.c
but it dosent work Smilie Help pliz
What about using Makefile(s) ?

Cheers, Loïc
# 5  
Old 01-07-2011
Make is great, except nobody seems to keep it clean enough to work right, and so has to purge and build from scratch all the time, or has n different versions of the same source file in production. I noticed in Ant they said don't bother, just make it all again. Of course, it is nice if you can do that quickly, like in parallel, but with clean logging and error handling, so you can tell if it ran, and if not, why not, and where.

---------- Post updated at 03:43 PM ---------- Previous update was at 01:19 PM ----------

PS: If the files are subroutines but one or no mains, and you compile them all at once, some compilers can optimize between files, like inlining.
# 6  
Old 01-10-2011
Quote:
Originally Posted by DGPickett
Make is great, except nobody seems to keep it clean enough to work right, and so has to purge and build from scratch all the time, or has n different versions of the same source file in production. [...]
That might be a good down-to-earth comment for many SW-development teams... But with such an answer, you won't get any vacancy in my team Smilie *LOL*

Cheers, Loïc
# 7  
Old 01-10-2011
I have made my living cleaning up make files, an endless task, even with the cc support and even with dynamic libs. I used to run all prod through a what script to see the multiple versions installed. However, many make a good living chasing this butterfly!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to ignore Pipe in Pipe delimited file?

Hi guys, I need to know how i can ignore Pipe '|' if Pipe is coming as a column in Pipe delimited file for eg: file 1: xx|yy|"xyz|zzz"|zzz|12... using below awk command awk 'BEGIN {FS=OFS="|" } print $3 i would get xyz But i want as : xyz|zzz to consider as whole column... (13 Replies)
Discussion started by: rohit_shinez
13 Replies

2. Linux

Problems with gcc

Hello I'm not able to install gcc. My platform is # uname -a Linux localhost 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux #yum install gcc I got the following error ---> Package libgfortran44.x86_64 0:4.4.4-13.el5 set to be updated ---> Package... (2 Replies)
Discussion started by: My Style
2 Replies

3. Shell Programming and Scripting

Replace pipe with Broken Pipe

Hi All , Is there any way to replace the pipe ( | ) with the broken pipe (0xA6) in unix (1 Reply)
Discussion started by: saj
1 Replies

4. UNIX for Dummies Questions & Answers

What is the difference between GCC and CC?

Can anyone briefly tell me the difference between CC and GCC? Thanks! (1 Reply)
Discussion started by: andrewust
1 Replies

5. UNIX for Dummies Questions & Answers

Help with gcc and g++

Hi, I have recently got a job in unix, now training is going on and we have been practicing on telnet, so to practice at home I have installed vmware(virtual machine) and planning to download ubuntu. So my doubt is that whether I can write c and cpp progs in vi editor and can I run them by default... (5 Replies)
Discussion started by: vishal.973s
5 Replies

6. Programming

gcc compiler

Which gcc compiler release had the Arm 9 multicore support?Whether the compiler that used for the single Arm 9 core can be used for its multicore systems ? If gcc not support,please tell me which are the compilers that are available for Arm 9 multicore systems (including commerical).Whether... (0 Replies)
Discussion started by: sujith4u87
0 Replies

7. AIX

Gcc for AIX

Hi, I am working with AIX5.3 and I downloaded the gcc-4.2.4.tar.bz2 from the site and when I am trying to un-tar it.It is throwing error-- Please help me to resolve it. Thanks in Advance.. (6 Replies)
Discussion started by: smartgupta
6 Replies

8. Solaris

Installing gcc - recieve error message gcc : cannot execute

AIM- Install Oracle 11g on Solaris using VMWare Steps 1.Logged on as root 2.Created subfolders à /usr/local/bin & /usr/local/bin/gcc 3.Downloaded gcc & libiconv & unzipped them on my harddrive & burnt them on CD 4.Copied files from CD to /usr/local/bin/gcc 5.Terminal (root) à pkgadd -d... (8 Replies)
Discussion started by: Ackers
8 Replies

9. Programming

Gcc

Dear all, Any body please guide, i require a C which will run in Linux environment. Its urgent please. warm regards, Senthil K (1 Reply)
Discussion started by: Senthil
1 Replies

10. Programming

gcc update

Hai Friends How should i update gcc (version 3.2.1) to gcc (version 3.2.2). I am using FreeBSD 5.0 RELEASE Thanks in advance Collins (0 Replies)
Discussion started by: collins
0 Replies
Login or Register to Ask a Question