配置 g++ 以使用 wxwidget 库构建 c++
我一直在尝试在 Linux 中使用 Wxwidget 编译和运行一个简单的 C++ 程序,但是当我构建它时,这就是我尝试构建时得到的:
I've been trying to compile and run a simple c++ program with Wxwidget in Linux but when I build it this is what I got when I try to build :
Executing task: g++ -c $(find /home/sopheak/Documents/WXWIDGET/ -type f -iregex '.*\.cpp') -g -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -DWX_PRECOMP -fno-strict-aliasing -pthread -I/usr/local/lib/wx/include/gtk3-unicode-static-3.1/** -Iusr/include/** -I/usr/include/gtk-3.0/** -I/usr/include/at-spi2-atk/2.0/** -I/usr/include/at-spi-2.0/** -I/usr/include/dbus-1.0/** -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include/** -I/usr/include/gio-unix-2.0/** -I/usr/include/cairo/** -I/usr/include/pango-1.0/** -I/usr/include/fribidi/** -I/usr/include/harfbuzz/** -I/usr/include/atk-1.0/** -I/usr/include/pixman-1/** -I/usr/include/uuid/** -I/usr/include/freetype2/** -I/usr/include/libpng16/** -I/usr/include/gdk-pixbuf-2.0/** -I/usr/include/libmount/** -I/usr/include/blkid/** -I/usr/include/glib-2.0/** -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/** -I/usr/include/gtk-3.0/unix-print/** -Wall
zsh:1: no matches found: -I/usr/local/lib/wx/include/gtk3-unicode-static-3.1/**
The terminal process "zsh '-c', 'g++ -c $(find /home/sopheak/Documents/WXWIDGET/ -type f -iregex '.*\.cpp') -g -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -DWX_PRECOMP -fno-strict-aliasing -pthread -I/usr/local/lib/wx/include/gtk3-unicode-static-3.1/** -Iusr/include/** -I/usr/include/gtk-3.0/** -I/usr/include/at-spi2-atk/2.0/** -I/usr/include/at-spi-2.0/** -I/usr/include/dbus-1.0/** -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include/** -I/usr/include/gio-unix-2.0/** -I/usr/include/cairo/** -I/usr/include/pango-1.0/** -I/usr/include/fribidi/** -I/usr/include/harfbuzz/** -I/usr/include/atk-1.0/** -I/usr/include/pixman-1/** -I/usr/include/uuid/** -I/usr/include/freetype2/** -I/usr/include/libpng16/** -I/usr/include/gdk-pixbuf-2.0/** -I/usr/include/libmount/** -I/usr/include/blkid/** -I/usr/include/glib-2.0/** -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/** -I/usr/include/gtk-3.0/unix-print/** -Wall'" failed to launch (exit code: 1).
这里是我的 task.json :
Here my task.json :
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Compile",
"linux": {
"command": "g++",
"args": [
"-c",
"$(find",
"${workspaceFolder}/",
"-type",
"f",
"-iregex",
"'.*\\.cpp')",
"-g",
"-D__WXGTK__",
"-D_FILE_OFFSET_BITS=64",
"-DWX_PRECOMP",
"-fno-strict-aliasing",
"-pthread",
"-I/usr/local/lib/wx/include/gtk3-unicode-static-3.1/**",
"-Iusr/include/**",
"-I/usr/include/gtk-3.0/**",
"-I/usr/include/at-spi2-atk/2.0/**",
"-I/usr/include/at-spi-2.0/**",
"-I/usr/include/dbus-1.0/**",
"-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include/**",
"-I/usr/include/gio-unix-2.0/**",
"-I/usr/include/cairo/**",
"-I/usr/include/pango-1.0/**",
"-I/usr/include/fribidi/**",
"-I/usr/include/harfbuzz/**",
"-I/usr/include/atk-1.0/**",
"-I/usr/include/pixman-1/**",
"-I/usr/include/uuid/**",
"-I/usr/include/freetype2/**",
"-I/usr/include/libpng16/**",
"-I/usr/include/gdk-pixbuf-2.0/**",
"-I/usr/include/libmount/**",
"-I/usr/include/blkid/**",
"-I/usr/include/glib-2.0/**",
"-I/usr/lib/x86_64-linux-gnu/glib-2.0/include/**",
"-I/usr/include/gtk-3.0/unix-print/**",
"-Wall"
]
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "MoveObjects",
"linux": {
"command": "mv",
"args": [
"${workspaceFolder}/*.o",
"${workspaceFolder}/"
]
},
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [],
"dependsOn": [
"Compile"
]
}
]
}
我正在使用 Kali Linux,数周以来我一直在寻找构建 run wxwidgets 库的方法,但我仍然找不到任何好的答案.感谢您提前提供帮助!
I'm using Kali Linux and I've been trying looking for ways to build run wxwidgets library for weeks but I still couldn't find any good answer. Thanks you for helping in advance !
我觉得在 Linux 上的 VS Code 中使用 wxWidgets 时,最简单的就是使用 CMake.首先,您需要 CMake 和 CMake 工具扩展:
I think when using wxWidgets in VS Code on Linux, the easiest thing is to use CMake. To get started, you'll need both the CMake and CMake Tools extensions:
首先,在 VS Code 中打开您的项目:
To get started, open your project in VS Code:
然后打开命令托盘并选择CMake:Quick Start":
Then open the command pallet and select "CMake:Quick Start":
然后输入将在 CMake 文件中使用的项目的名称,并为项目类型选择可执行文件.我使用了cmakewx"为项目.选择可执行文件后,会出现一个CMakeLists.txt".文件和构建文件夹将被创建.
Then enter a name for the project that will be used in the CMake files and select executable for the project type. I used "cmakewx" for the project. After you select executable, a "CMakeLists.txt" file and a build folder will be created.
打开 CMakeLists.txt 文件.在文件中间应该有一行看起来像:
Open the CMakeLists.txt file. In the middle of the file there should be a line looking something like:
add_executable(cmakewx main.cpp)
就我而言,cmakewx"是我在上面为项目名称输入的名称.在您的情况下,它将是您输入的名称.将此更改为
In my case "cmakewx" is the name I entered above for the project name. In your case, it will be the name you entered instead. Change this to
find_package(wxWidgets REQUIRED COMPONENTS net core base)
include(${wxWidgets_USE_FILE})
add_executable(cmakewx main.cpp)
target_link_libraries(cmakewx ${wxWidgets_LIBRARIES})
但是替换cmakewx";使用您为项目选择的名称.
But replace "cmakewx" with the name you chose for the project.
最后,再次打开命令托盘并选择CMake:Configure"
Finally, open the command pallet again and select "CMake:Configure"
现在项目已准备就绪.您可以将状态栏上的按钮用于各种项目任务.此区域: 可用于更改项目的配置(调试/发布/等).这个区域 将构建项目,这些按钮 将调试并运行项目.
Now the project is ready to go. You can use buttons on the status bar for various project tasks. This area: can be used to change the project's configuration (debug/release/etc). This area will build the project, and these buttons will debug and run the project.
这可能看起来像很多步骤,但是当您熟悉该过程时,只需大约 30 秒即可准备好项目.
This may seem like a lot of steps, but when your familiar with the process it only takes about 30 seconds to get a project ready to go.
Intellisense 应在您配置项目后开始工作.但我已经看到有时它不会.我不知道为什么.如果发生这种情况,关闭并重新打开该项目应该会使智能感知工作.
Intellisense should start working after you configure the project. But I have seen that sometimes it doesn't. I'm not sure why. If this happens, closing and reopening the project should get intellisense working.