So I'm using GCC. I downloaded MinGW base tools and g++ compiler from the installer, and wrote a basic "hello world" program. The source code is as followed:

#include <iostream> 

int main() 
{ 
std::cout << "Solidum petit in profundis!\n"; 
return 0; 
} 

I saved this as Motto.cpp. I went into the command prompt and typed in cd and dragged the file's location (which is a folder dubbed "programs") into the console. I hit enter, so now the path is that folder containing my file. I then entered the following command which compiles and links the file:

g++ Motto.cpp -o Motto.exe 

Now, I'm supposed to be seeing an output that reads "Solidum petit in profundis!". Instead, I'm getting an error message:

g++: Motto.cpp No such file or directory 
g++: no input files 

If it helps, the Variable Value is:

C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\sy... Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\QuickTime\QTSystem\;C:\MinGW\bin 

At the very end of the value the textbook instructed me to add ;C:\MinGW\bin in order to run G++ from any folder. I tested it by using the g++ --version command and it works normally. However, I cannot get Motto.cpp to compile.

Help?

Recommended Answers

All 3 Replies

After you cd to where you think Motto.cpp is locted, do dir command to make sure the file is where you think it is. The file needs to be in the current working directory.

Ensure it really is called Motto.cpp

Windows has a terrible habit of adding extra bits to the end of file names, and then hiding it from you; if you wrote Motto.cpp with a standard issue text editor, for example, it might be called Motto.cpp.txt

Windows has a terrible habit of adding extra bits to the end of file names, and then hiding it from you;

I never had that problem. But you are right about the spelling -- capitalization is not important on Windows but the file name must be spelled correctly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.