How to complie a c++ program in Unix or Cygwin?


 
Thread Tools Search this Thread
Top Forums Programming How to complie a c++ program in Unix or Cygwin?
# 1  
Old 03-20-2007
Question How to complie a c++ program in Unix or Cygwin?

Can I use gcc to compile a piece of c++ code?
Do I need to name the file that contains the code as .cpp? Thank you
# 2  
Old 03-21-2007
use g++ to compile .cpp code
# 3  
Old 03-21-2007
if the file is called, say:
thing.cpp or thing.c

do
make thing

and it should work OK
# 4  
Old 03-21-2007
Quote:
Originally Posted by bigearsbilly
if the file is called, say:
thing.cpp or thing.c

do
make thing

and it should work OK
No, it shouldn't. Make depends on having a Makefile, written for the specific purpose of compiling a piece of code.
# 5  
Old 03-21-2007
How to compile the following "test.cpp" code? It reports "std error"...

#include <vector>
#include<iostream>

int main(){
std:vector <int> a1(10);
a1[0]=12;
std:cout<<a1[0]<<endl;
return 0;
}

Quote:
Originally Posted by matrixmadhan
use g++ to compile .cpp code
# 6  
Old 03-21-2007
Quote:
Originally Posted by reborg
No, it shouldn't. Make depends on having a Makefile, written for the specific purpose of compiling a piece of code.
Thank you. But where is the makefile? How can I revise it?
# 7  
Old 03-21-2007
Quote:
Originally Posted by meili100
How to compile the following "test.cpp" code? It reports "std error"...

#include <vector>
#include<iostream>

int main(){
std:vector <int> a1(10);
a1[0]=12;
std:cout<<a1[0]<<endl;
return 0;
}
You don't have one.

g++ -o test test.cpp
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Cygwin script to transfer file from windows to UNIX

Hi, Objective is to transfer files from windows server to Unix server using cygwin. I have installed cygwin, and I manually execute commands and transfer files from windows to unix using sftp. These are steps I execute 1) Run cmd 2) Run cygwin 3) At prompt type sftp user1@uniserver 4) lcd... (2 Replies)
Discussion started by: wahi80
2 Replies

2. Shell Programming and Scripting

Execute a shell script in UNIX server from Cygwin

Hi All, We have shell scripts in UNIX ( Sun OS ) server. Also in my windows machine i have Cygwin installed. Now is there a way to execute Shell script available in UNIX server from Cygwin? (4 Replies)
Discussion started by: Girish19
4 Replies

3. HP-UX

UNIX apps on CYGWIN

Hi all, am new to the forum. i would like to check with the community whether anyone had tried to run self-developed UNIX apps on the CYGWIN? Does the CYGWIN presents a friendly environment to host the UNIX apps? thanks :) (14 Replies)
Discussion started by: lchunleo
14 Replies

4. UNIX for Dummies Questions & Answers

How can I rebuild applications that developed in UNIX? I need to use it in windows os with cygwin

I need to rebuild an application that developed in unix environment and run in windows OS with cygwin. so How can I rebuild from the source code? is there any one who said something on this regard? (2 Replies)
Discussion started by: bejirond
2 Replies

5. UNIX for Dummies Questions & Answers

Cross complie linux make files onto a windows 7 machine using PGI Cygwin

Hello, I am very unfamiliar with linux/unix (don't even know the difference), but am trying to get some linux software to run on my Windows machine for my research. I have the makefiles for the software, and it is designed to be compiled in the PGI complier, which I also have. When i... (6 Replies)
Discussion started by: roba87
6 Replies

6. UNIX for Dummies Questions & Answers

Cygwin not waiting for program in background (solved)

Hello, I know this isn't exactly a Unix question, but I wasn't able to find much information elsewhere. I'm trying to run a program in the background using Cygwin on a Windows machine, then use the wait command to pause before proceeding. Unfortunately, as I've confirmed using ps aux, the... (0 Replies)
Discussion started by: ocdcollector
0 Replies

7. UNIX for Dummies Questions & Answers

Unix Emulator Cygwin

Hi, I installed unix emulator cygwin, it does not allow me to open vi editor. Can anybody know if cygwin supports vi. if not can somebody please refer a good emulator. (5 Replies)
Discussion started by: siquadri
5 Replies

8. Shell Programming and Scripting

using alias in cygwin unix

i have a cygwin unix and i would like to use alias to save a cd command.. however i lose this alias when i close out cygwin and log back in.. is there any way to save this command so that i can use it every time i log in? i am using cygwin on windows xp. thanks. (1 Reply)
Discussion started by: npatwardhan
1 Replies

9. Windows & DOS: Issues & Discussions

Basic Unix Commands for cygwin

Hi. I'm New user for this Forum.Presently i'm working with Cygwin I want to know the basic commands that will be used for Cygwin. Can anyone guide me on this regards Thanks & Regards Sanjay (0 Replies)
Discussion started by: sanjay.karthik
0 Replies

10. Programming

Help about SCO unix complie problem ?

Can you tell me why ? Thank you ! $ cc -L /usr/lib server.c -lsocket UX:acomp: WARNING: "server.c", line 60: argument is incompatible with prototype6 Undefined first referenced symbol in file ffush server.o... (2 Replies)
Discussion started by: loudingyang
2 Replies
Login or Register to Ask a Question