Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"g++ is not recognized as an internal or external command"

Status
Not open for further replies.

newbiebie

Programmer
Aug 18, 2009
8
US
Hello,

I try to use Eclipse as an IDE for C programming. Hence, I installed cygwin successfully thereby getting gcc,gdb, and make tools. I'm able to execute C programs on cygwin, however I can't do that on Command prompt. I know, there must be a problem related to Path. But I added C:\Cygwin\bin;C:\Cygwin\usr\bin to the path. I double-checked the folders by bash command on Cygwin.

Nothing worked out yet. I've no idea about the next step. What I know is I can't use Eclipse in the present conditions.

Thanks in advance for valuable responses.
 
From the command prompt, if you type

g++ --version

what do you get?
 
I get the same error "g++ is not recognized as an internal or external command".

However when I type the same to Cygwin I get
g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125

Thanks a lot,

 
In cygwin, type

whence g++

If that doesn't work, type

which g++

This will tell you where g++ lives. Add that to your path.
 
I've already done that, but I tried again.

Clearly, I got usr/bin/g++ when I typed 'which g++' on gygwin. Next, I added c:/cygwin/usr/bin to the path which is located on the system variables.

What do you think for any other step?

Thanks.
 
Which way round did you put the /. Was it / or \? It needs to be \ on windows.

What happens if you type

C:\cygwin\usr\bin\g++.exe --version
 
Yeah it's like \. I misprinted it on the forum.

I noticed one thing that there's no bin file in cygwin\usr, I guess there is sbin file instead of bin. However, when I typed C:\cygwin\usr\sbin\g++.exe --version I got the same error "g++ is not recognized as an internal or external command".

One more thing, as you mentioned before when I type which g++ on Cygwin I get usr/bin/g++. I'm totally confused:-(

Anyway, I'm gonna try to add C:\cygwin\usr\sbin to the path.

Thanks.
 
Do the following in a DOS prompt
Code:
cd c:\cygwin
dir /s g++.exe
If it cannot find it then it is probably using gcc as an alias for g++. In bash, if you do ls -l /usr/bin/g++

1) what size is it
2) how many inodes does it have. If it has more than 1 (like vi) then it is one of those files which has a different personality depending on what it is called
 
Hello,

I appreciate your help.

I typed the code on command prompt, but it couldn't find.

When I do ls -l /usr/bin/g++ that gave me

lrwxrwxrwx 1 username None 21 Aug 18 17:59 /usr/bin/g++ ->
/etc/altenatives/g++

If it means anything to you, let me know the next step please.

Thanks.
 
Add C:\cygwin\etc\alternatives to your path
 
Ohh gosh!! the same error appears. It happened very exhausting, I hope to be edge of success.

Thanks for your kind effort.
 
In cygwin, ls -l /etc/alternatives/g++

Track it until the first letter of lrwx... is not l. Say it goes to /aaa/bbb/g++

Have a look at C:\cygwin\aaa\bbb. Is g++.exe there? If it is then add C:\cygwin\aaa\bbb to the path.
 
Another alternative is to just replace g++ with gcc since g++, like gfortran is just a variant of gcc with some flags set.

I haven't got cygwin installed so I can't really check for you.
 
I'm going crazy buddy, it has been one week that I couldn't deal with that crap.

Anyway, I realize that the right message is

lrwxrwxrwx /usr/bin/g++ -> /etc/altenatives/g++-3.exe

notice to g++-3.exe

When I look into the alternatives file, I see there are g++-3.exe, g++-4.exe, gcc-3.exe, gcc-4.exe shortcuts whose target files are located in cygwin\bin. There is no such file named /usr/bin. As I mentioned before, there is sbin file in usr directory.

Besides, I saw g++.exe and gcc.exe shortcuts in bin directory, but they don't have any target file. Do you think that might cause a problem?

Any suggestion??
 
Easiest way is to

1) unlink /usr/bin/g++
2) copy /etc/alternatives/g++3.exe to /usr/bin/g++.exe
 
Alright, I got it, at last.

Thank you for contribution. Well done.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top