简体   繁体   English

如何在 VSCode 中为 GCC 设置 wxWidgets?

[英]How to setup wxWidgets in VSCode for GCC?

I'm trying to make a GUI-Project with wxWidgets.我正在尝试使用 wxWidgets 制作一个 GUI 项目。 Instead of using Visual Studio I want to use VSCode with the GCC (MinGW).我想将 VSCode 与 GCC (MinGW) 一起使用,而不是使用 Visual Studio。
I'm facing the following problem: I can't compile or run any code which has wxWidgets librarys included.我面临以下问题:我无法编译或运行任何包含 wxWidgets 库的代码。 How have the c_cpp_properties.json and the tasks.json files to be configured?如何配置 c_cpp_properties.json 和 tasks.json 文件?

I already went through the instructions for installing wxWidgets using "Cygwin/MinGW Compilation" part "Using plain makefiles:".我已经阅读了使用“Cygwin/MinGW 编译”部分“使用普通 makefile:”安装 wxWidgets 的说明。 ( https://docs.wxwidgets.org/3.1.2/plat_msw_install.html ) ( https://docs.wxwidgets.org/3.1.2/plat_msw_install.html )
1. cd .../wxWidgets-3.1.2\\build\\msw 1. cd .../wxWidgets-3.1.2\\build\\msw
2. mingw32-make -f makefile.gcc (for generating Build=debug per default) 2. mingw32-make -f makefile.gcc(默认生成Build=debug)

And added following to my files:并在我的文件中添加了以下内容:
tasks.json:任务.json:

    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g", "cApp.cpp", 
                "-I", "D:/Programme/wxWidgets-3.1.2/include/msvc", 
                "-I", "D:/Programme/wxWidgets-3.1.2/include", 
                "-L", "${WXWIN}/lib/vc_lib"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

c_cpp_properties.json: c_cpp_properties.json:

    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "${WXWIN}/include/msvc",
                "${WXWIN}/include"
            ],
            "browse": { "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "${WXWIN}/include/msvc",
                    "${WXWIN}/include"
                ]
            },
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "__WXMSW__",
                "NDEBUG",
                "WXUSINGDLL"
            ],
            "compilerPath": "E:/Programme/MinGW/bin/g++.exe",
            "compilerArgs": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.exe",
                "-I", "${WXWIN}/include/msvc",
                "-I", "${WXWIN}/include",
                "-L", "${WXWIN}/gcc_lib",
                "-L", "${WXWIN}/gcc_lib/mswud"
            ]
        }
    ],
    "version": 4
} 

I got the following error from my own code while compiling, which uses #include "wx/wx.h" :我在编译时从我自己的代码中得到以下错误,它使用#include "wx/wx.h"

                 from ${WXWIN}/include/wx/defs.h:45,
                 from ${WXWIN}/include/wx/wx.h:14,
                 from ${Project}\VSC-Basic-ProjectSetup\src\cMain.h:1,
                 from ${Project}\VSC-Basic-ProjectSetup\src\cMain.cpp:1:
${WXWIN}/include/msvc/wx/setup.h:12:6: error: #error "This file should only be included when 
     #error "This file should only be included when using Microsoft Visual C++"
      ^~~~~
...
...
...
In file included from ${WXWIN}/include/wx/platform.h:148:0,
                 from ${WXWIN}/include/wx/defs.h:45,
                 from ${WXWIN}/include/wx/wx.h:14,
                 from ${Project}\VSC-Basic-ProjectSetup\src\cMain.h:1,
                 from ${Project}\VSC-Basic-ProjectSetup\src\cMain.cpp:1:
${WXWIN}/include/msvc/wx/setup.h:125:27: fatal error: ../../../lib/vc_lib /msw /wx/setup.h: N
 #include wxSETUPH_PATH_STR
                           ^
compilation terminated.
The terminal process terminated with exit code: 1

${WXWIN}, ${Project} are just placeholders. ${WXWIN}, ${Project} 只是占位符。

I know it's little bit too late but here is "Hello World" project for VSCode.我知道现在有点太晚了,但这里是 VSCode 的“Hello World”项目。 You can observe all required includes and libraries to successfully compile & link your project in VSCode.您可以观察到在 VSCode 中成功编译和链接您的项目所需的所有包含和库。 All 3 major OS's are included in project.所有 3 个主要操作系统都包含在项目中。 https://github.com/huckor/wxwidgets-vscode https://github.com/huckor/wxwidgets-vscode

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM