簡體   English   中英

VS Code 和 wxWidgets:致命錯誤:wx/wx.h:沒有那個文件或目錄

[英]VS Code and wxWidgets: fatal error: wx/wx.h: No such file or directory

我構建 wxWidgets 時沒有任何make錯誤,並且確實make install ,現在我在/usr/local/include/wx-3.1/進行了安裝。 wx/wx.hwx/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的項目正確的選項必須包括的輸出`wx-config --cxxflags`的C ++編譯器和`wx-config --libs`為連接器。

不要硬編碼在你的項目中選擇任意路徑,使用wx-config是更簡單,更便於攜帶。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM