cygwin g++ produces no output

一笑奈何 提交于 2020-01-03 05:57:05

问题


I just installed g++ from cygwin, when I try to compile a C++ file I am not getting any executable produced by the compiler, see example below. What's going wrong?

 Directory of C:\helloworld

01/02/2011  04:50 PM              .
01/02/2011  04:50 PM              ..
01/02/2011  04:48 PM                94 helloworld.cpp
               1 File(s)             94 bytes
               2 Dir(s)  24,658,272,256 bytes free

C:\helloworld>g++-4 helloworld.cpp

C:\helloworld>dir
 Volume in drive C is OS
 Volume Serial Number is C47B-942D

 Directory of C:\helloworld

01/02/2011  04:50 PM              .
01/02/2011  04:50 PM              ..
01/02/2011  04:48 PM                94 helloworld.cpp
               1 File(s)             94 bytes
               2 Dir(s)  24,657,747,968 bytes free

C:\helloworld>

回答1:


The problem seems to be (judging from your C:\ prompt) that you are not running Cygwin. Try double-clicking the Cygwin icon.




回答2:


For others who end up here with g++ producing no output.

I solved it by running cygcheck -s in the cygwin terminal window. This checks (amongst others) for multiple instances of cygwin1.dll. In my case WinAVR was causing problems, uinstalling did the the trick

This link was also helpful in getting Cygwin to run properly: http://thehacklist.blogspot.nl/2009/04/cygwin-ls-command-not-found.html




回答3:


You should be able to run any Cygwin program from the DOS prompt since Cygwin is not an operating system like Linux, it is primarily a special DLL that programs link against + tools. However, in this case, I suspect that path issues are preventing g++ from running, either the path to g++ itself or to some libs g++ requires. Cygwin apps are notoriously bad at giving any info when they don't run, and the solution is to run them via strace.

C:\cygwin\bin> strace g++

Then any issues will be shown in a windows dialog box.



来源:https://stackoverflow.com/questions/4581388/cygwin-g-produces-no-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!