Information on configuring VSCode in Linux is sparse. In addition, information on configuring VSCode to run with wxWidgets is equally sparse. So, after days of poking around I finally got a working sample. Here is how I did it:
Starting conditions
- I am using Ubuntu 24.04.3
- I am installing the wxWidget binaries (not compiling from source code)
- The version of wxWidgets I'm using is 2.3.8
- I am using VSCode 1.103
-
You will create/edit json files under the .vscode directory of your project
- c_cpp_properties.json
- tasks.json
- launch.json (no changes needed)
-
You will edit a json file at ~/.config/Code/User
- settings.json
Here are the install steps:
- # install additional components # libwxgtk3.2-dev is wxWidgets sudo apt install git gcc g++ gdb make cmake libwxgtk3.2-dev # install VSCode via snap sudo snap install --classic code
- # link to wx at the root cd /usr/include sudo ln -s wx-3.2/wx wx
- # copy the setup.h file sudo cp /usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2/wx/setup.h /usr/include/wx-3.2/wx
- # install the C++ extensions in VSCode C/C++ C/C++ Extension Pack
-
# Add some minimal code
Perhaps from https://docs.wxwidgets.org/3.1/overview_helloworld.html
-
# create the json files
Shift-Control-P (to get the configuration list)
- select "C/C++ Edit Configure (UI)" - this will generate the c_cpp_properties.json file
- select the main.cpp file
- from the configuration list, select "C/C++ Debug Add Configuration" - this will generate the lauch.json file
- # add extra include folders to c_cpp_properties.json @ the project's .vscode directory "${workspaceFolder}/**" /usr/include/wx-3.2/wx /usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2
- # Add to settings.json @ ~/.config/Code/User/settings.json # This will contravene the Snap properties "terminal.integrated.env.linux": { "GTK_PATH": null, "GIO_MODULE_DIR": null, },
- Tweak the tasks.json file to change "${file}" to "${workspaceFolder}/*.cpp" Tweak the tasks.json file to include items from "wx-config --cxxflags -libs" "-I/usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2", "-I/usr/include/wx-3.2", "-D_FILE_OFFSET_BITS=64", "-DWXUSINGDLL", "-D__WXGTK__", "-L/usr/lib/x86_64-linux-gnu", "-pthread", "-lwx_gtk3u_xrc-3.2", "-lwx_gtk3u_html-3.2", "-lwx_gtk3u_qa-3.2", "-lwx_gtk3u_core-3.2", "-lwx_baseu_xml-3.2", "-lwx_baseu_net-3.2", "-lwx_baseu-3.2", Tweak the tasks.json file to force the standard C++ library (due to snap interference) "-lstdc++"