LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
Password
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.

Notices

Reply
 
Search this Thread
Old 08-12-2003, 02:28 PM   #1
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Post DISCUSSION: Building C programs on Linux


This thread is to discuss the article titled: Building C programs on Linux
 
Old 08-13-2003, 08:11 PM   #2
darin3200
Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Rep: Reputation: 45
Looks nice. Hopefully java expierence will be helpful, I want to learn C and my school never has enough people sign up for the class to have it. Thanks
 
Old 08-14-2003, 04:22 AM   #3
genesis1923
LQ Newbie
 
Registered: Aug 2003
Distribution: SuSE Office Desktop 8.1
Posts: 7

Rep: Reputation: 0
Looks good but my problem is that SuSE Office desktop does not come with a C compiler. What would be really useful for me is a section on how to get started if you don't have a C compiler.
 
Old 08-21-2003, 09:42 AM   #4
svar
Member
 
Registered: Jul 2003
Posts: 352

Rep: Reputation: 30
??? what do you mean Suse does not come with a C compiler?
gcc is the GNU C compiler
and it is packaged with Suse, last time I checked(up to SuSe 8)

svar
 
Old 10-31-2003, 04:32 PM   #5
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
make comment:

under several flavors of unix make does not require tab characters in rules. They don't break anything if they are there.

The other thing which confuses new folks : K&R, ANSI "styles"
Code:
/* ----- version 1 */
int main(argc, argv)
int argc;
char **argv;
{
       return 0;
}

/* ---- version 2 */
int main(int argc, char *argv[])
{
       return 0;
}

/* --------- version 3 */
int main(int argc, char *argv[]){
        return 0;
}
Believe it or not, C shops usually prefer style #3 - very 'ANSI'
Style 2 is "okay", style 1 is a no-no.

A lot of examples I've seen that come with downloads were written in 1985 and look like version 1.

While it doesn't REALLY matter, this is confusing as hell to newbies.

You might want to consider adding a section talking about style.
Plus, version 1 won't compile under cc -Aa on HPUX v11.0 for example. So, it can cause some issues down the road.
 
Old 03-02-2004, 09:49 PM   #6
wilson-china
LQ Newbie
 
Registered: Mar 2004
Posts: 6

Rep: Reputation: 0
a good subject
 
Old 01-19-2006, 11:57 PM   #7
Dazed_75
Member
 
Registered: Oct 2005
Location: Arizona
Distribution: Debian, Ubuntu, Puppy, others
Posts: 36

Rep: Reputation: 16
Although you begin the article saying it is inended for folks who know C but do not know how to build a program under Linux, you spend much of the article expplaining the simple C program. You spend very little of the article saying how building it is different in Linux. I have some 15= year old experience In C under DOS, Windows and Unix (a little). I was hoping to see this article show how to set up my environment under Linux and how some of the tools differ or have improved.

When I saw the first line in the 1st program as "#include" with no argument as to WHAT to include and your statement that it meant you were using the stdio library, I thought I was on the right track. However, gcc gives the expected errors on that line (yes, I named the file differently):

inctest.c:1:9: error: #include expects "FILENAME" or <FILENAME>
inctest.c: In function ‘main’:
inctest.c:5: warning: incompatible implicit declaration of built-in function ‘printf’

I infer not that your article is wrong, but that your environment is set up differently. Specifically, I found some other articles referring to default includes but they did not help either. Now I don't mind; in fact, I like being explicit about my includes so this is not a big deal detail. What I would like to find though is some information that really IS about how building C programs in Linux is different from other environments. Any suggestions?
 
Old 01-21-2006, 09:35 AM   #8
robin2190
LQ Newbie
 
Registered: Jan 2006
Posts: 1

Rep: Reputation: 0
how do i install simply mepis 2004 2.6.7.? HELPPPPPPPPP
 
Old 03-20-2006, 01:45 PM   #9
Darkhack
Member
 
Registered: Mar 2005
Location: Kansas City
Distribution: Ubuntu 7.10
Posts: 47

Rep: Reputation: 15
Quote:
Originally Posted by Dazed_75
When I saw the first line in the 1st program as "#include" with no argument as to WHAT to include and your statement that it meant you were using the stdio library, I thought I was on the right track. However, gcc gives the expected errors on that line (yes, I named the file differently):

inctest.c:1:9: error: #include expects "FILENAME" or <FILENAME>
inctest.c: In function ‘main’:
inctest.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
Sadly, the author must have forgotten that his text would be displayed "as-is" in a browser and that they don't render < or > very well. In order to display the greater-than or less-than signs, you must use the following... (hopefully the author will fix it)

> = &gt;
< = &lt;
 
Old 03-25-2006, 12:07 PM   #10
xushi
Senior Member
 
Registered: Jun 2003
Location: UK
Distribution: Gentoo
Posts: 1,288

Rep: Reputation: 45
I understand the author's kind intentions, but this is a very poor article. I'm not sure how the LQ mods allowed it to be posted, and furthermore, i'm not sure why or how the author didn't preview his work, or check/fix any mistakes afterwards. I'm not referring to tricky or blind-eye mistakes, but big ones such as the #include bit on the top.

Furthermore, adding to the comments said above, this hasn't really shown us any differences between building a typical C program, and building a C program for Linux.

And as an added suggestion, some outside links to more indepth tutorials for certain sections would do good.

I hope this article gets fixed. It is valuable and it's needed in LQ.
 
Old 02-19-2008, 01:29 AM   #11
kumar.anupam
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
storage of temporary variables in C

where does the temporary variables gets stored while executing C program.
 
Old 04-21-2008, 05:42 AM   #12
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,283

Rep: Reputation: 172Reputation: 172
also, you don't need a makefile to use make's implicit rules
for simple C files:

Code:
$ printf '#include <stdio.h>\nmain()\n{\nputs("hello");\n}\n' > dummy.c
$ make dummy
cc     dummy.c   -o dummy
$ ./dummy
hello
 
Old 04-15-2009, 02:50 AM   #13
kitiya
LQ Newbie
 
Registered: Apr 2009
Posts: 1
Blog Entries: 1

Rep: Reputation: 0
anyone know the coding for this progarmmes

i got 2 questions and i try to write codes for this. its dosent working propoerly. anyone know how to do coding for this questions. thanks

1) Instead of producing the summation of the given non-negative integer,
modify this program and make it create only one
thread that will calculate the factorial. When the thread finishes execution,
the parent thread will output the factorial calculated by the child thread


2 ) Besides of producing the summation of the given non-negative integer,
modify this program and make it create two threads.
One thread is to produce the summation of the given non-negative integer;
the other thread is to calculate the factorial. When the two child threads
finish execution, the parent thread will output the summation and the
factorial of the given non-negative integer
 
Old 05-03-2009, 11:13 PM   #14
linux.sridhark
LQ Newbie
 
Registered: Jan 2008
Location: India
Posts: 2

Rep: Reputation: 0
Sri

Nice tutorial
 
Old 05-12-2009, 01:59 PM   #15
ahmedtaw
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
Question help help :(

char c[20];
printf("\n\nPlease enter the name of the file: ");
scanf("%s",c);
printf("\nthe name you type is : %s\n",c);
system("mkdir c");

problem now in line 5 ,it make the folder name as c not the string i have enter
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DISCUSSION: Building C++ programs on Linux hylke LinuxAnswers Discussion 32 10-03-2013 09:27 AM
DISCUSSION: Building a Slackware Wireless Access Point eric.r.turner LinuxAnswers Discussion 11 09-09-2006 01:36 AM
DISCUSSION: ssh w/ gtk programs (host-client display export) mrchaos LinuxAnswers Discussion 1 12-14-2005 01:50 PM
DISCUSSION: Compiling Programs from Source jeremy LinuxAnswers Discussion 51 11-21-2005 04:35 AM
DISCUSSION: Virtual Filesystem: Building a Linux Filesystem from an Ordinary File mchirico LinuxAnswers Discussion 0 10-28-2004 10:35 PM


All times are GMT -5. The time now is 12:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration