gcc-integration is a JetBrains IDE Plugin specifically designed for IDEs that do not have c/cpp support such as PyCharm. Its functionality is simple - it adds a keyboard shortcut that can run the GCC/G++ compiler on the active file (GCC must be already installed and in your system PATH).
The default keyboard shortcut is ctrl + shift + G
.
GCC must be installed separately. To download, follow these steps:
- Visit https://sourceforge.net/projects/mingw/ and download.
- In the GUI under "basic setup", check off
mingw32
andmingw32gcc-g++
- Click "Installation > Apply Changes"
- Add MingW32 to your System path (
C:\MinGW\bin
)
Run the command brew install gcc
You can either install directly through PyCharm, or install from its GitHub releases.
- To install directly through PyCharm, open
PyCharm --> Settings --> Plugins
and search GCC/G++ Integration on the marketplace
- To manually install, visit the latest GitHub release and download the
.jar
. OpenPyCharm --> Settings --> Plugins
, click the Settings cog and chooseInstall Plugin from disk...
Note that each version of PyCharm needs a specific plugin file, for example the plugin version ending in 231 will only be compatibility with PyCharm version 231.
If the file that's open in the editor is of type .c or .cpp, press ctrl + shift + G
to send it straight to the GCC/G++ compiler in a new IDE Tool Window. If the file successfully compiles, this plugin will also run the created executable in the same toolwindow.
You can add optional settings to the plugin per each file.
Adding inline comments to the active C/C++ file above all code can modify the behavior of compilation/running of the active file's code.
In this example we've added test.cpp
as an additional source file for the plugin when it compiles main.cpp
. We've also chosen the parameters of "hello" & "world" for the main.cpp
file. The plugin determines which file is the "active file" based on which one you've clicked onto last.
As main.cpp
is the active file while we press ctrl + shift + G
in this example, the plugin compiles it along with the specified additional source file test.cpp
, and then runs the resulting executable with the specified params (hello, world).
For more information on configuring these types of settings, read on!
- Adding Arguments/Parameters
// [param1, param2, ...]
- Adding Additional Source Files
// +file1.c, +file2.c, +../file3.c, ...
By default, no parameters will be passed to the active file when it's run after compilation. To add parameters, add a comment above all code in the active file listing all desired parameters:
// [param1, param2, param3, ...]
#include <stdio.h>
int main() {};
This supports adding files, integers, or anything else as parameters. For file paths in parameters, you can either use an absolute path, or a relative path from the active file's directory.
Adding comments above the code that begin with +file.c
will tell the plugin to compile the current file along with the ones specified.
You can use either of the follow syntax:
// +file.cpp
// +file2.cpp
// +file.cpp, file2.cpp