Compile and Run
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Compile and Run




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Compile and Run  
Shane Malden


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:16 PM

Hi, Can someone help me out.. After writting the code in c or c++ what
commands in RedHat do you use to compile the application? Once compiled do
you just run it as any other command? Any help is appreciated.

Regards,
Shane







[ Post a follow-up to this message ]



    Re: Compile and Run  
Jens.Toerring@physik.fu-berlin.de


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:16 PM

Shane Malden <smalden@bigpond.net.au> wrote:
quote:
> Hi, Can someone help me out.. After writting the code in c or c++ what > commands in RedHat do you use to compile the application?
That's a bit difficult to tell because that might depend on which libraries you need etc. But in the most simple case, when you have a single source file that doesn't depend on any external libraries (except the system library), it can be as easy as make myprog if the source file is named myprog.c or myprog.cpp. If you wnat to invoke the compiler and linker directly instead of having the make utility do the work for you you may just need gcc -o myprog myprog.c or g++ -o myprog myprog.cpp If you require math functions you have to add '-lm' to these lines. Of course, all of the above assumes that you have 'make' and gcc installed on your system.
quote:
> Once compiled do you just run it as any other command?
Yes. Just type './myprog' and it should be executed (depending on how your system is set up you may even be able to drop the './' bit at the start of the command). Regards, Jens -- \ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de \__________________________ http://www.physik.fu-berlin.de/~toerring




[ Post a follow-up to this message ]



    Re: Compile and Run  
Master Web Surfer


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:16 PM

[This followup was posted to comp.unix.programmer]

In article <pBjAb.41861$aT.3617@news-server.bigpond.net.au>,
smalden@bigpond.net.au says...
quote:
> Hi, Can someone help me out.. After writting the code in c or c++ what > commands in RedHat do you use to compile the application? Once compiled do > you just run it as any other command? Any help is appreciated. > > Regards, > Shane
For a simple one file program that only uses standard UNIX libraries you could do something like the following : gcc mycommand.c -o mycommand Then you run "mycommand" just like any other command. If your program uses some other special libraries then you could do something like the following : gcc mycommand -o mycommand -llibname




[ Post a follow-up to this message ]



    Re: Compile and Run  
examnotes


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 10:16 PM

Master Web Surfer <raisin@delete-this-trash.mts.net> writes:
quote:
> > For a simple one file program that only uses standard UNIX libraries > you could do something like the following : > > gcc mycommand.c -o mycommand
Or, even simpler, make mycommand
quote:
> Then you run "mycommand" just like any other command.
Depending on your $PATH, you might have to use ./mycommand, to run it from the current directory. Having . in your PATH is a bad idea. -- Måns Rullgård mru@kth.se




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:28 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register