the screenshot shows what the empty field and the code writtenI have just set up VS Code for programming with C, I installed all the necessary things (gcc, gdb..etc)
But when I started writing basic code, vs code shows an empty output after I run it
Installation (Ignore if installed)
Windows
Install mingw/gcc/clang compiler and then add it to the path.
GNU/Linux
Install gcc/clang compiler using your package manager.
Arch Based Distros: `sudo pacman -S gcc`
Ubuntu/Other debian based distro: `sudo apt install gcc g++`
Now, install C/C++ extension for VSCODE here's the link C/C++ extension
Installing the C/C++ VSCODE extenion
Or you can directly install it through Ctrl+Shift+P and paste this snippet ext install ms-vscode.cpptools.
Compiling
Now, open your terminal in VSCODE and run gcc Test.c -o test and then run ./test to execute your program.
Or, if you have installed clang compiler then the terminal command goes here clang Test.c -o test and then run ./test to execute your program.
Main method have return type int, try return 0; after printf. Or you need to add argument to main method, in java program i know we can not run program without argument.
Or
Try make void main method
Related
I downloaded atom a couple of days ago and I can't seem to find the right package or where and how you compile the program.
does anyone know?
Now, it's possible to run and compile (also debug) C and C++ program from within atom editor.
Install gpp compiler package in atom editor.
Prerequisites:
Windows:
You'll need to install MinGW and add it to your system PATH.
Mac:
You'll need to install XCode.
Linux:
The GNU Compiler Collection may come with your distribution. Run which gcc g++ to find out.
To compile and run: F5
To debug: F6
Atom is "simply" a Text editor that is not able to compile anything. If you use a Makefile, then there are a few add-ons for building targets via key bindings.
If not, open a terminal and use the C compiler on your system. On Linux/Unix machines you probably want to use gcc:
gcc <your_source>.c -o <output_name>
EDIT
Or take a look at This Package
here's a link for atom gnu gcc compiler-- https://atom.io/packages/gpp-compiler
1. download it
2. place the file in atom's package folder
3. press F5 on atom editor to RUN n Compile your file.
it will open text.ext as a output.
Can you tell me how to install GTK on windows 10 or have a step by step guide, all the ones I've tried have not helped me.
Possibly if someone also explain how to compile from cmd or prepare an IDE (code: block maybe).
Any commands I mention should be run at the MINGW shell, found here: C:\msys64\msys2_shell.cmd
First update msys2 with pacman -Syu
Make sure you have installed GCC...Install the required toolchain for GCC with pacman -S mingw-w64-x86_64-toolchain. When using pacman, just keep typing enter if prompted to follow through with the installation and get back to the command prompt.
In order to set this step up with Code:Blocks, make sure you go to the Code:Blocks menu Settings->Compiler, and the menu Toolchain Executables. From there, put in the msys2 installation directory and where you installed MinGW's GCC compiler (for me this was putting C:\msys64\mingw64) under the compiler's installation directory option. Also edit the C Compiler path under the same menu to x86_64-w64-mingw32-gcc.exe.
Next, in order to install gtk+3.0, use the command pacman -S mingw-w64-x86_64-gtk3. Now the latest version of GTK+3.0 will have been installed, so it is time to set it up with Code:Blocks.
Open Code:Blocks and create a new C file. You may definitely write your code in Code:Blocks, but I do not suggest that you compile it from there. Two compile, go back to the MINGW shell. Type nano ~/.bashrc to edit it. You may scroll down using the arrow keys to the bottom of the file and add: PATH=$PATH:/c/msys64/mingw64/bin. Restart the MINGW shell and open it back up.
Finally, try running:
gcc source.c -o executable.exe `pkg-config --cflags --libs gtk+-3.0`.
If that command doesn't work, I would suggest using the i686 version of gcc installed in MINGW.
I hope this helps!
Gcc was running in my system until I started using the eclipse IDE (for school reasons) and encountered a problem where it would or would not compile my code randomly. Long story short now I don't have gcc installed on my mac (gcc -v returns "gcc : command not found"). I've tried installing command line tools, Xcode, command line tools and Xcode with no result. Any ideas?
I am trying to write some C code and execute it through Cygwin command line interface using the below command but it throws me an error. I selected the gcc package when i have installed the Cygwin utility. Please kindly share your thoughts regarding the same. Thank you.
$ gcc HelloWorld.cpp -o HelloWorld
-sh: gcc: command not found
I'm trying to Compile my C program I have on my Mac.
I've been using Codepad.org to check that my Code works, but Codepad doesn't let me input my own values.
I need a Compiler that lets me input my own values, and I can save the Output as a txt file (to submit to my Professor).
2 possible ways,
get xcode, which includes gcc.
install macports, and use macports to install gcc.
Just use the Terminal app with gcc.
You can then run by appending ./ before the program name and > to save the output.
gcc -Wall program.c -o program
This will compile with all warnings (-Wall) with executable name program (-o).
run ./program > textfile.txt and this will put the output in a file.
(You might have to install Xcode and command line tools depending on your OS version)