Windows vs代码wxWidgets的#include< wx/wx.h>未找到 [英] Windows vs code wxWidgets's #include <wx/wx.h> not found

查看:127
本文介绍了Windows vs代码wxWidgets的#include< wx/wx.h>未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用window10和vs代码来编译一些源代码.我可以编译代码,但是当我运行.exe文件时.什么都没有出现.我得到了这个错误.

I use window10 and vs code to compile some source code. I can compile the code but when I run the .exe file. Nothing shows up. I got this error.

我的cmakefile如下:

My cmakefile is as follows:

    cmake_minimum_required(VERSION 3.11.3)
    
    set(CMAKE_CXX_STANDARD 17)
    
    project(membot)
    set(wxWidgets_ROOT_DIR "C:/wxWidgets-3.1.4")
    set(wxWidgets_LIB_DIR "C:/wxWidgets-3.1.4/lib/gcc_dll"
        CACHE PATH "wxWidgets_LIB_DIR ")
    find_package(wxWidgets REQUIRED COMPONENTS core base)
    include(${wxWidgets_USE_FILE})
    
    file(GLOB project_SRCS src/*.cpp)
    
    add_executable(membot ${project_SRCS})
    target_link_libraries(membot ${wxWidgets_LIBRARIES})
    target_include_directories(membot PRIVATE ${wxWidgets_INCLUDE_DIRS})

我不知道该怎么解决.我还尝试将路径包含在c_cpp_properties.json中,但仍然无法正常工作.

I don't know how to solve it. I also tried to include the path in the c_cpp_properties.json, but still doesn't work.

推荐答案

我找到了解决方案.

  1. 在cmakefile.txt中,我使用 find_package(wxWidgets必需的gl核心基础OPTIONAL_COMPONENTS net),而不是 find_package(wxWidgets所需的组件核心基础)

我最终的cmakefile.txt就是这样

My final cmakefile.txt is like this

cmake_minimum_required(VERSION 3.11.3)

set(CMAKE_CXX_STANDARD 17)

project(membot)

set(wxWidgets_ROOT_DIR "C:/wxWidgets-3.1.4")
set(wxWidgets_LIB_DIR "C:/wxWidgets-3.1.4/lib/gcc_dll")
find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)

include(${wxWidgets_USE_FILE})

file(GLOB project_SRCS src/*.cpp)

add_executable(membot ${project_SRCS})
target_link_libraries(membot ${wxWidgets_LIBRARIES})
target_include_directories(membot PRIVATE ${wxWidgets_INCLUDE_DIRS})

  1. 引用此 https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW 具有正确的wxwidgets构建.我使用 mingw32-make -f makefile.gcc SHARED = 1 UNICODE = 1 BUILD = release clean 清理动态库,并使用 mingw32-make -f makefile.gcc SHARED = 0 UNICODE =1 BUILD = release clean 清除静态库.然后,我使用此 mingw32-make -j8 -f makefile.gcc BUILD = release SHARED = 0 UNICODE = 1 VENDOR = custom 来构建静态库.
  2. 使用 cmake -G"MinGW Makefiles".. make 来编译源代码.成功了.
  1. Referring to this https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW to have a correct wxwidgets build. I use mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release clean to clean the dynamic libraries and use mingw32-make -f makefile.gcc SHARED=0 UNICODE=1 BUILD=release clean to clean the static libraries. Then I use this mingw32-make -j8 -f makefile.gcc BUILD=release SHARED=0 UNICODE=1 VENDOR=custom to build static libraries.
  2. Use cmake -G "MinGW Makefiles" .. and make to compile the source code. It succeeded.

这篇关于Windows vs代码wxWidgets的#include< wx/wx.h>未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆