LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-22-2005, 02:45 PM   #1
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Rep: Reputation: 32
the hello program in KDevelop


hi im just starting to learn programming and already have problems i wrote the hello program in KDelop and when i was done i opened the konsole at bottom and logged in as root and typed "cc hello.c" as far as i know it was supposed to make a exe file called a.out so i went back to kopnsole and typed "a.out" as root and it gave me


/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status


not sure what that means but i looked over everything and its just as book has it i even indented the "printf" part.
 
Old 08-22-2005, 03:37 PM   #2
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
oh and if theres a better or more beginner friendly program to use for "C" plz let me know ty. im using FC4 just incase u need that
 
Old 08-22-2005, 03:38 PM   #3
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Posting your source here would be helpfull.


Note as well you can compile programs without being root.


as a user try and compile it as such type only whats in red.


User@Nightmare$ gcc -Wall -o test hello.c


and post any erros you get.
 
Old 08-22-2005, 03:43 PM   #4
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
Code:
#include <stdio.h>
main()
{
          printf("hello, john\n");
}

that is program as written now here is the errors after "gcc -wall -o test hell.c"
Code:
[boxerboy@localhost ~]$ gcc -Wall -o test hello.c
hello.c:3: warning: return type defaults to ‘int’
hello.c: In function ‘main’:
hello.c:5: warning: control reaches end of non-void function
hello.c:5:2: warning: no newline at end of file
 
Old 08-22-2005, 03:48 PM   #5
devscott
LQ Newbie
 
Registered: Jan 2005
Location: Wisconsin
Distribution: Ubuntu & Fedora
Posts: 5

Rep: Reputation: 0
main should return an int to tell the OS how it terminated.

so try this

#include <stdio.h>
int main()
{
printf ("Hello Linux Questions people");
return 0;
}
 
Old 08-22-2005, 03:55 PM   #6
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
after trying devs version (pasted it in) i returned this:
Code:
[boxerboy@localhost ~]$ gcc -Wall -o test hello.c
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
looks like same thing only now its minus one error.
 
Old 08-22-2005, 04:06 PM   #7
devscott
LQ Newbie
 
Registered: Jan 2005
Location: Wisconsin
Distribution: Ubuntu & Fedora
Posts: 5

Rep: Reputation: 0
try doing just a

gcc -c hello.c

should compile fine...

Oh and you asked about programs... download install anjuta by

yum install anjuta
 
Old 08-22-2005, 04:11 PM   #8
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
ok i tryed "gcc -c hello.c" and command line came up for me other than that no errors or nothing.
"a.out" is saying command not found.
 
Old 08-22-2005, 04:19 PM   #9
devscott
LQ Newbie
 
Registered: Jan 2005
Location: Wisconsin
Distribution: Ubuntu & Fedora
Posts: 5

Rep: Reputation: 0
yeah in never built that file. but we know it compiled successfully

try this

gcc hello.c -o hello

and then run it
./hello

should give you your desired results.
 
Old 08-22-2005, 04:39 PM   #10
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by devscott
try doing just a

gcc -c hello.c

should compile fine...

Oh and you asked about programs... download install anjuta by

yum install anjuta
i installed it and it said it installed succesfully but i dont see it in the list under programming. is it called that or would it store it under different name?
 
Old 08-22-2005, 04:43 PM   #11
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
ok heres what happened using KDevelop

Code:
boxerboy@localhost ~]$ gcc hello.c -o hello
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
 
Old 08-22-2005, 04:45 PM   #12
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
ok i saved it this time lol i forgot to last time heres what i got
Code:
[boxerboy@localhost ~]$ gcc hello.c -o hello
hello.c:6:2: warning: no newline at end of file
 
Old 08-22-2005, 04:48 PM   #13
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
Talking

i typed "./hello" and it worked i thinklol it said "hello boxerboy" and right after it gave my username$ i assuming thats it
 
Old 08-22-2005, 04:49 PM   #14
devscott
LQ Newbie
 
Registered: Jan 2005
Location: Wisconsin
Distribution: Ubuntu & Fedora
Posts: 5

Rep: Reputation: 0
typing anjuta

from the command line should start up anjuta

In gnome and FC I know you have to log out before a program is added, well at least on my system, to the menu. I don't know if KDE is the same.

as far as your error message... I don't know.
 
Old 08-22-2005, 04:57 PM   #15
boxerboy
Member
 
Registered: Jul 2005
Distribution: ubuntu5.04, ubuntu5.10, suse9.3, mandrake10.1, mandriva2006(beta), FC1-4, redhat9.0, debian sarge
Posts: 519

Original Poster
Rep: Reputation: 32
it worked i think thank you very much and i will try anjuta in a min. does "int" have to be in front of "main" always? and thank you again
 
  


Reply



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
developing graphical program using kdevelop shyam_d_sundar Programming 2 04-28-2005 11:39 AM
Kdevelop splash screen finishes loading then program crashes BluePyre Linux - Software 1 08-25-2004 01:51 PM
How do i transport a C++ program in VC++ 6.0 to run on Linux Kdevelop 2 vsu003 Programming 2 08-20-2004 10:22 AM
my program does not single step with gdb in kdevelop tcma Linux - Software 0 08-12-2004 04:48 PM
howto use kdevelop to develop and debug a console program vasanthraghavan Programming 5 05-15-2004 12:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:45 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration