Skip to content

Instantly share code, notes, and snippets.

@Acry
Last active June 11, 2023 20:32
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save Acry/e0a167f6d323feb0519edb47248ab3bf to your computer and use it in GitHub Desktop.
Save Acry/e0a167f6d323feb0519edb47248ab3bf to your computer and use it in GitHub Desktop.
Kick off VSCode for C and GTK 3.

Code GTK 3 in C with VSCode

Kick off VSCode for C and GTK 3.

c_cpp_properties.json

{
  "configurations": [
    {
      "name": "C Linux GTK3",
      "includePath": [
        "${workspaceFolder}/**",
        "/usr/lib/glib-2.0/include/",
        "/usr/include/gtk-3.0",
        "/usr/include/pango-1.0",
        "/usr/include/glib-2.0",
        "/usr/lib/libffi-3.2.1",
        "/usr/include/harfbuzz",
        "/usr/include/fribidi",
        "/usr/include/freetype",
        "/usr/include/libpng16",
        "/usr/include/cairo",
        "/usr/include/pixman-1",
        "/usr/include/gdk-pixbuf-2.0",
        "/usr/include/libmount",
        "/usr/include/blkid",
        "/usr/include/gio-unix-2.0",
        "/usr/include/atk-1.0",
        "/usr/include/at-spi2-atk/2.0",
        "/usr/include/at-spi-2.0",
        "/usr/include/dbus-1.0",
        "/usr/lib/dbus-1.0/include",
        "/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include",
        "/usr/local/include",
        "/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include-fixed",
        "/usr/include"
      ],
      "defines": [],
      "compilerPath": "/usr/bin/gcc",
      "cStandard": "c11",
      "cppStandard": "c++17",
      "intelliSenseMode": "clang-x64",
      "compilerArgs": [
        "-Wall",
        "-Wextra",
        "-mtune=native",
        "-no-pie",
        "`pkg-config gtk+-3.0 --cflags`",
        "`pkg-config --libs gtk+-3.0`",
        "-lm"
      ]
    }
  ],
  "version": 4
}

Code GTK 3 in C with VSCode

Kick off VSCode for C and GTK 3.

Prerequisites

Compiler

GCC and Clang

Build Tools

pkg-config and GNU Make

Used Extension

Name: C/C++
Id: ms-vscode.cpptools
Description: C/C++ IntelliSense, debugging, and code browsing.
Version: 0.26.2
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

Config

see:
.vscode/c_cpp_properties.json

That is basically:
pkg-config --libs --cflags gtk+-3.0

Where your glibconfig.h lives:
/usr/lib/glib-2.0/include/

And the output from
cpp -v

That is my include search path for the C preprocessor:

/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include-fixed
/usr/include

Prerequisites

Compiler

GCC and Clang

Build Tools

pkg-config and GNU Make (optional)

Used Extension

Name: C/C++
Id: ms-vscode.cpptools
Description: C/C++ IntelliSense, debugging, and code browsing.
Version: 0.26.2
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

Config

see:
.vscode/c_cpp_properties.json

That is basically:
pkg-config --libs --cflags gtk+-3.0

Where your glibconfig.h lives:
/usr/lib/glib-2.0/include/

And the output from
cpp -v

That is my include search path for the C preprocessor:

/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include-fixed
/usr/include
@Fabxx
Copy link

Fabxx commented Feb 2, 2022

Hi, i'm having some trouble with setting this up, do you have discord please?

@Acry
Copy link
Author

Acry commented Feb 2, 2022

Hi!
It totally depends on your tool chain.
If you use the gnu tool chain you can try to clone this first.

Take care, there is still rust code in the repo. The Ms c/cpp extension is under heavy development. I tried to set it up on windows and it was not nice.

I bought an ultimate licence of jet brains development tools because I use C#, python, Java, go and typescript too.

Even i had serious issues using Clion years back for plain c with the gnu tool chain.

And yes I do have discord but I am currently very busy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment