473,396 Members | 2,158 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.

How Do I Compile My c++ program.

I am new to C++ and made my first program which looks like this:
#include <iostream>

using namespace std;

int main()
{
cout << "Bonjour Monde!" << endl;
return 0;
}

I am using dev-c++. I was wondering how do I compile using Cygwin.
Nov 30 '07 #1
17 5806
Choose "Save as",select a proper folder where to save your file to.
Press <Ctrl> + F9 to compile your source.
Press <Ctrl> + F10 to execute your program.
otherwise ,in windows ,from command line,type
gcc.exe yourprogram.c -o yourprogram.exe
Nov 30 '07 #2
where do i press <ctrl>+F9
Nov 30 '07 #3
Ganon11
3,652 Expert 2GB
Using cygwin, type:

Expand|Select|Wrap|Line Numbers
  1. g++ yourProgramNameHere.cpp -o yourExeNameHere.exe
For a C program,

Expand|Select|Wrap|Line Numbers
  1. gcc yourProgramNameHere.c -o yourExeNameHere.exe
Make sure you're in the folder with your program file.
Nov 30 '07 #4
I am new to C++ and made my first program which looks like this:
#include <iostream>

using namespace std;

int main()
{
cout << "Bonjour Monde!" << endl;
return 0;
}

I am using dev-c++. I was wondering how do I compile using Cygwin.
What is the exe name. and the file is called hello.c
Nov 30 '07 #5
sicarie
4,677 Expert Mod 4TB
In gcc/g++ the -o option allows you to specify the name of the resulting executable file. So when you type in '-o myprog.exe' you are saying, "call the resulting executable of my program 'myprog.exe' " and that is the file you either just type in at the command line (depending on how everything is set up) or you type ./myprog.exe.

If you do not specify the -o option, it will be named a.exe (on Cygwin) or a.out (Linux).
Nov 30 '07 #6
In gcc/g++ the -o option allows you to specify the name of the resulting executable file. So when you type in '-o myprog.exe' you are saying, "call the resulting executable of my program 'myprog.exe' " and that is the file you either just type in at the command line (depending on how everything is set up) or you type ./myprog.exe.

If you do not specify the -o option, it will be named a.exe (on Cygwin) or a.out (Linux).
I have an error though. It says bash: gcc: command not found.
Nov 30 '07 #7
sicarie
4,677 Expert Mod 4TB
I have an error though. It says bash: gcc: command not found.
You have to install it via the setup program, I don't believe it is installed by default.
Nov 30 '07 #8
where do i install it.
Nov 30 '07 #9
sicarie
4,677 Expert Mod 4TB
where do i install it.
You need to run the Cygwin setup program again and install. This is most likely wherever you installed it originally, but I make it a point to move it back to C:/Cygwin so I don't lose it. Run the setup.exe, and it keeps your currently installed packages (unless you de-select them from the list), and will install any new packages you choose.

I'd recommend searching your computer for the setup.exe file as it could be anywhere (most likely your desktop or 'My Documents' folder). It will have the Cygwin icon.
Dec 1 '07 #10
You have to install it via the setup program, I don't believe it is installed by default.
I think this happens because he doesn't provide the full path of the gcc command;please update the shell Path variable with the path of the directory where gcc is installed;this can be done through control panel->system->advanced->environment variables
otherwise,type the whole path of gcc.exe
for example if gcc is in C:\mytools you should type
C:\mytools\gcc.exe mysource.c -o mysource.exe
Dec 1 '07 #11
sicarie
4,677 Expert Mod 4TB
I think this happens because he doesn't provide the full path of the gcc command;please update the shell Path variable with the path of the directory where gcc is installed;this can be done through control panel->system->advanced->environment variables
otherwise,type the whole path of gcc.exe
for example if gcc is in C:\mytools you should type
C:\mytools\gcc.exe mysource.c -o mysource.exe
This is so if you are not using Cygwin to compile (and just Dev C++). If you are using gcc/g++ inside Cygwin, you do not need to do this.

(Well, at least I never have...)
Dec 1 '07 #12
cant i just use dev c++ to compile.
Dec 1 '07 #13
i just found something that says

There doesn't seem to be a GNU make file in PATH or in dev-c++'s Bin Path. Please make surethat you have GNU make and adjust bin setting or system PATH enviroment variable and that make setting in Compiler Option contains correct filename, otherwise you will not be able to compile anything.

Is that the problem? How do i fix it.
Dec 1 '07 #14
sicarie
4,677 Expert Mod 4TB
i just found something that says

There doesn't seem to be a GNU make file in PATH or in dev-c++'s Bin Path. Please make surethat you have GNU make and adjust bin setting or system PATH enviroment variable and that make setting in Compiler Option contains correct filename, otherwise you will not be able to compile anything.

Is that the problem? How do i fix it.
Yes, as I said, if you are using Dev C++, you must put the path in the environment variables (as specified above). However, if you can find the file through Cygwin, you don't need to do that. It's up to you.
Dec 1 '07 #15
how do i put the path in the enviroment variables?
Dec 1 '07 #16
oler1s
671 Expert 512MB
how do i put the path in the enviroment variables?
We could tell you the answer to this question. But you're turning into a help vampire. Look, whether or not you realize this, you can't keep running back to us everytime you don't know something. Googling something takes about 5 seconds. Reading the material you get from Google takes a bit of work.

As a programmer, you need to be able to actively solve problems, Googling, reading material, reading books, etc. as needed. Get some practice now. If we say something, and you don't understand how to do what we ask, Google first, read the material, and try it.

See definition of help vampire. Also see article on asking smart questions.
Dec 1 '07 #17
sicarie
4,677 Expert Mod 4TB
That and the fact that this will be the second time I am telling you that it is posted above.
Dec 1 '07 #18

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.