Problem compiling C++ Code in Cygwin

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Problem compiling C++ Code in Cygwin
# 1  
Old 03-07-2010
Problem compiling C++ Code in Cygwin

Hello everyone. I just recently installed Cygwin and I am running it under Windows 7.

My problem is that I cannot seem to compile any C++ code with g++. I've tried to compile C Code using gcc and that works just fine. But Whenever I try to compile some C++ code, g++ throws a whole bunch of errors at me, which I have caught in an error file.

I've attached it to this post, so please take a look at it and tell me what I can do about it. I am absolutely clueless right now.
# 2  
Old 03-07-2010
Hm, from the error output itself I can't deduct anything special. What's the code, and the compilation options?
# 3  
Old 03-07-2010
The code looks as follows:
Code:
#include <iostream>
using namespace std;

int main () {

cout << 'Hello World!';
return 0;

}

And the call to the compiler is:

g++ 04.cpp -o 04
# 4  
Old 03-07-2010
Well, here (Cygwin on Win XP SP3) there's no problem. But you've got a glaring error in your code anyways, which probably is the source of your problems:
Code:
#include <iostream>
using namespace std;

int main () {

cout << 'Hello World!';
return 0;

}

On the red marked line you're trying to pass of a string as a character. Replace the single quotes with double quotes.
# 5  
Old 03-07-2010
Unfortunately that only fixes the very first error mentioned in the first line of the error file.

Something seems to be wrong with the includes, I think. But as stated before I have no clue how to handle this problem..
# 6  
Old 03-07-2010
As I haven't seen those errors before, I couldn't say anything about the cause or the remedy. But on instinct I'd check again if the required development libraries are installed (as those packages also include the headers). Also check the bug reports for anyone with a similar problem and/or report a problem (instructions here)
# 7  
Old 03-07-2010
I have no clue where those errors were coming from, but:

I have deinstalled and reinstalled Cygwin from a different mirror while installing only the needed packages. It seems to work now.

Thanks anyways!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Answers to Frequently Asked Questions

Error when compiling using cygwin

I tried to compile the files in basic_dump_ex using cygwin : /cygdrive/c/WpdPack/Examples-pcap/basic_dump_ex $make but I got this : cc -g -O -mno-cygwin -I ../../include -c -o basic_dump_ex.o basic_dump_ex.c cc: error: unrecognized command line option ‘-mno-cygwin’... (6 Replies)
Discussion started by: steve120
6 Replies

2. Programming

Library problem - not compiling in c

Ok I was trying to test if I installed correctly gsl, I followed the INSTALL file and still I don't know what is wrong. Here is a sample code to test gel,I got it from Random Number Generator Examples - GNU Scientific Library -- Reference Manual (note: made a few changes in the code) #include... (2 Replies)
Discussion started by: joseamck
2 Replies

3. UNIX for Advanced & Expert Users

Cygwin permission problem

I can't figure out why cygwin won't let me write a file to this directory. Any ideas? $ id uid=1007(jdbaldwin) gid=513(None) groups=513(None),0(root),544(Administrators),545(Users) $ ls -lad . drwxrwxrwx+ 1 jdbaldwin None 0 2010-09-29 12:47 . $ touch x touch: cannot touch `x': Permission... (3 Replies)
Discussion started by: jdbaldwin
3 Replies

4. UNIX for Advanced & Expert Users

Problem in cygwin

Hi All, I am using cygwin 2.697. When i was working with LAN its working fine. But when i am trying to working via ( Aventail Smart Tunnel), It close after 20 mins. But Exceed-10 is working fine, but it take more resource and its not freeware. so kindly help me in this regards. I have a... (1 Reply)
Discussion started by: rajamohan
1 Replies

5. HP-UX

Problem in HP-UX compiling

Hi When im trying to do make --version and make --help in HP-UX it throws error Make: Unknown flag argument -. Stop. a soft link is present in this directory /usr/bin/make and hard link is in /usr/ccs/bin/make what could be the reason can any1 ..please tell me how to solve this... (1 Reply)
Discussion started by: vasanthan
1 Replies

6. UNIX for Dummies Questions & Answers

Cygwin installation problem

hihi, im new here. just start to use cygwin as unix-based in Windows XP. my installation of cygwin is not success, it has procedure entry_impure_ptr problem due with ash.exe, install_info.exe, and In-exe files. do anyone know why is that so? (3 Replies)
Discussion started by: Suraine
3 Replies

7. UNIX for Dummies Questions & Answers

problem with cygwin

hi... i'm working on windows xp currently but i have to work on linux. the problem is there is no internet in linux OS so i decided to use cygwin which (i was told) can be used for unix based commands to an extent in windows.i have to write c-programs and i'm using emacs as editor and g++... (0 Replies)
Discussion started by: raya_g
0 Replies

8. Solaris

Problem's compiling Glib

Hello, I am trying to install glib on my development box - with little/no luck. Below are some details of the box: SunOS 5.8 Generic_117350-38 sun4u sparc SUNW,Ultra-Enterprise gcc version 2.95.2 19991024 (release) GNU Make version 3.78.1, by Richard Stallman and Roland McGrath. Glib version:... (2 Replies)
Discussion started by: tetley
2 Replies

9. Solaris

Compiling problem

I'm trying to install the jed text editor on a SunOS 5.10 box. It depends on the s-lang library, which I installed to ~/lib. I'm trying to install jed to ~/jed (it's a box @ my university, so I don't have rights to install globally), but when I run make I get this error: It looks like it... (1 Reply)
Discussion started by: iandunn
1 Replies

10. UNIX for Dummies Questions & Answers

cygwin problem

Hi, I have install cygwin in my PC which is having Windows-XP. I am able to run c programm successfully using gcc compiler but when i am running c++ program it is giving the following error: $ gcc abc.cpp /cygdrive/c/DOCUME~1/ADMINI~1/LOCALS~1/Temp/cclwkyqD.o:abc.cpp:(.text+0xd): unde... (0 Replies)
Discussion started by: gauri_agr
0 Replies
Login or Register to Ask a Question