How do I run a simple C++ program in the Cloud9 IDE? - c++

I am working on a translation application in my high school Computer Science Advanced Studies class. MY school's computers have a CodeBlocks IDE, but no compiler installed. So, I decided to try and find one online that I can use, and Cloud9 seemed like a good prospect. However, when I try to run my program, I get errors such as the following:
g++: error: /home/ubuntu/workspace/English-Spanish: No such file or directory
g++: fatal error: no input files
compilation terminated.
chmod: cannot access ‘/home/ubuntu/workspace/runme’: No such file ordirectory
sh: 1: /home/ubuntu/workspace/runme: not found
I'm not sure where the problem is or how to fix it. Any tips? I'm new to the online IDE scene.

Looks like you didn't add any source code to your project.

I figured out what was wrong. It was a simple mistake, really. My project's filename was "English-Spanish Translator," but spaces are not acceptable for filenames. I renamed it "eng-esp_translate.cpp," and it ran just fine.

Related

VS Code Error when compiling C++ Program: 'cmd' is not recognized as an internal or external command

I attempted to follow through on VS Code's method on making C++ code work on their editor. I did this successfully on my laptop but when I tried compiling it, I was met with the error:
* Executing task: C/C++: g++.exe build active file
Starting build...
C:\msys64\mingw64\bin\g++.exe -fdiagnostics-color=always -g "C:\Users\salty\Documents\Programming\C++ Scripts\myProgram\main.cpp" -o "C:\Users\salty\Documents\Programming\C++ Scripts\myProgram\main.exe"
'cmd' is not recognized as an internal or external command,
operable program or batch file.
Build finished with error(s).
* The terminal process failed to launch (exit code: -1).
* Terminal will be reused by tasks, press any key to close it.
This is the entire error message plus extra things in my editor.
If I try and copy and paste the command in the message into Windows Power Shell, it actually works (New .exe file appeared in the correct directory and runs without fault).
These are my environment variables for User, and these are my System variables.
I've tried uninstalling and re-installing and changing the paths around. I'm new to C++ programming and how compilers work in general, but I'm not sure why VS Studio says it doesn't recognize cmd among others it could've not recognized.
Why is it giving me this error?
Edit: I believe I didn't include a return 0; line in the program. Correcting this did not fix the issue.
I am not sure what I poked into place or if I just was too incompetent to realize something, however adding %SystemRoot%\system32 to my PSModulePath environment variables somehow fixed the issue, and since that action I have yet to replicate the compile error.
I don't know if adding that variable to my environments permanently fixed it or VS Studio needed a moment to process some things. Thanks anyways!

i don't know what is wrong with vs code in running cpp

i just started to code in cpp and nothing is working idk if i didn't install the gcc properly or what but i already set the path of the bin file idk why it refuses to run
the code:
#include<iostream>
int main()
{
std::cout<<"hello";
}
and the problem is that when I try to use the "code runner extension" it is not working so I just press f5 and then when I get the error messages which says at first "could not find the task file'c/c++:g++.exe build active file' " and I get three options 1:debug anyway
2:configure task
3:cancel
when I choose debug anyway I get this error here
Since you're on windows consider installing Visual Studio or CLion. They're more beginner friendly - VSCode can get tricky to run c++ on windows. Either way, looks like you're trying to run your project without building it first. There should be a build option right next to the run option. Try building it, then running. The build is what compiles and creates the project.exe file, which is what the compiler is saying isn't there.
The referenced IDE's always auto-build on run, so there's that
If you're familiar with using the command line, these commands will do what you want, assuming the .cpp file is in your current directory.
g++ <FILENAME>
./a.out
There are wonderful flags you can add to the first command (the compiling command) like -Wall, -Wextra, -o, and many more. But, since it seems like you're just starting out, there's no need to worry about those!
If you're not familiar with the command line, I would encourage you to become familiar! It is an extremely powerful tool for a programmer. Here is a YouTube video that talks about it.

Codeblocks C 'Hello World' : Does not run, No such file or directory [duplicate]

I'm new to programming so I feel there is something simple I'm missing here.
I'm using the latest version of Mac and I've just installed Code::Blocks along with Xcode so I can use the gcc compiler.
I created a new "console application" project and the code for a hello world program shows up.
I built this code and it gave me 0 errors and 0 warnings so I thought it was off to a good start.
But when I go to run this code all I get is the following in my Terminal window:
*/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
Ryan-McMullens-iMac:~ Ryan$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
sh: /Users/Ryan/Documents/C++: No such file or directory
Process returned 127 (0x7F) execution time : 0.003 s
Press ENTER to continue.*
I've checked to make sure its using the gcc compiler. I've also tried creating a C++ directory in my documents folder but that didn't help.
Like I said, I feel like I'm just missing a step somewhere so any help would be really appreciated!
Thanks!
Try avoiding using '+' and spaces in the name of directories.
Many program don't handle escaping of pathnames when running external tools like compiler, linker or when calling the final executable.
Remove spaces from your path. It seems that codeblocks does not quote the paths, so every space will be introducing a new command or parameter. The problem here is this part:
C++ book
because it has a whitespace.

Code::Blocks isn't executing properly

I'm new to programming so I feel there is something simple I'm missing here.
I'm using the latest version of Mac and I've just installed Code::Blocks along with Xcode so I can use the gcc compiler.
I created a new "console application" project and the code for a hello world program shows up.
I built this code and it gave me 0 errors and 0 warnings so I thought it was off to a good start.
But when I go to run this code all I get is the following in my Terminal window:
*/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
Ryan-McMullens-iMac:~ Ryan$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Ryan/Documents/C++ book stuff/SayHello/bin/Debug/SayHello
sh: /Users/Ryan/Documents/C++: No such file or directory
Process returned 127 (0x7F) execution time : 0.003 s
Press ENTER to continue.*
I've checked to make sure its using the gcc compiler. I've also tried creating a C++ directory in my documents folder but that didn't help.
Like I said, I feel like I'm just missing a step somewhere so any help would be really appreciated!
Thanks!
Try avoiding using '+' and spaces in the name of directories.
Many program don't handle escaping of pathnames when running external tools like compiler, linker or when calling the final executable.
Remove spaces from your path. It seems that codeblocks does not quote the paths, so every space will be introducing a new command or parameter. The problem here is this part:
C++ book
because it has a whitespace.

Basic ping pong style C++ program, can't seem to get it to compile and run

To start off I must say I am an absolute n00b. I just started with C++ and I am trying to figure it out. To issue I am having is I found this source code on google for Ping Pong and I've saved it as "pong.cpp" from sublime text edit to my Desktop. I am under the impression that all C++ programs have to be run through the terminal? but I am not sure, again beginner problems. So in terminal I direct it to my desktop in from there I type in g++ pong.cpp. Then it says this:
pong.cpp:2:10: fatal error: 'allegro.h' file not found
#include <allegro.h>
1 error generated.
I am thinking this is because I found it on google and that I need a file to back up the processing on the program which is unavailable.
Does anyone know where I could get a proper Ping Pong C++ code that would suite what I need here? I just want to be able to run a basic pingpong style game through my terminal to get more familiarized with C++
You have to tell gcc where allegro.h is installed. Run this command in terminal and post the output.
find / -name 'allegro.h' 2>/dev/null