LinuxQuestions.org
Visit Jeremy's Blog.
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 09-28-2012, 11:35 AM   #1
tamilvanan
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Rep: Reputation: Disabled
how to make an standalone simple hello world application


Hi team,

I like to create simple hello world application. i know the basics of c and scripting .The application should work like when i enter show in terminal it should display hello world and exit .

Regards,
Tamil Vanan K
 
Old 09-28-2012, 12:01 PM   #2
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
Have you tried
Code:
#include <stdio.h>
int main(void){
    printf("Hello World!\n");
    system("pause");
    return(0);
}
 
Old 09-28-2012, 12:07 PM   #3
mennohellinga
Member
 
Registered: Jun 2012
Location: AccountKiller
Distribution: AccountKiller
Posts: 72

Rep: Reputation: 38
Define 'standalone'.
The first program in K&R is a hello world:
Code:
#include <stdio.h>

main()
{
        printf("hello, world\n");
}
The hello world program is part of the basics of any scripting language:
python 2:
Code:
print "hello, world"
Perl:
Code:
print "hello, world\n";
Shell:
Code:
echo hello, world
If you don't know this, you don't know scripting.
 
Old 09-28-2012, 12:32 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860
Also, if you do a websearch of "C hello world" you will get literary millions of pages with examples.
Usually Hello World is the first example you will get in any course/book/tutorial for any programming language, so if you already know the basics of C you should already know such an example.
 
Old 09-28-2012, 12:55 PM   #5
tamilvanan
LQ Newbie
 
Registered: Sep 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi team,

i have tried examples given by you.what i exactly want is instalble executable. when i install it some others system also and if i enter "show" in terminal simply it has to print hello world in screen.please guide how to i start doing it

Regards,
Tamil
 
Old 09-28-2012, 01:12 PM   #6
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
You mean in an already opened terminal emulator execute
Code:
$ show
or "right click" -> "show in terminal" ?
 
Old 09-28-2012, 03:20 PM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860Reputation: 4860
If you want something to be installable you have to package it correctly. Since you use Ubuntu, which is using Debian's packaging system have a look here: http://wiki.debian.org/IntroDebianPackaging
 
Old 10-22-2012, 03:01 PM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: SlackwareŽ
Posts: 13,238
Blog Entries: 29

Rep: Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437
Moderator Response

Moved: This thread is more suitable in <Programming> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 10-22-2012, 03:17 PM   #9
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,569

Rep: Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130
Quote:
Originally Posted by tamilvanan View Post
Hi team,

i have tried examples given by you.what i exactly want is instalble executable. when i install it some others system also and if i enter "show" in terminal simply it has to print hello world in screen.please guide how to i start doing it

Regards,
Tamil
If you compile in 32-bit with static libraries, it will run on 99.9% of Linux setups. For that last 0.1%, you'll need to custom-compile it for the architecture.

You won't "install" it per-se on the computers, you'll just copy the executable over and run it with "./show".

You still haven't told us what language you want to do this in either. If you're just doing this in BASH you don't even need a program, you can do it with a simple alias:
Code:
$ alias show="echo Hello, world"
$ show
Hello, world
What is the purpose of what you're doing here? If it's a learning experience, then what are you trying to learn to do? The right way to approach this exercise is by first determining what you intend to learn from it.

Last edited by suicidaleggroll; 10-22-2012 at 03:20 PM.
 
Old 10-22-2012, 05:32 PM   #10
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
File "show.c":
Code:
#include <stdio.h>
#include <stdlib.h>

int main( int argc, char * argv[] ){
    printf( "Hello, world!\n" );
    exit(0);
}
Build the executable "show"
Code:
make show
It is 'installed' in the current working directory. If you want to officially install it, use 'install':
Code:
# first, maybe 'man install', then...
sudo install show /usr/local/bin
Run the program:
Code:
show
Send it to another computer
Code:
scp show someUser@some.other.computer
Done.

--- rod.

Last edited by theNbomr; 10-22-2012 at 05:35 PM.
 
  


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
Simple standalone ftp server bigmo Linux - Server 4 09-06-2011 04:07 PM
How can I make that simple application by c Buggaya Programming 12 06-10-2006 09:39 PM
LXer: Beyond Rootkits: World's First Standalone Kernel Mode Bot? LXer Syndicated Linux News 0 04-07-2006 06:54 PM
I want to make a standalone network media player from a 200MHz PII resnak Linux - Software 1 05-06-2005 07:00 PM
Creating Standalone Application using Octave swifty99uk Linux - Software 0 10-28-2003 04:26 AM

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

All times are GMT -5. The time now is 06:58 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration