LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-07-2003, 06:26 AM   #1
banana2
Member
 
Registered: Dec 2002
Location: Sydney
Distribution: Debian
Posts: 55

Rep: Reputation: 15
Haw can i run my C program in linux??


i made one program in C,but i do not know haw to run it?

debian:/# gcc ctest
/usr/bin/ld: cannot open crt1.o: No such file or directory
collect2: ld returned 1 exit status

thats my program...

#include <stdio.h>

void main(void)

{

printf(this is my simple program in Linux);

}

Last edited by banana2; 02-07-2003 at 06:30 AM.
 
Old 02-07-2003, 07:09 AM   #2
gg4
LQ Newbie
 
Registered: Jan 2003
Posts: 9

Rep: Reputation: 0
It shouldn't compile. Void main is wrong.
 
Old 02-07-2003, 01:11 PM   #3
bgraur
LQ Newbie
 
Registered: Dec 2002
Location: Iasi
Distribution: Mandrake 8.2
Posts: 12

Rep: Reputation: 0
if you wanna do it by the book try this :

#include <stdio.h>

int main( int argc, char* argv[])

{

printf("this is my simple program in Linux");

return 0;
}

but judging from the output you provided I think you don't have gcc properly installed on your machine.
 
Old 02-07-2003, 04:21 PM   #4
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
Quote:
Originally posted by gg4
It shouldn't compile. Void main is wrong.
It compiles perfectly, and why shouldn't it? I can see no fatal errors in 'void main'
 
Old 02-07-2003, 08:16 PM   #5
gg4
LQ Newbie
 
Registered: Jan 2003
Posts: 9

Rep: Reputation: 0
Quote:
Originally posted by iceman47
It compiles perfectly, and why shouldn't it? I can see no fatal errors in 'void main'
I really don't want to get in this argument, but oh well.


void main is undefined. According to the C/C++ standards, main should return an int. There is no exception. If you don't believe me, check out the language standard.
 
Old 02-07-2003, 10:39 PM   #6
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
"void main()" shouldn't be compiled. "main" should return "int".
But you can write "main" without any return value.

main()

It doesn't mean that the return type is void. The compiler assumes that return "int" if you don't put any return type in front of "main".
 
Old 02-08-2003, 09:06 AM   #7
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
Re: Haw can i run my C program in linux??

I think the main() function thing is not the actual problem. "void main()" is not the right way, but it actually should only result in a warning.

Quote:
Originally posted by banana2
debian:/# gcc ctest
/usr/bin/ld: cannot open crt1.o: No such file or directory
collect2: ld returned 1 exit status
I think the real problem is the command you are using to compile your program with. It should read: "gcc ctest.c" at least. After this, the executable file will bee called "a.out" and you should run it with: "./a.out".

Better yet: "gcc ctest.c ctest". Then your executable will be called "ctest", and can run it with "./ctest".

Like bgraur already pointed out, the text inside the printf statement should be quoted with " ". Without these double quotes, compiling will fail anyway.

Last edited by Hko; 02-08-2003 at 09:08 AM.
 
  


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
I need to run a linux program on windows 000jits Linux - General 2 08-16-2004 04:07 AM
A Linux dist that will run Linux under Windows like a program caderyn Linux - Distributions 4 05-24-2004 07:43 PM
How to run pascal program in Linux? zWaR Programming 5 02-04-2004 03:52 AM
bmp2html- how to run program in linux disorderly Linux - Newbie 3 11-21-2003 01:42 AM
Run WINNT Program in Linux ckamheng Linux - Software 7 05-07-2003 10:21 AM


All times are GMT -5. The time now is 12:44 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration