473,396 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

compile and run C++ program

254 100+
In java environment, i compile and run program using "javac" and "java" respectively.

So, now is C++.

Compile c++ program (hello.cpp) , we type:

$ g++ testing.cpp

and to run that program, we type:

$ ./testing

as same in the below image:



OR this way.
---------------------------------------
Nick@ACER-Nick ~
$ g++ testing.cpp -o testing
$ testing
Hello C++ World!
$
---------------------------------------


Can you see any different from the image and the other way of compile-run program ?
Nov 20 '06 #1
9 22295
Banfa
9,065 Expert Mod 8TB
Can you see any different from the image and the other way of compile-run program ?
No because they are the same method.

the "./" just means "in the current directory", since the current directory is assume by default it can be left off so "./testing" and "testing" are the same file accessed in the same manor.
Nov 20 '06 #2
nickyeng
254 100+
No because they are the same method.

the "./" just means "in the current directory", since the current directory is assume by default it can be left off so "./testing" and "testing" are the same file accessed in the same manor.
i know about "/testing" and "testing"

but why the following "run program" fails?



that's why i explicitly mention the 2 ways of compile-run program methods.
Nov 20 '06 #3
sivadhas2006
142 100+
Hi,

The second method will work if you do the follwoing things.

Append the . to the PATH environment variable.
So it will work as you are expecting..

Regards,
M.Sivadhas.
Nov 21 '06 #4
nickyeng
254 100+
Hi,

The second method will work if you do the follwoing things.

Append the . to the PATH environment variable.
So it will work as you are expecting..

Regards,
M.Sivadhas.
where to change the PATH environment variable? i'm using cygwin.
Nov 21 '06 #5
Colloid Snake
144 100+
where to change the PATH environment variable? i'm using cygwin.
Do an 'ls -a' which will show you all the hidden files - my guess is it is in your .bash_profile or your .bashrc
Nov 21 '06 #6
nickyeng
254 100+
Actually do you guys know what i mean or not?

I want something happen like this :



i DONT want something happen like this :



Do you guys understand of what i'm trying to say?

so far now, my situation is the 2nd screen dump,once i compiled the program, it just pop to new command prompt..

I want 1st screen dump.

Please help.
Nov 21 '06 #7
Banfa
9,065 Expert Mod 8TB
Insert the code

Expand|Select|Wrap|Line Numbers
  1.   for(;;)
  2.     ;
  3.  
just before the end of main so that the program does not stop running.
Nov 22 '06 #8
nickyeng
254 100+
Insert the code

Expand|Select|Wrap|Line Numbers
  1.   for(;;)
  2.     ;
  3.  
just before the end of main so that the program does not stop running.
it is nothing to do with my code.

its cygwin propmting issue, dont you think?
Nov 22 '06 #9
Banfa
9,065 Expert Mod 8TB
it is nothing to do with my code.

its cygwin propmting issue, dont you think?
No you have asked that the console doesn't return to the command prompt once the program has finished running.

This is not possible the only way to prevent a return to the command prompt is not to end the program, which is what the code I have posted will do.
Nov 23 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Brian | last post by:
Greetings: I am trying to compile the following code via command line. It compiles just fine in visual studio 2002 v7 so i took looked at the properties and i got the following command line...
17
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the...
5
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
10
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for performance reasons and can't be done at run time (data...
3
by: | last post by:
I am trying to compile a simple c# class in Web Matrix called howdy.cs: // Program start class public class HowdyPartner { // Main begins program execution public static void Main() { //...
4
by: John Smith | last post by:
Hi I'm porting some C++ code to new platforms and have some 1-byte aligned structures which need a specific size. Since datatypes can vary on different platforms (which I found out the hard way...
1
by: 张沈鹏 | last post by:
How to compile the HelloWorld of boost.asio? Maybe this is a stupid problem , but I really don't konw how to find the right way. My compile environment is WinXP, Msys , MinGw , G++ 3.4.2,...
109
by: zaidalin79 | last post by:
I have a java class that goes for another week or so, and I am going to fail if I can't figure out this simple program. I can't get anything to compile to at least get a few points... Here are the...
2
by: BruceWho | last post by:
I downloaded boost1.35.0 and built it with following command: bjam --toolset=msvc-7.1 --variant=release --threading=multi -- link=shared --with-system stage and it failed to compile, error...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.