VS Code and wxWidgets: fatal error: wx/wx.h: No such file or directory
VS Code and wxWidgets: fatal error: wx/wx.h: No such file or directory
我使用 make
构建了 wxWidgets 并且没有任何错误,并且 make install
现在我已经在 /usr/local/include/wx-3.1/
中安装了。 wx/wx.h
和 wx/setup.h
都存在于该文件夹中。我正在使用最新的 VS Code 和最新的 Ubuntu 20.04.
c_cpp_properties.json
文件:
"configurations": [
{
"name": "Linux",
"includePath": [
"/usr/local/include/wx-3.1/",
"${default}"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu18",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
main.cpp
:
#include "wx/wx.h"
int main(){}
编译出现如下错误:
g++ -std=c++17 -Wall -Wextra -g -c -o src/main.o src/main.cpp
src/main.cpp:1:10: fatal error: wx/wx.h: No such file or directory
1 | #include "wx/wx.h"
| ^~~~~~~~~
compilation terminated.
奇怪的是,VS Code Intellisense 检测到包含 wx 并且没有错误或红色下划线(从 includePath
中删除包含文件夹会使 VS Code 显示错误)。
这里有什么问题?一切似乎都正确地包括在内。
此外,您需要将链接器指向要与 -L
选项一起使用的库,并对您需要的每个库使用 -l
(小写 L)。
示例:
-L/usr/local/lib -lwxcore-3.1 -lwxbase-3.1
检查那里的库名称并在没有 lib
前缀的情况下使用它们。
更好的是 - 尝试 运行 wx-config --libs
并将输出用于 IDE.
中的链接器选项
此外,对于编译器的完整选项集,请使用 wx-config --cxxflags
的输出
您必须配置 IDE 以使用正确的选项调用编译器。 wxWidgets 项目的正确选项必须包括 C++ 编译器的 `wx-config --cxxflags`
和链接器的 `wx-config --libs`
的输出。
不要不要硬编码项目选项中的任何路径,使用wx-config
既简单又便携。
我使用 make
构建了 wxWidgets 并且没有任何错误,并且 make install
现在我已经在 /usr/local/include/wx-3.1/
中安装了。 wx/wx.h
和 wx/setup.h
都存在于该文件夹中。我正在使用最新的 VS Code 和最新的 Ubuntu 20.04.
c_cpp_properties.json
文件:
"configurations": [
{
"name": "Linux",
"includePath": [
"/usr/local/include/wx-3.1/",
"${default}"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu18",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
main.cpp
:
#include "wx/wx.h"
int main(){}
编译出现如下错误:
g++ -std=c++17 -Wall -Wextra -g -c -o src/main.o src/main.cpp
src/main.cpp:1:10: fatal error: wx/wx.h: No such file or directory
1 | #include "wx/wx.h"
| ^~~~~~~~~
compilation terminated.
奇怪的是,VS Code Intellisense 检测到包含 wx 并且没有错误或红色下划线(从 includePath
中删除包含文件夹会使 VS Code 显示错误)。
这里有什么问题?一切似乎都正确地包括在内。
此外,您需要将链接器指向要与 -L
选项一起使用的库,并对您需要的每个库使用 -l
(小写 L)。
示例:
-L/usr/local/lib -lwxcore-3.1 -lwxbase-3.1
检查那里的库名称并在没有 lib
前缀的情况下使用它们。
更好的是 - 尝试 运行 wx-config --libs
并将输出用于 IDE.
此外,对于编译器的完整选项集,请使用 wx-config --cxxflags
您必须配置 IDE 以使用正确的选项调用编译器。 wxWidgets 项目的正确选项必须包括 C++ 编译器的 `wx-config --cxxflags`
和链接器的 `wx-config --libs`
的输出。
不要不要硬编码项目选项中的任何路径,使用wx-config
既简单又便携。