Using wxwidgets on VS Code over Linux

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
grazianobolla
In need of some credit
In need of some credit
Posts: 1
Joined: Thu Jan 14, 2021 11:15 pm

Using wxwidgets on VS Code over Linux

Post by grazianobolla »

I am trying to setup wxwidgets in Linux using VSCode, I can get the example to compile and run from the terminal using

Code: Select all

g++ main.cpp `wx-config --cxxflags --libs` -o app
but it wont compile on VSCode, it also throws some intellisense errors that are clearly wrong as the project compiles and runs just fine on the terminal, here is my tasks.json

Code: Select all

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "main.cpp",
                "`wx-config --cxxflags --libs`",
                "-o",
                "app.o"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
main.cpp is just the hello world example from the wxwidgets page.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Using wxwidgets on VS Code over Linux

Post by ONEEYEMAN »

Hi,
Why do you want to do that?
You can compile the samples and "Hello World" using the basic Terminal command.

Thank you.
Viriathe
In need of some credit
In need of some credit
Posts: 1
Joined: Sun Sep 04, 2022 6:49 am

Re: Using wxwidgets on VS Code over Linux

Post by Viriathe »

Hello
I have encountered the same problem

After many searches on the web, I did not find a suitable answer.
However I was falling on this post .
So I have the idea to put the oblique quote the one on the 7 pad of the French AZERTY keyboard obtained with <ALT GR + 7> I think it's the same as the one under the tilde of the QWERTY keyboard

Code: Select all

            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "`wx-config --cxxflags --libs`",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
and it works.

I think this is partly because wx-config is not an option but a script

Code: Select all

[arch@archLinux myapp]$ type wx-config
wx-config est /usr/local/bin/wx-config
[arch@archLinux myapp]$ 

-------------------- Edit -----------

and if you want launch the binary result file directly from VSCODE console you should set correctly the environment variable on launch.json file like this

Code: Select all

                "cwd": "${fileDirname}",
                "environment": [
                    {   
                        "name": "LD_LIBRARY_PATH",
                        "value": "/usr/local/lib"
                    }
                ], 
Last edited by Viriathe on Sun Sep 04, 2022 8:50 am, edited 3 times in total.
New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

Re: Using wxwidgets on VS Code over Linux

Post by New Pagodi »

Even the authors of VSCode say that it is intended to be a code editor and not a full featured IDE. The build system it includes is really only intended to build a single file. Trying to hack it to build a full project is not recommended.

So if you want to use VSCode to build projects, it's best to combine it with a build tool like CMake or Meson. Extensions for both are included in the marketplace. I wrote an answer on stackoverflow about how to do this with CMake here.
Post Reply