![](/img/trans.png)
[英]How to setup wxWidgets under Windows + Eclipse + Cygwin + GCC
[英]How to setup wxWidgets in VSCode for GCC?
我正在嘗試使用 wxWidgets 制作一個 GUI 項目。 我想將 VSCode 與 GCC (MinGW) 一起使用,而不是使用 Visual Studio。
我面臨以下問題:我無法編譯或運行任何包含 wxWidgets 庫的代碼。 如何配置 c_cpp_properties.json 和 tasks.json 文件?
我已經閱讀了使用“Cygwin/MinGW 編譯”部分“使用普通 makefile:”安裝 wxWidgets 的說明。 ( https://docs.wxwidgets.org/3.1.2/plat_msw_install.html )
1. cd .../wxWidgets-3.1.2\\build\\msw
2. mingw32-make -f makefile.gcc(默認生成Build=debug)
並在我的文件中添加了以下內容:
任務.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:
"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
}
我在編譯時從我自己的代碼中得到以下錯誤,它使用#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} 只是占位符。
我知道現在有點太晚了,但這里是 VSCode 的“Hello World”項目。 您可以觀察到在 VSCode 中成功編譯和鏈接您的項目所需的所有包含和庫。 所有 3 個主要操作系統都包含在項目中。 https://github.com/huckor/wxwidgets-vscode
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.